Non-Volatile storage on ESP32?

I’d like to modify Non-Volatile Storage on an ESP32.

Platformio’s Updating Binary Data documenation seems promising, but the access method is something like

extern const uint8_t aws_root_ca_pem_start[] asm("_binary_src_aws_root_ca_pem_start");

Whereas when I look at the espressif NVS example, I see access methods like

err = nvs_get_i32(my_handle, "restart_counter", &restart_counter);

Am I missing something, or will I need to use espressif’s toolchain instead of Platformio’s for that? Thanks!

You’ve confused two things here: When embedding binary data using the directive

build_flags =
    -DCOMPONENT_EMBED_TXTFILES=src/private.pem

the PIO as well Espressif toolchain will do the exact same thing, that is read the file, inject it into the binary at some point and make it visible as a symbol name by the namescheme _binary_<path>_start and _binary_<path>_end. The binary gets then uploaded to the flash.

This API on the other hand (read this) allocates a section in flash for the creation of a non-volatile data storage system.

These are two ways to store data. The NVS API should also be available in PlatformIO if it’s included in the ESP-IDF version that PIO distributes (see Releases · platformio/platform-espressif32 · GitHub).

1 Like

Yup, you’re completely right! Thanks for that.

For reference to others, here’s the steps I followed:

I used this guide as a reference.

1 Like