Error flashing EspHome after migration from Tasmota on ESP32 (Sonoff DUALR3)

Hello guys,

I’m experiencing a problem trying to flash images on DUALR3 Sonoff Smart Relays, based on ESP32 chip.

While flashing directly there’s no issues, but when trying to migrate:

  • If I select “Modern Format” Tasmota fail saying “Invalid file signature”
  • If I select “Legacy Format” Tasmota flash succed and ESPhome device works as expected, until I try to do an OTA upgrade.

The file is simple and works on other DUALR3

This is the error I got when trying to OTA upgrade:

Processing rele-scrivania (board: esp32dev; framework: arduino; platform: platformio/espressif32 @ 5.2.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- WiFi @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- Update @ 2.0.0
|-- noise-c @ 0.1.4
|   |-- libsodium @ 1.10018.1
Compiling /data/rele-scrivania/.pioenvs/rele-scrivania/src/main.cpp.o
Linking /data/rele-scrivania/.pioenvs/rele-scrivania/firmware.elf
RAM:   [=         ]  12.2% (used 40120 bytes from 327680 bytes)
Flash: [=====     ]  47.9% (used 879205 bytes from 1835008 bytes)
Building /data/rele-scrivania/.pioenvs/rele-scrivania/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin(["/data/rele-scrivania/.pioenvs/rele-scrivania/firmware.bin"], ["/data/rele-scrivania/.pioenvs/rele-scrivania/firmware.elf"])
Wrote 0xe80f0 bytes to file /data/rele-scrivania/.pioenvs/rele-scrivania/firmware-factory.bin, ready to flash to offset 0x0
========================= [SUCCESS] Took 8.80 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 10.10.12.82
INFO Uploading /data/rele-scrivania/.pioenvs/rele-scrivania/firmware.bin (884976 bytes)
Uploading: [=                                                           ] 1% 
ERROR Error sending data: [Errno 104] Connection reset by peer

I searched on www but found nothing

Keep trying, and possibly bring the device closer to your ap so the wifi strength is bettet.

Thank you, already tried several times, device are under the AP, both with 50 dB or less, it shouldn’t be a problem.
Also tried power cycling some times with no results

EDIT: Tried with minimal firmware (only wifi, api, ota): same problem.

This is definitely a problem.

Flashed the same image via USB TTL adapter and is now working flawlessly.

Tried to upgrade a MINIR2 (ESP8266 based) and got Tasmota saying “Not enough space” even if program and flash size are correct. I think there is something with the latest version of Tasmota (12.3.1) as I had no problems migrating from the previous ones

Edit: *solved on the ESP8266 uploading a compressed .bin.gz source

I had to solder and flash with usb adapter ALL the Tasmota ESP32 devices I had, to migrate to ESPhome.

In the other hand, I only need to flash tasmota minimal and then ESPhome on ESP8266 devices.

This might sound strange, but if you can load the latest minimal tasmota image, you should be able to flash it over the air. That’s what I had to do with my Sonoff Basic R2 that already had tasmota on it.

That’s also what i did on MINIR2 and all other ESP8266 based devices, on ESP32 boards, but on DUALR3 it didn’t work.

Same problem, pretty annoying with these boards. There seems to be no minimal for my board (ESP32-S2)

I have the exact same issue on two devices, a Shelly Plus i4 and a Sonoff TX Ultimate.

And if I retry the flash process, the second time it will look like the OTA update completed successfully, with upload progress bar and all, but the firmware will not change.

The way I put ESPHome on the devices is: I installed Tasmota on them via Shelly OTA update or Tasmota Web Flasher respectively, then I downloaded the ESPHome binary in “legacy” format and flashed it using Tasmota’s update form. Was that the correct procedure?

There’s a different storage partition starting with tasmota v12 not compatible with esphome
If you have safe boot partition, then you need to serial flash it

There was a message during the update “Switching to Safeboot” and after the update before the reboot there was a red text “SAFEBOOT” above the menu. So I think I have it, whatever it is. :smiley:

Does that mean there is no way to go from Tasmota to ESPHome using OTA? Or do I simply need to do something different?

Does that explain why my OTA updates have no effect?

Yes, unfortunately
If you still need to use tasmota, you’ll need to flash tasmota v11, and you can still ota to v12 and back to esphome.

Same problem here.
“Modern format” produces the “Invalid file signature” error.
“Legacy format” works after a couple of tries but later updates via ESPHome produce the following:

INFO Successfully compiled program.
INFO Resolving IP address of esp-j1.local
INFO  -> 192.168.2.184
INFO Uploading /data/build/esp-j1/.pioenvs/esp-j1/firmware.bin (860976 bytes)
Uploading: [                                                            ] 0% 
ERROR Error sending data: [Errno 104] Connection reset by peer

Monitoring log output in a separate web page I can observe the following:

INFO Reading configuration /config/esphome/esp-j1.yaml...
INFO Starting log output from esp-j1.local using esphome API
INFO Successfully connected to esp-j1.local
[21:25:22][I][app:102]: ESPHome version 2023.10.6 compiled on Nov  5 2023, 21:04:36
[21:25:22][C][wifi:546]: WiFi:
[21:25:22][C][wifi:382]:   Local MAC: 84:F7:03:EC:B7:68
[21:25:22][C][wifi:383]:   SSID: [redacted]
[21:25:22][C][wifi:384]:   IP Address: 192.168.2.184
[21:25:22][C][wifi:386]:   BSSID: [redacted]
[21:25:22][C][wifi:387]:   Hostname: 'esp-j1'
[21:25:22][C][wifi:389]:   Signal strength: -7 dB ▂▄▆█
[21:25:22][C][wifi:393]:   Channel: 1
[21:25:22][C][wifi:394]:   Subnet: 255.255.255.0
[21:25:22][C][wifi:395]:   Gateway: 192.168.2.3
[21:25:22][C][wifi:396]:   DNS1: 192.168.2.3
[21:25:22][C][wifi:397]:   DNS2: 192.168.2.2
[21:25:22][C][logger:416]: Logger:
[21:25:22][C][logger:417]:   Level: DEBUG
[21:25:22][C][logger:418]:   Log Baud Rate: 115200
[21:25:22][C][logger:420]:   Hardware UART: UART0
[21:25:22][C][captive_portal:088]: Captive Portal:
[21:25:22][C][mdns:115]: mDNS:
[21:25:22][C][mdns:116]:   Hostname: esp-j1
[21:25:22][C][ota:097]: Over-The-Air Updates:
[21:25:31][I][ota:117]: Boot seems successful, resetting boot loop counter.
[21:25:32][D][esp32.preferences:114]: Saving 1 preferences to flash...
[21:25:32][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[21:27:09][D][ota:151]: Starting OTA Update from 192.168.2.217...
[21:27:17][D][ota:320]: OTA in progress: 0.1%
WARNING esp-j1.local: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for esp-j1.local
WARNING Disconnected from API
INFO Successfully connected to esp-j1.local
[21:32:27][I][ota:117]: Boot seems successful, resetting boot loop counter.
[21:32:27][D][esp32.preferences:114]: Saving 1 preferences to flash...
[21:32:27][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed

The following link indicates this should work and to use the “Modern format” but it does not work.
https://next.esphome.io/guides/migrate_sonoff_tasmota

I am unable to initialize the WEMO-S2 using web.esphome.io as well.

Seems “board: lolin_s2_mini” is broken in several places.

If someone knows what to try I can give it a go.