1

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.

6
  • First you should probably research how EEPROM is approximately emulated on a system that doesn't actually have any. Commented Nov 12, 2017 at 20:42
  • it is written to flash.to location after SPIFS
    – Juraj
    Commented 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
    Commented Nov 14, 2017 at 17:34
  • @ChrisStratton as far as I understand the ESP, it has an EEPROM onboard and does not only emulate it
    – Sim Son
    Commented 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. Commented Nov 14, 2017 at 23:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.