Hi,
This is my 3rd attempt to move from Arduino Studio to Platform.io for my own IoT project and I have made significant progress (I finally have it compiling for all my targets from platformio). However, the resulting binary size for a d1_mini (esp8266) is 437,041 bytes from Arduino Studio but 645,205 bytes from Platformio. That is such an enormous difference that I am unable to deploy it to some of the same hardware and none of them are able to have OTA updates anymore which is a deal-breaker for devices embedded in walls for obvious reasons.
I’m using both espressif32 and espressif8266 platforms with multiple boards each but I’m happy to focus on just a wemos D1 mini and solve that one.
I figure that the difference is going to be with either the core platform being included, or the compiler flags being different, or both. I tried a verbose build out of platformio to try and catch the compiler flags but the terminal window doesn’t have enough scrollback to get them.
I’m not sure if 136kb of “unknown” is normal with this build system.
So really I’m looking for hints and suggestions for how to find the cause of my oversized binaries. I desparately need a more capable build system than Arduino Studio can offer but obviously the requirement that my code fit on the board is more important.
The project is about 3700 lines, so I have opted to not include the code here. I did convert the .ino file to main.cpp.
Here is a chunk of the build log (not verbose) which might be useful
What version of Arduino-ESP8266 does it use? What version of xtensa-lx106-elf-gcc does it use? Have 100% equialized the version of all used libraries? Have you got access to a verbose compilation log from Arduino Studio?
Not sure. I’m using esp8266 v3.0.2 from the boards manager. How do I find my xtensa version?
EDIT: in the Arduino log I see “10.3-1757bed” which matches the toolchain version listed against the Espressif 8266 platform.
As far as I can tell, yes. There are a lot fewer libraries in this than I thought.
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Someone\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Someone\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries D:\Someone\Documents\Arduino\libraries -fqbn=esp8266:esp8266:d1_mini:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,eesz=4M3M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600 -vid-pid=1A86_7523 -ide-version=10813 -build-path C:\Users\Someone\AppData\Local\Temp\arduino_build_730264 -warnings=none -build-cache C:\Users\Someone\AppData\Local\Temp\arduino_cache_431172 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed -prefs=runtime.tools.xtensa-lx106-elf-gcc-3.0.4-gcc10.3-1757bed.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mklittlefs.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\mklittlefs\3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mklittlefs-3.0.4-gcc10.3-1757bed.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\mklittlefs\3.0.4-gcc10.3-1757bed -prefs=runtime.tools.python3.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.mkspiffs.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mkspiffs-3.0.4-gcc10.3-1757bed.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\3.0.4-gcc10.3-1757bed -verbose D:\Someone\Documents\github\core\ESP_IoT_Core\ESP_IoT_Core.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Someone\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Someone\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries D:\Someone\Documents\Arduino\libraries -fqbn=esp8266:esp8266:d1_mini:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,eesz=4M3M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600 -vid-pid=1A86_7523 -ide-version=10813 -build-path C:\Users\Someone\AppData\Local\Temp\arduino_build_730264 -warnings=none -build-cache C:\Users\Someone\AppData\Local\Temp\arduino_cache_431172 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed -prefs=runtime.tools.xtensa-lx106-elf-gcc-3.0.4-gcc10.3-1757bed.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mklittlefs.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\mklittlefs\3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mklittlefs-3.0.4-gcc10.3-1757bed.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\mklittlefs\3.0.4-gcc10.3-1757bed -prefs=runtime.tools.python3.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.mkspiffs.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mkspiffs-3.0.4-gcc10.3-1757bed.path=C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\3.0.4-gcc10.3-1757bed -verbose D:\Someone\Documents\github\core\ESP_IoT_Core\ESP_IoT_Core.ino
Using board 'd1_mini' from platform in folder: C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2
Using core 'esp8266' from platform in folder: C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2
Detecting libraries used...
"C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -D_GNU_SOURCE "-IC:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/sdk/include" "-IC:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/sdk/lwip2/include" "-IC:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\\Users\\Someone\\AppData\\Local\\Temp\\arduino_build_730264/core" -c -w -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10813 -DARDUINO_ESP8266_WEMOS_D1MINI -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINI\"" "-DBOARD_VARIANT=\"d1_mini\"" "-DBOARD_FLASH_SIZE=\"4M\"" -DFLASHMODE_DIO -DESP8266 "-IC:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2\\cores\\esp8266" "-IC:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2\\variants\\d1_mini" "C:\\Users\\Someone\\AppData\\Local\\Temp\\arduino_build_730264\\sketch\\ESP_IoT_Core.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
...
"C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3" -I "C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/elf2bin.py" --eboot "C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/bootloaders/eboot/eboot.elf" --app "C:\\Users\\Someone\\AppData\\Local\\Temp\\arduino_build_730264/ESP_IoT_Core.ino.elf" --flash_mode dio --flash_freq 40 --flash_size 4M --path "C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\3.0.4-gcc10.3-1757bed/bin" --out "C:\\Users\\Someone\\AppData\\Local\\Temp\\arduino_build_730264/ESP_IoT_Core.ino.bin"
Creating BIN file "C:\Users\Someone\AppData\Local\Temp\arduino_build_730264/ESP_IoT_Core.ino.bin" using "C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2/bootloaders/eboot/eboot.elf" and "C:\Users\Someone\AppData\Local\Temp\arduino_build_730264/ESP_IoT_Core.ino.elf"
"C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3" -I "C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/signing.py" --mode sign --privatekey "D:\\Someone\\Documents\\github\\core\\ESP_IoT_Core/private.key" --bin "C:\\Users\\Someone\\AppData\\Local\\Temp\\arduino_build_730264/ESP_IoT_Core.ino.bin" --out "C:\\Users\\Someone\\AppData\\Local\\Temp\\arduino_build_730264/ESP_IoT_Core.ino.bin.signed" --legacy "C:\\Users\\Someone\\AppData\\Local\\Temp\\arduino_build_730264/ESP_IoT_Core.ino.bin.legacy_sig"
"C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3" -I "C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/sizes.py" --elf "C:\\Users\\Someone\\AppData\\Local\\Temp\\arduino_build_730264/ESP_IoT_Core.ino.elf" --path "C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\3.0.4-gcc10.3-1757bed/bin" --mmu "-DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000"
Executable segment sizes:
ICACHE : 32768 - flash instruction cache
IROM : 397196 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 28777 / 32768 - code in IRAM (IRAM_ATTR, ISRs...)
DATA : 1528 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 9540 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 26032 ) - zeroed variables (global, static) in RAM/HEAP
Using library LittleFS at version 0.1.0 in folder: C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\LittleFS
Using library ArduinoJson at version 6.19.4 in folder: D:\Someone\Documents\Arduino\libraries\ArduinoJson
Using library ESPAsyncTCP at version 1.2.2 in folder: D:\Someone\Documents\Arduino\libraries\ESPAsyncTCP
Using library ESPAsyncWebServer at version 1.2.3 in folder: D:\Someone\Documents\Arduino\libraries\ESPAsyncWebServer
Using library ESP8266WiFi at version 1.0 in folder: C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi
Using library Hash at version 1.0 in folder: C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\Hash
Using library QList at version 0.6.7 in folder: D:\Someone\Documents\Arduino\libraries\QList
Using library NeoPixelBus_by_Makuna at version 2.6.9 in folder: D:\Someone\Documents\Arduino\libraries\NeoPixelBus_by_Makuna
Using library SPI at version 1.0 in folder: C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\SPI
Using library ESP8266HTTPClient at version 1.2 in folder: C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266HTTPClient
Using library ESP8266httpUpdate at version 1.3 in folder: C:\Users\Someone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266httpUpdate
"C:\\Users\\Someone\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-size" -A "C:\\Users\\Someone\\AppData\\Local\\Temp\\arduino_build_730264/ESP_IoT_Core.ino.elf"
Sketch uses 437041 bytes (41%) of program storage space. Maximum is 1044464 bytes.
Global variables use 37100 bytes (45%) of dynamic memory, leaving 44820 bytes for local variables. Maximum is 81920 bytes.
Unfortunately the log is too long so i snipped out the middle. Apparently the full log exceeds the limits of a post here and on pastebin.
This is basically my first embedded project so I’m still working things out as I go.
I had a look at the binaries coming out in a hex editor and just at a cursory glance it looks like all the libraries are being build with debug symbols and other non-optimised build flags. is there a way to specify or control the building of libraries loaded in platform.io’s UI?
There’s 95kb of “/include/bits” in my binary. Is this normal? That’s where those random strings are from anyway (locale_facets_nonio.tcc etc) so Arduino Studio doesn’t include all of this, if any.
I had a dependency: "me-no-dev/ESP Async WebServer": "*", which I thought this would give me the head of the repo. But it turns out to have given me some other version (hard to tell which/why) which was after the regex was introduced, but before a conditional inclusion macro was put around it.
So that’s the real reason why PlatformIO was creating giant binaries: by dumb bad luck, it was linking a fat library, while my Arduino IDE build was using a newer, leaner version.
An interesting voyage, but one I could have done without.
You sir, are a gentleman and a scholar.
The problem was indeed the library import for a me-no-dev package. Is there anything I can do to repay you for this nugget of information?