ESPHome Update to 2025.6.0 errors out because binary size

Hi !

Wanted to update my esp home device from 2025.4.0 → 2025.6.0
Unfortunately I get this error during build process:

INFO ESPHome 2025.6.0
INFO Reading configuration /config/esphome/wr-lufter-dallas-sensor.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing wr-lufter-dallas-sensor (board: d1_mini_lite; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
Dependency Graph
|-- ESPAsyncTCP-esphome @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.3.0
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- noise-c @ 0.1.6
|-- ArduinoJson @ 6.18.5
Compiling .pioenvs/wr-lufter-dallas-sensor/src/main.cpp.o
Linking .pioenvs/wr-lufter-dallas-sensor/firmware.elf
RAM:   [=====     ]  46.0% (used 37648 bytes from 81920 bytes)
Flash: [======    ]  60.2% (used 616557 bytes from 1023984 bytes)
Building .pioenvs/wr-lufter-dallas-sensor/firmware.bin
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:54: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:73: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
esp8266_copy_factory_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
esp8266_copy_ota_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
========================= [SUCCESS] Took 12.50 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.178.184 port 8266...
INFO Connected to 192.168.178.184
INFO Uploading /data/build/wr-lufter-dallas-sensor/.pioenvs/wr-lufter-dallas-sensor/firmware.bin (620704 bytes)
INFO Compressed to 423691 bytes
ERROR Error binary size: Error: ESP does not have enough space to store OTA file. Please try flashing a minimal firmware (remove everything except ota)

Of course code is running before with 2025.4.0, what should I do ?

If only the error message ended with some sort of suggestion :no_mouth:

The problem is that the OTA flash process needs twice the space of the image, to store both the existing current and incoming new images together.

Create a cut-down version of the config with just the name and network stuff, flash that, then flash your new version.

2 Likes

I did not see the last piece of text, so the link was only to the \s warnings.

ESP devices have the flash drive partitioned into sections, like one for runtime data, one for firmware image1, one for firmware image2 and so on.
The ESP device is set to boot up in firmware image1 or image2 and when it is OTA updated, then the image that is not booted up will be overridden and the primary boot image will be switched to that.

OTA updates can be tricky with a large image, because one image will need to be running to handle the OTA update process and changing the partition sizes through OTA might also fail.

Best way is to flash directly through USB or serial connectors, where the ESP device is put into flash mode, since no image needs to be running then, or you can simply make you image smaller, like by removing unneeded or less important things.

Ah, neither did I :slight_smile:

The other option using OTA is to flash a minimal image (just what’s needed to make it run with WiFi and OTA) then flash the desired one. I’ve had to do that with some 8266 based smart plugs.

Thank for all the advises.
One thing I‘m wondering about is that the OTA process was successful for more than a year…
So several versions up to 2025.4.0 ??

It is just a matter of time before some bugfix or improvement increase the image size to above the limit for your ESP device.
ESP devices should not be updated unless something needs to be fixed or the update include an improvement that is worth it for the specific setup on that ESP device.

The rule here is truly:
If it ain’t broke, don’t fix it!

Although I really like the ESP8266 and started most of my projects with it, I discovered that it’s relatively limited, especially in terms of memory (only 80 kB total for drivers, programs, and variables).
If memory issues arise, they usually first manifest themselves in problems with flashing and establishing a Wi-Fi connection at me. If there’s not enough memory, the 8266 usually just crashes. As memory becomes increasingly scarce, the frequency of crashes also increases. I’m now considering switching to an ESP32 for one project.

I would first try to save memory. Delete unneeded global variables, delete unneeded lighting effects, delete logs, control fewer LEDs in LED strips, use fewer different components (to save drivers), so don’t connect a Dallas temperature sensor, a BME280, and also a DHT22, shorten text, avoid resource-hungry sensors like the LD2410, and work with strings as little as possible…

(I’ve also heard of various flashing issues when running ESPHome on a computer with insufficient memory, such as a Raspberry Pi with only 1GB of RAM)

You have a few choices:

  1. Do nothing - it will continue working (or not) as it has been
  2. Flash locally - connected directly you can put in a full size program
  3. Double OTA - create a minimalist program that has only Wi-Fi and OTA. Flash that and then flash the real program you want. Tasmota has been in this state for a decade or so, if you want to OTA, it is a two step process.

I disabled the web server and with that OTA worked:

Linking .pioenvs/wr-lufter-dallas-sensor/firmware.elf
RAM:   [====      ]  44.7% (used 36656 bytes from 81920 bytes)
Flash: [======    ]  57.0% (used 583461 bytes from 1023984 bytes)
Building .pioenvs/wr-lufter-dallas-sensor/firmware.bin
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:54: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:73: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
esp8266_copy_factory_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
esp8266_copy_ota_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
========================= [SUCCESS] Took 95.79 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.178.184 port 8266...
INFO Connected to 192.168.178.184
INFO Uploading /data/build/wr-lufter-dallas-sensor/.pioenvs/wr-lufter-dallas-sensor/firmware.bin (587616 bytes)
INFO Compressed to 403155 bytes
Uploading: [============================================================] 100% Done...

INFO Upload took 4.07 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.178.184 using esphome API
INFO Successfully resolved wr-lufter-dallas-sensor @ 192.168.178.184 in 0.000s

After that I enabled the web server again and tried OTA again.
Obviously web server needs:
RAM: 46%-44.7% = 1.3%
Flash: 60.2% - 57% = 2.8%

Compiling .pioenvs/wr-lufter-dallas-sensor/src/main.cpp.o
Linking .pioenvs/wr-lufter-dallas-sensor/firmware.elf
RAM:   [=====     ]  46.0% (used 37648 bytes from 81920 bytes)
Flash: [======    ]  60.2% (used 616557 bytes from 1023984 bytes)
Building .pioenvs/wr-lufter-dallas-sensor/firmware.bin
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:54: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:73: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
esp8266_copy_factory_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
esp8266_copy_ota_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
========================= [SUCCESS] Took 12.17 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.178.184 port 8266...
INFO Connected to 192.168.178.184
INFO Uploading /data/build/wr-lufter-dallas-sensor/.pioenvs/wr-lufter-dallas-sensor/firmware.bin (620704 bytes)
INFO Compressed to 423690 bytes
Uploading: [============================================================] 100% Done...

INFO Upload took 6.06 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.178.184 using esphome API
INFO Successfully resolved wr-lufter-dallas-sensor @ 192.168.178.184 in 0.000s

So the code is now exactly the same like before…
What else beside code size could cause the initial OTA problem ?
Or why did OTA work right now ?

If you have an esp board with 4MB of flash this method also works, but you have to set it up correctly first.

https://arduino.stackexchange.com/questions/77002/esp8266-ota-update-with-different-flash-size-settings

I have no idea why but with update from 2025.6.0 → 2025.6.2 same error occurs again…

INFO ESPHome 2025.6.2
INFO Reading configuration /config/esphome/wr-lufter-dallas-sensor.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing wr-lufter-dallas-sensor (board: d1_mini_lite; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
Dependency Graph
|-- ESPAsyncTCP-esphome @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.3.0
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- noise-c @ 0.1.6
|-- ArduinoJson @ 6.18.5
Compiling .pioenvs/wr-lufter-dallas-sensor/src/main.cpp.o
Linking .pioenvs/wr-lufter-dallas-sensor/firmware.elf
RAM:   [=====     ]  46.0% (used 37648 bytes from 81920 bytes)
Flash: [======    ]  60.2% (used 616557 bytes from 1023984 bytes)
Building .pioenvs/wr-lufter-dallas-sensor/firmware.bin
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:54: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:73: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
esp8266_copy_factory_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
esp8266_copy_ota_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
========================= [SUCCESS] Took 12.04 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.178.184 port 8266...
INFO Connected to 192.168.178.184
INFO Uploading /data/build/wr-lufter-dallas-sensor/.pioenvs/wr-lufter-dallas-sensor/firmware.bin (620704 bytes)
INFO Compressed to 423690 bytes
ERROR Error binary size: Error: ESP does not have enough space to store OTA file. Please try flashing a minimal firmware (remove everything except ota)

Again I commented out the web server and wireless installation did work again.

Linking .pioenvs/wr-lufter-dallas-sensor/firmware.elf
RAM:   [====      ]  44.7% (used 36656 bytes from 81920 bytes)
Flash: [======    ]  57.0% (used 583461 bytes from 1023984 bytes)
Building .pioenvs/wr-lufter-dallas-sensor/firmware.bin
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:54: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:73: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
esp8266_copy_factory_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
esp8266_copy_ota_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
========================= [SUCCESS] Took 96.18 seconds =========================
INFO Successfully compiled program.

After that again I commented in the web server again and was able to install wirelessly the exact same code as before…

Linking .pioenvs/wr-lufter-dallas-sensor/firmware.elf
RAM:   [=====     ]  46.0% (used 37648 bytes from 81920 bytes)
Flash: [======    ]  60.2% (used 616557 bytes from 1023984 bytes)
Building .pioenvs/wr-lufter-dallas-sensor/firmware.bin
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:54: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
/data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py:73: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
esp8266_copy_factory_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
esp8266_copy_ota_bin([".pioenvs/wr-lufter-dallas-sensor/firmware.bin"], [".pioenvs/wr-lufter-dallas-sensor/firmware.elf"])
======================== [SUCCESS] Took 109.30 seconds ========================
INFO Successfully compiled program.

Here’s your problem. When this number goes above 50%, you can’t upload OTA. Only manually.

But OTA works if I change the code back and forth…?!

You are on the line between can and can’t. Is this a DIY project? 1Mb of flash is low, like what the ESP8266 contained three or four years ago. If this is a DIY project, change the ESP module (what module are you using) to one with 4Mb of flash.

Yep

D1 Mini Lite

I had these warnings a few days ago. Not a real fix, but I did connect to the docker container and manually edit the files to fix those warnings.

➜  ~ docker exec  addon_5c53de3b_esphome grep split /data/cache/platformio/packages/framework-arduinoespressif8266/tools/elf2bin.py
            words = re.split(r'\s+', line)
            words = re.split(r'\s+', line)

As for the out of space issue, in my case rebooting (or power cycling, as I did) the device made OTA updates work again. YMMV, as they say.

Well, since you wisely socketed the module, just buy some Wemos D1 Mini modules with 4Mb of flash. They are so cheap I buy them 5 at a time on Ali. Problem solved.

2 Likes

It might could be it is an D1_Mini_Pro…
At least it has an external antenna and as far as I know only the pro has this.

But I have configured this in esp Home:

esp8266:
board: d1_mini_lite
#board: d1_mini_pro

I‘m not sure and I can’t remember why I changed to lite Board…

Is there an option to find out how much flash memory the device has ?

I bought this one:

https://www.makershop.de/plattformen/d1-mini/d1-mini-pro/

So I think it is a pro but with 1Mb why I changed to lite board.

After compile I get this in log window:

RAM:   [=====     ]  46.0% (used 37648 bytes from 81920 bytes)
Flash: [======    ]  60.2% (used 616557 bytes from 1023984 bytes)

So I it should be 1Mb (1023984 bytes = 1.02Mb)…

Or how I can find out how much memory is really available ?