ESP does not have enough space to store OTA file

I’ve spend some time debugging an issue with an AM2302 temperature and humidity sensor connected to an ESP01.
Without having done anything to my code I suddenly started getting this error message when trying to download code:

Memory Usage -> http://bit.ly/pio-memory-usage
DATA: [==== ] 39.6% (used 32424 bytes from 81920 bytes)
PROGRAM: [======= ] 65.3% (used 326480 bytes from 499696 bytes)
========================= [SUCCESS] Took 9.83 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of raindance_esp1_temp3.local
INFO -> 10.0.1.127
INFO Uploading /data/raindance_esp1_temp3/.pioenvs/raindance_esp1_temp3/firmware.bin (330624 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)

Here is the code:

esphome:
  name: raindance_esp1_temp2
  platform: ESP8266
  board: esp01

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

sensor:
  - platform: dht
    pin: GPIO2
    model: AUTO_DETECT
    update_interval: 10s
    temperature:
      name: "Temperature"
      filters:
        - sliding_window_moving_average:
            window_size: 15
            send_every: 15
            send_first_at: 15
    humidity:
      name: "Humidity"
      filters:
        - sliding_window_moving_average:
            window_size: 15
            send_every: 15
            send_first_at: 15

Nothing fancy and nothing advanced and keep in mind that the code used to download.
I tried a couple of things.

  1. I did remove everything below the ota: line - still I get error message
  2. I tried another ESP01 and do get the same error message.
  3. I tried to download the code over a serial port but the download appear to hang after compilation but before download starts. (I use the serial port to initialize the ESP01 the first time and that works OK)
  4. I rebooted my Raspberry Pi where I run HassIO but I doesn’t change anything.

I am running 0.97

Any suggestions?

Thanks,

So I thought I wanted to give an update in case anyone else should run into similar issues.

As mentioned in my post I did try several things including rebooting HassIO. I did phrase this as rebooting my Raspberry Pi but perhaps this is technically not true - I don’t know exactly what Restarting HassIo does so…
Eventually I power cycled my Raspberry Pi and while it didn’t solve the issue it did appear to address item 3 in my list of things that I had tried meaning I now were able to download the code via USB without experiencing any problems.
And after successfully having downloaded the code over USB I could subsequently download the same code OTA.

2 Likes

I wonder if there was an incompatibility related to OTA between the version that was on the device and the version you’re trying to flash.

Just figured this one out. So the ESP-01 comes in two flavors. 512k of flash and 1M of flash. You have selected the 512k version with

board: esp01

If this is correct, you’re out of luck for flashing OTA. If, like me, you actually have the 1M version change your board to:

board: esp01_1m

Reflash over usb and then OTA should work

3 Likes

This also solves my problem ([SOLVED] ERROR Uploading YAML via OTA: [Errno 104])

Today I figured that I have the 512K version of the ESP-01 (blue one) :man_facepalming:

esp8266-version-1s

2 Likes
Checking size /data/plugstripgosund6_pcall/.pioenvs/plugstripgosund6_pcall/firmware.elf
RAM:   [=====     ]  48.1% (used 39408 bytes from 81920 bytes)
Flash: [====      ]  42.7% (used 436740 bytes from 1023984 bytes)
Creating BIN file "/data/plugstripgosund6_pcall/.pioenvs/plugstripgosund6_pcall/firmware.bin" using "/root/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" and "/data/plugstripgosund6_pcall/.pioenvs/plugstripgosund6_pcall/firmware.elf"
======================== [SUCCESS] Took 122.55 seconds ========================
INFO Successfully compiled program.
INFO Resolving IP address of plugstripgosund6_pcall.local
INFO  -> 
INFO Uploading /data/plugstripgosund6_pcall/.pioenvs/plugstripgosund6_pcall/firmware.bin (440896 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)

What about math here? 436’740 +440’896 < 1’023’894

Is that an esp01?

Hi Guys, I had same issue. With black esp01 with 1MB
@belowe was right.
You need to change board to esp01_1m, generate BIN file or reflash ESP thru USB.
Because your old FW allocate memory like 512K.
After reflashing with 1MB version OTA starts working (after first reset).

1 Like

For OTA uploads, the size of the compiled (old sketch + new sketch) should not exceed the flash size.

Due to this, large sketches (more than 500KB with 1MB flash) cannot be OTA uploaded directly if the sketch size exceeds half of the flash size.

However, this restriction can be circumvented by first uploading a sketch only with OTA features as given below:


#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

char ssid[] = “xxxxxxxx”; //WiFI user id
char pass[] = “yyyyyy”; //WiFi password

#define OTA_Host_Name “ESP01S-EMPTY-OTA”

void setup() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, pass);

while (WiFi.waitForConnectResult() != WL_CONNECTED) {
delay(5000);
ESP.restart();
}

ArduinoOTA.setHostname(OTA_Host_Name);
ArduinoOTA.begin();
}

void loop() {
ArduinoOTA.handle();
}


This script will compile to around 300KB. Once this script is uploaded in flash, a script with upto 700KB can be uploaded through OTA to a 1MB flash!

Upload this script first. Then restart the controller and choose “ESP01S-EMPTY-OTA” as the port and upload the new updated script that you wish to upload!

IMPORTANT: Firewall must be turned OFF during OTA uploads.

I read somewhere there is some wrong flag sometimes marked on the device and without uploading by wires, it is not possible to upload OTA anymore.

But I’d love to try that script. I tried via ESPHome but most probably it is not the right path?

Thank you for this solution. I’ve got both 512k and 1M ESP01’s, and for some odd reason only the 512k size will work on a breadboard with the ESPHome firmware. The 1M ones will not, even though the program and wiring is the same. So this is a good way around not being able to do the OTA when updating the 512k modules. FYI - The 1M modules will work when in the programmer, just not on the breadboard.

I ran into the same issue.
The problem is that I cannot reprogram the eps8266-01 using USB anymore for some reason. (Tried many options and configs)
I can connect to the device using epshome, but when I reprogram it using OTA I get this error

INFO Successfully compiled program.
INFO Resolving IP address of temperatuur-regeling.local
INFO  -> 192.168.0.74
INFO Uploading /data/temperatuur-regeling/.pioenvs/temperatuur-regeling/firmware.bin (333280 bytes)
INFO Compressed to 239139 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)

My esp YAML is like this:

esphome:
  name: temperatuur-regeling

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
#api:
#  encryption:
#    key: "kgkghhjgjhgjghj="

ota:
  password: "gkgkgkgkgkgjkkg"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
#  ap:
#    ssid: "Temperatuur-Regeling"
#    password: "kjhkjkhkkg"

#captive_portal:
# Stuff to control this relay:

All the help is welcome.

Well, your config is literally minimal. if that cannot fit then something is really wrong.

That said, each time I run into this issue that I cannot upload firmware over OTA, I use ESPHome Flasher to do it via serial port. It nails it every time as it first erases memory, and clears space, and then writes new firmware.

If that does not work for you either, then maybe that boards is done.