Trouble using custom partition scheme

I am using an Adafruit Huzzah32 with 4MB Flash. Since the firmware has become too large, I would like to adjust the partition table and increase the app0 and app1 areas and shrink the spiffs area a little. To do this, I created a copy of the file tools/WLED_ESP32_4MB_1MB_FS.csv as tools/WLED_HUZZAH32_4MB_1MB_FS.csv and adapted the content as follows:

# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x190000,
app1, app, ota_1, 0x1A0000,0x190000,
spiffs, data, spiffs, 0x330000,0xD0000,

When I compile and install the firmware with “platformio run --target upload”, it crashes as soon as an attempt is made to save /wsec.json to the flash:

---WLED 0.14.0 2310130 INIT---
esp32 v3.3.6-16-gcc5440f6a2
arduino-esp32 v1.0.x

CPU:   ESP32-D0WDQ6 rev.1, 2 core(s), 240MHz.
FLASH: 4MB, Mode 3 (DOUT), speed 40MHz.
heap 295128
PIN ALLOC: Pin 1 successfully allocated by 0x89 (137)
Registering usermods ...
heap 295128
Mount FS
Reading config
Reading settings from /wsec.json...
JSON buffer locked (3)
Read from /wsec.json with key nullptr >>>
JSON buffer released. (3)
JSON buffer locked. (1)
Reading settings from /cfg.json...
Read from /cfg.json with key nullptr >>>
JSON buffer released. (1)
Writing settings to /wsec.json...
JSON buffer locked (4)
Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (loopTask) 
Core 1 register dump:

When switching back to the “tools/WLED_ESP32_4MB_1MB_FS.csv” partition scheme everything works fine.

I already did a “esptool.py erase_flash” to get rid of old data, but this didn’t help.

I would be very happy to hear what I am doing wrong.

kind regards,

Christoph

You miscalculated addresses.

I’m quite sure, i’ll do a face palm, when you tell me, but please: Where?

I really appreciate your help and would like to learn from my mistake, but after reviewing and recalculating the table multiple times, I don’t see it. To make it worse, the firmware crashes now with the standard WLED_ESP32_4MB_1MB_FS.csv table as well…

Each start address has to be the sum of previous start and previous length.

Yes, i’m aware of this and i’ve read Partition Tables - ESP32 - — ESP-IDF Programming Guide latest documentation, but i really don’t see any error in my table. I’ve even copied all values from the table above into the calculator app and they all sum up to the expected values of the following line:
0x9000+0x5000 = 0xe000
0xe000+0x2000 = 0x10000
0x010000+0x190000 = 0x1a0000
0x1a0000+0x190000 = 0x330000
0x330000+0x0d0000 = 0x400000

Then it must be I miscalculated them. Sorry for that. :man_shrugging: