How to use the full size of the partition with PlatformIO with M5Core2?

Hi everyone,
I bought a M5Core2 with Flash 16MB and PSRAM 8MB, but with PlatformIO, I’m not able to use the whole space.
I created a partition csv file (see below), but it seems not really working well

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app,      app,  ota_0,   0x10000, 0xff0000,

I always receive this kind of errors:

.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/m5stack-core2/firmware.elf section `.flash.rodata' will not fit in region `drom0_0_seg'
.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: region `drom0_0_seg' overflowed by 247536 bytes

I really don’t know what to do with that.
Without my little change, platformio returns:

RAM:   [          ]   1.8% (used 119212 bytes from 6553600 bytes)
Flash: [==        ]  20.9% (used 3485493 bytes from 16711680 bytes)

So I should have available spaces ^^’

Any idea?

Everything is reproducible here: https://github.com/PierreRambaud/pokegotchi/tree/try/partitions

The drom0_0_seg is limited to 4MByte minus 24 bytes by the linker script.

The ESP32 has a harvard-architecture core, meaning instructions (code) and data are in seperate memory addresses. The d in drom is the data read only memory, whereas irom would be instruction code (i.e., function code). So, in this drom0_0_seg, constant data created by e.g. const data arrays is saved.

I’m not sure why the linker script limits this to 4Mbyte, maybe the ESP32 has an architectural limitation here in regards to its memory map / flash controller / mapper. Best to ask the Espressif people if you want to find out.

In any case, I don’t think this limitation applies when you do a paradigm shift from compiling all your assets (which is what jacks up the .flash.rodata section beyond its allowed limit) to storing the files in the SPIFFS filesystem. For that, just delete all your asset .c files and move the original files into the data/ folder of the project and upload that to the ESP32 as documented. The code accessing the original arrays will then have to be modified to load the file from SPIFFS into RAM temporarily and work with that.

Thanks a lot for your explanation, I’ll try to use the data partition, I thought it would be simple to use only assets in C files, but it’s not a problem. It’s really cool to learn new things everyday :slight_smile: