0

As I use the EEPROM to persist data such as for provisioning the WiFi (SSID and password), I'd like to make sure that the very first time the ESP32 runs, it finds the initial '\0' for the SSID so that it does not run into the WiFi connection code block.

For this I need to set the initial values into the EEPROM when I flash the firmware.

I use platform IO.

How to do that?

3
  • You're probably better off using SPIFFS and a "eeprom.bin" file. The current partition scheme of the ESP doesn't provide a dedicated partition for the arduino-like eeprom and the ESP32 doesn't have an EEPROM...
    – Sim Son
    Jan 24 at 19:12
  • you can set/wipe SPIFFS with default files when uploading.
    – dandavis
    Jan 24 at 20:28
  • first of all, the esp32 remembers the WiFi credentials by itself. you don't have to store it. example github.com/jandrassy/lab/blob/master/ConfigurationAP/…
    – Juraj
    Mar 4 at 18:42

1 Answer 1

0

The ESP32 does not have a real EEPROM; instead, the data is stored in the external flash in the non-volatile storage (NVS) partition. The problem is, that the structure of this partition is proprietary. Only the SDK knows "where to find what" within NVS and any access to this partition is done using the SDK.

Unfortunately, the EEPROM.h library uses the NVS partition to store its values. As the way how data is stored within NVS is closed source, you can't build a flash image that is guaranteed to work in different sketches or different versions of the SDK. So, if you need to upload pre-made non-volatile data, the EEPROM.h library is practically useless.

A convenient alternative is to put that data in a file and store that file in a filesystem like SPIFFS.h. This way, you define how data is stored/accessed yourself, so it's much less likely you run into problems when the core experiences changes.

Data upload is straight forward using esptool.py.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.