Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The EEPROM-methods can not work this way on an ESP32 #4

Open
dl9sec opened this issue Jun 20, 2019 · 0 comments
Open

The EEPROM-methods can not work this way on an ESP32 #4

dl9sec opened this issue Jun 20, 2019 · 0 comments

Comments

@dl9sec
Copy link

dl9sec commented Jun 20, 2019

It seems, that the EEPROM-methods are used the same way as on an AVR based Arduino.
This will not work in this way. I came upon that problem when using an AVR based sketch on an ESP32. The EEPROM class exists for compatibility purpose (exactly this usecase), but need a little extra effort to work propperly.
The compiler will not throw a warning or so, all seems to be all right, but it will not.

An EEPROM size must be defined:

#define EEPROM_SIZE 128           // Emulate 128 bytes of EEPROM

As far as i see this can be not more than one sector of an ESP32 FLASH which means 4kB.

The EEPROM must be initialized:

if (!EEPROM.begin(EEPROM_SIZE))
  {
    Serial.println(F("Failed to initialise EEPROM!"));
  }

The EEPROM content must be "commited" to be persistent after using EEPROM.write() (whenever it is useful and not to exceed the maximum FLASH write cycles):

EEPROM.commit();

As far as i see, RAM memory is allocated as an EEPROM emulation. At initialization the FLASH area is read into that emulation memory. EEPROM manipulation is done within that RAM emulation memory. So if you don't commit, the EEPROM content isn't stored persistent.

Be aware, that EEPROM.length() will not work propperly with the standard initialization!

So i suppose, that the EEPROM content is lost after a suppy interruption with the current sketch...

Regards, Thorsten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant