Problem compiling idf + arduino

Hello guys, I migrated a project from arduino into Platformio Core, using arduino as a dependency following the docs from the repository, everything looks to be okay but for some reason, the compilation process tells me I am using more space than available in the flash, I already configured the board with the specs I need, but doesnt look to take actual effect on the flash size.

The purpose of migrating from arduino is the ability to use the PSRAM with malloc(), because arduino complained about the ram being overflown.

So my requirements are 4mgs of RAM and 16mgs of flash, so I used the ODROID json file with this platformio.ini definition:

[env]
platform = espressif32
framework = arduino, espidf
build_flags =
-D CONFIG_BLINK_GPIO=2
monitor_speed = 115200
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#idf-release/v4.0
[env:odroid_esp32]
board = odroid_esp32
lib_extra_dirs = ~/Documents/Arduino/libraries
lib_deps = gypsyrobot/CuteBuzzerSounds@^1.0.0

After compilation I get this message that doesnt look to be using the flash size:

Linking .pio/build/odroid_esp32/firmware.elf
Retrieving maximum program size .pio/build/odroid_esp32/firmware.elf
Building .pio/build/odroid_esp32/firmware.bin
Checking size .pio/build/odroid_esp32/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  37.6% (used 123260 bytes from 327680 bytes)
Flash: [==========]  119.3% (used 1251251 bytes from 1048576Error: The program size (1251251 bytes) is greater than maximum allowed (1048576 bytes)
*** [checkprogsize] Explicit exit, status 1
 bytes)
esptool.py v3.0
============================================================ [FAILED] Took 119.64 seconds ==================================================

The error message states that the program code does not fit into the flash memory. So it’s not related to RAM or PSRAM. Instead it’s about the flash size.

The code (including read-only data and initialization for read-write data) is 1,251,251 bytes large. That’s quite big but possible.

The code size hits a limitation of 1MB, far lower than the 16MB available.

The ESP32 flash memory is divided into partitions. And it looks like the partitions for code is limited to 1MB. Partitions can be chosen more or less freely. Have a look at the related documentation: Partition Tables.

I’m not a specialist on partition tables and combining Arduino and ESP-IDF framework. For Arduino, the default partition table uses a code partition of 1.3MB. Quite obviously, a different partition table is used.

2 Likes

Changing the partition table to enable a bigger usable app-size involves first creating a partiton table csv file per the docs linked above, setting that in the platformio.ini per board_build.partitions = yourfile.csv, then using menuconfig to also set the same partition filename there.

2 Likes

@manuelbl @maxgerhardt you were right!, it did work with this partition table:

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x640000,
app1,     app,  ota_1,   0x650000,0x640000,
spiffs,   data, spiffs,  0xc90000,0x370000,

I would have guessed that the partition table would have been there since the beggining