Available program storage space is different between PlatformIO and Arduino IDE


I have been working with PlatformIO for ESP8266 coding over a year. Last month, I tried to enable IPv6 supported with the latest espressif8266 platform, the latest version is V2.0.4.
It works fine, but one problem is the flash available space for sketch uploading.
the previous version which does to support IPv6, the available space is about 9xxKB.
now, it is 7XXKB.
And my sketch compiling size is about 385KB. It is over 50% than available space which cause my http OTA function failed.
below is the content of ini file, and terminal info of compiling

platform = espressif8266
board = esp01_1m
framework = arduino
upload_speed = 115200
board_build.f_cpu = 80000000L
build_flags = -Wl,-Teagle.flash.1m.ld
board_build.flash_mode = dio
board_build.f_flash = 40000000L
upload_resetmethod = ck
upload_port = /dev/cu.wchusbserial14240
lib_deps = EspSoftwareSerial@5.0.4

terminal- compiling info
DATA: [==== ] 41.6% (used 34068 bytes from 81920 bytes)
PROGRAM: [===== ] 50.9% (used 388100 bytes from 761840 bytes)

I tried many ways to reduce the sketch size, but performance is not good enough.
last week, I tried to move the exactly same code to Arduino IDE, and compile it.
the system show me available space of storage space is about 1MB, and with the similar compiling sketch size, the percentage is dropped to 37%.
and I tested it, all functions work fine. please see below Arduino setting and info.
the version shows in board manager is V2.5.0

Arduino-terminal compiling info
Sketch uses 387776 bytes (37%) of program storage space. Maximum is 1023984 bytes.
Global variables use 33860 bytes (41%) of dynamic memory, leaving 48060 bytes for local variables. Maximum is 81920 bytes.

I checked the setting between 2 environments, all setting should be the same.
May I know what setting I miss? How do I solve it?

Thanks for advise

You were nearly there.

Don’t have two build_flags statements… I’m guessing the second one overrode the first…

ie. do

build_flags = -Wl,-Teagle.flash.1m.ld -D PIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY

instead of

build_flags = -Wl,-Teagle.flash.1m.ld
 ... other stuff ...


I found the root cause yesterday

I looked into board configuration file, “esp01_1,.json”
and found below
“build”: {
“core”: “esp8266”,
“extra_flags”: “-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP01”,
“f_cpu”: “80000000L”,
“f_flash”: “40000000L”,
“flash_mode”: “qio”,
“ldscript”: “eagle.flash.1m256.ld”,
“mcu”: “esp8266”,
“variant”: “generic”
“connectivity”: [
“frameworks”: [
“name”: “Espressif Generic ESP8266 ESP-01 1M”,
“upload”: {
“maximum_ram_size”: 81920,
“maximum_size”: 1048576,
“require_upload_port”: true,
“resetmethod”: “ck”,
“speed”: 115200
“url”: “esp8266-module-family [ESP8266 Support WIKI]”,
“vendor”: “Espressif”

it looks like the setting in platformio.ini (build_flags = -Wl,-Teagle.flash.1m.ld), can not overwrite it
I modified “ldscript”: “eagle.flash.1m256.ld” to “ldscript”: “eagle.flash.1m.ld”

then problem fixed


Simply merging to TWO build_flags statements in platformio.ini so that the second did not cancel out the first fixed it for me using the platformio.ini you provided. No editing of the board configuration file (making it susceptible to not working in the future with an update) is not necessary.

i.e. changing


Gives the correct maximum size.


Please note that we do real computation of available flash based on the regions in LD script. Arduino IDE does not do that and show the same available flash size even if you switch to another LD script. See source code

Yes, I did experiment yesterday
it does work

Thanks for detail explanation



This feature is great, but updating boards “upload.maximum_size” causes problems if we want use the board size later for a custom download script.
I had to save the value in a pre: script to an environment variable.
Is there a way to get the total flash size once the target is generated? (I did not see a field named “flash_size”).