user14665305
user14665305

Reputation: 245

How to enlarge the nvs partition in ESP32-WROOM32 4MB

I need to enlarge my nvs partition to store more data. Below is my ideal partition constellation:

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x8000,
otadata,  data, ota,     0x11000,  0x2000,
app0,     app,  ota_0,   0x13000, 0x1E0000,
app1,     app,  ota_1,   0x1F3000,0x1E0000,
spiffs,   data, spiffs,  0x3D3000,0x2D000,

However, when building, I am getting the following error:

Partition app0 invalid: Offset 0x13000 is not aligned to 0x10000
*** [.pio/build/esp32dev/partitions.bin] Error 2

Now my questions: Does app0 always have to start from 0x10000? How can I apply the above partition table?

Using VScode, Platform IO and framework-arduinoespressif32. I do need OTA and my app portions must be at least 0x1E0000 large.

Upvotes: 0

Views: 1070

Answers (3)

Teodor Nikolov
Teodor Nikolov

Reputation: 11

Posting this here, as it might help others like me:

Turns out that arduino-esp32 has hardcoded address for the first app to be at address 0x10000 and the simplest workaround for that is to move the NVS partition at any point after that.

Found this solution at the esp32 forum: https://esp32.com/viewtopic.php?t=20966#p77053

Upvotes: 1

SteveRC
SteveRC

Reputation: 11

I found messing with Arduino's default NVS partition causes untold issues, and I wanted a really big NVS partition for good wear-levelling with rapidly changing numbers... Since I wasn't using spiffs, my solution was to change spiffs to nvs2 as follows..

# Name,   Type, SubType, Offset,  Size,    Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x330000,
app1,     app,  ota_1,   0x340000,0x330000,
nvs2,     data, nvs,     0x670000,0x180000,

Now that u have 2 nvs partitions, u can store slowly changing prefs in the small default nvs and rapidly changing ones (like a scope-trace or counters) in the huge nvs2 for best wear-levelling! You can, of course, also split the large upper-area between nvs2 and spiffs if u need to!

Upvotes: 1

Gotfredsen
Gotfredsen

Reputation: 66

See: Espressif's API guide on partition tables:

Partitions of type app have to be placed at offsets aligned to 0x10000 (64 K). If you leave the offset field blank, gen_esp32part.py will automatically align the partition. If you specify an unaligned offset for an app partition, the tool will return an error.

I would try:

  • have ota_0 start at 0x20000 and see if you can live with the remaining space, or;
  • change your code from needing nvs to use spiffs, or;
  • drop using OTA, or;
  • see if you can change the CONFIG_PARTITION_TABLE_OFFSET from 0x8000 to earlier. This is where the partition table is stored, and the reason why the table starts at 0x9000. But here is a guy who had a problem with that in PIO...

Upvotes: 1

Related Questions