Favor <avr/eeprom.h> over Arduino's <EEPROM.h>
Closed this issue · 1 comments
Arduino's EEPROM.h declares a problematic static variable inside the header file. Even with LTO, each static variable results in a separate instantiation of an empty EEPROMClass
object, resulting in a one byte RAM overhead for every compilation unit that includes EEPROM.h.
Example global data usage from Ardens showing the EEPROM objects:
It could be worth removing inclusions of the EEPROM.h header and replacing each usage of the EEPROM class with eeprom_update_byte
or eeprom_read_byte
, and can open a PR for this if desired.
The big downside to this that I see is that existing sketches that rely on the Arduboy2 headers to include the EEPROM header will need to be updated to include the header themselves.
Closed as I no longer believe this problem is due to Arduboy2. (Discussion here).