PlatformIO Community

Compiling Size compared to Arduino

Community, I need help for an issue you encountered while compiling on PlatformIO: the size of the final compiled file is beyond the FLASH memory size limit.

PlatformIO vs Arduino IDE output comparison
For an empty project:
PlatformIO:
RAM: [] 4.5% (used 14700 bytes from 327680 bytes)
Flash: [==] 16.0% (used 209799 bytes from 1310720 bytes)

Arduino IDE:
Sketch uses 205144 bytes (15%) of program storage space. Maximum is 1310720 bytes.
Global variables use 14492 bytes (4%) of dynamic memory, leaving 313188 bytes for local variables. Maximum is 327680 bytes.

For the same source code:
PlatformIO:
RAM: [==] 15.4% (used 50336 bytes from 327680 bytes)
*** [checkprogsize] Explicit exit, status 1
Flash: [==========] 101.5% (used 1330601 bytes from 1310720 bytes)

Arduino IDE:
Sketch uses 1125082 bytes (85%) of program storage space. Maximum is 1310720 bytes.
Global variables use 45108 bytes (13%) of dynamic memory, leaving 282572 bytes for local variables. Maximum is 327680 bytes.

After updating to latest AtmelAVR updates, my program has increased over 100%. Now I cannot upload the code to my ESP32 DEV MODULE. Someone please help! I have read several forums but all without solution to the problem.

The problem could lie in multiple things.

  • using a different Arduino core version than in the Arduino IDE
  • using different external library versions
  • using a different compiler version
  • wrong platformio / framework configuration which doesn’t match Arduino IDE

In order for us to help you we would need the following information:

  • ESP32 board platform version inside Arduino IDE
  • list of external libraries used in the Arduino IDE and their versions (library manager)
  • platformio.ini and code for reproduction
1 Like

Here I send the configuration of my Arduino IDE, and my platform.ini. I use no external library, I only include the header
#include <WiFi.h> and call the WiFi.begin () function and the percentage of memory consumption increases by 40%.

PlatformIO output:

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 1.12.3 > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, 
olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.200129 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0) 
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 39 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <WiFi> 1.0
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Compiling .pio\build\esp32dev\lib8d1\WiFi\WiFiScan.cpp.o
Compiling .pio\build\esp32dev\lib8d1\WiFi\WiFiServer.cpp.o
Compiling .pio\build\esp32dev\lib8d1\WiFi\WiFiUdp.cpp.o
Archiving .pio\build\esp32dev\lib8d1\libWiFi.a
Linking .pio\build\esp32dev\firmware.elf
Building .pio\build\esp32dev\firmware.bin
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  11.6% (used 37960 bytes from 327680 bytes)
Flash: [=====     ]  47.1% (used 617138 bytes from 1310720 bytes)
esptool.py v2.6
========================================================= [SUCCESS] Took 9.46 seconds =========================================================

Arduino IDE output:

Sketch uses 613514 bytes (46%) of program storage space. Maximum is 1310720 bytes.
Global variables use 37908 bytes (11%) of dynamic memory, leaving 289772 bytes for local variables. Maximum is 327680 bytes.

arduino

platform.ini

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino