How to optimize code for flash memory esp32 arduino framework

Hi community,
I would like to know how to improve optimization of the flash of my esp32 (currently 90% used…)
Do I have to set something in the platformio.ini file ?

Thanks a lot

The default GCC optimization flag is already -Os (optimize for smallest size). Mabe link-time-optimization (LTO) can additionally do something (and not break the firmware like it sometimes does). See build_flags and -flto.

Otherwise, make sure that if you’re not using OTAA or a (big) filesystem to use an appropriate partition table that makes the best usage of the flash chip size you have on your particular board.

1 Like

Thanks Max… but the flash size should be 4MB right ?
Why it is showing in this way?


How can I change the partition of the memory from platformio ?


Thanks again

I just linked that piece of information above.

board_build.partitions = huge_app.csv