I have a variable uint8_t a_ram
which needs to be initialized from the EEPROM variable a_eeprom
when the ESP boots up. Whenever a_ram
changes, the new value has to be stored to the EEPROM (a_eeprom
), so that the ESP will initialize a_ram
to this new value after the next reboot.
The problem I have is to understand, how the value of a_eeprom
can be initialized for the very first boot. If a_eeprom
has not been set before (that means, that a_ram
has not been stored to EEPROM yet), my variable will be initialized to 0
, which must not be the case.
I could introduce an extra variable to the EEPROM (kind of a flag), which tells me whether a_ram
has been stored to EEPROM or not and only initialize a_ram
to a_eeprom
if that is the case. But as I don't want to spend this memory if it isn't neccessary, I'd like to know if there is a possibility to set an EEPROM value when flashing the ESP.
Btw, I'm using the arduino IDE.
-
First you should probably research how EEPROM is approximately emulated on a system that doesn't actually have any.Chris Stratton– Chris Stratton2017年11月12日 20:42:07 +00:00Commented Nov 12, 2017 at 20:42
-
it is written to flash.to location after SPIFSJuraj– Juraj ♦2017年11月13日 09:59:18 +00:00Commented Nov 13, 2017 at 9:59
-
@Juraj unfortunately I'm not very familiar with this topic. Could you give me a hint about what I should update myself if I did not understand your comment? ;)Sim Son– Sim Son2017年11月14日 17:34:46 +00:00Commented Nov 14, 2017 at 17:34
-
@ChrisStratton as far as I understand the ESP, it has an EEPROM onboard and does not only emulate itSim Son– Sim Son2017年11月14日 17:36:37 +00:00Commented Nov 14, 2017 at 17:36
-
@SimSon - you are mistaken. The ESP8266 has no on-chip EEPROM, and most boards pair it with an SPI flash, not an EEPROM.Chris Stratton– Chris Stratton2017年11月14日 23:10:54 +00:00Commented Nov 14, 2017 at 23:10