Read/Write bootloader, partition table and any partition via OTA - #5535
Read/Write bootloader, partition table and any partition via OTA#5535angelnu wants to merge 34 commits into
Conversation
|
Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration ( |
|
Perfect, thanks! After the above, I ran Hoping this can be merged soon... |
|
Thanks to this PR, I manged to migrate the last of my Tasmota 14.6 devices (an ESP32 Sonoff M5-3C) to ESPHome. |
|
The commands from #5535 (comment) were super helpful to start to figure things out for me, but I found I could simplify the python venv parts quite a bit: |
|
@angelnu thanks for the PR and @lotharbach thanks for the summary of instructions. I installed in around 5 tasmotas v15. The only issue i had was the update through tasmota webpage was getting reset in the middle - perhaps something related to v15. I was able to continue by hosting the firmware in a local webserver. |
|
@angelnu - Would it be possible to do a merge and resolve conflicts? It would be wonderful to see this make some progress towards actually being merged, as instructing to use a (possibly outdated) external PR component isn't a very smooth process. |
|
With the 2025.7.0 release lots of devices can no longer be upgraded without conversion to esp-idf. If @angelnu can't resolve conflicts, can someone else pick this up? |
You can switch to esp-idf OTA. There's no problem. It won't change the partition table, but that's fine. |
|
Did you test this? I tested this (last year) and in Home Assistant it looks like it's successful but the device reloads into the old version simply, because partitions haven't been modified. |
|
We have consolidated all the ota code into a single place in 2025.7 so it should be a bit easier to do now if someone wants to pick this up |
|
I support it, it would be very convenient if this part was completed and included in ESPHome. |
I tried switching from Arduino to IDF, 5 attempts, the firmware uploads without problems, but then it rolls back to 2025.6.3. I think this PR would solve this problem. |
|
Same here - this feature would be super useful for a LOT of people! |
|
Yes, +1 for this feature. Some devices are pain in the a⦠to use serial Flash. I used it to Switch to ESPIDF for some of my devices. maybe this could be a start get even a bigger thing going Like Tasmota did start with V12 in 2022: https://tasmota.github.io/docs/Safeboot/#introducing-safeboot That way even bigger ESPHome projects are possible⦠|
In which version of ESPHome did this work? |
|
tested with Sonoff MiniR4 Extreme with Tasmota v15 and Sonoff Dual R3 with Tasmota v14.2; Both worked great! Thanks for it β€οΈ |
What version of ESP Home? |
The version from this branch⦠then you can upgrade to the latest ESPHome version; just create your YAML with wifi.use_address configured with the IP of your Tasmota to EspHome converted device. |
What version of ESPHome is in this branch? This branch does not work on 2025.7. |
I already have ESPHome flashed in Nous A8T, now I need to update the partition layout in it. |
|
I've tested the simplified steps by @lotharbach on a Shelly Plug Plus S that's running Tasmota 15.1. Unfortunately a only get to SafeBoot everytime I try to flash the firmware.bin through the Tasmota UI. I guess I need to throw in the towel an open the damn device, but since Shelly Plugs now are worse than fort knox I'd like to make sure I've ruled out all posibilities to OTA. Anyone have any suggestion? |
damn, that doesn't sound good. I just bought 8 of these "Shelly Plug Plus S", then went ahead and flashed Tasmota and even used the auto config resize partition because i haven't read all the comments before. I am able to view the logs via ESPHOME: Not sure how can I recover from this. |
Just a quick update on this one: I was able to compile a esphome:
name: shelly
platformio_options:
board_build.partitions: "/custom_partitions.csv"
board_build.flash_mode: dio
esp32:
board: esp32doit-devkit-v1
framework:
type: esp-idf
platform_version: 6.4.0
version: 5.1.1
wifi:
manual_ip:
static_ip: 10.10.50.169
gateway: 10.10.50.1
subnet: 255.255.0.0
dns1: 10.10.50.1
networks:
- ssid: "xxx"
password: "xxx"
ota:
password: "xxx"
unprotected_writes: True # This is mandatory if you want to flash the partition table or bootloader!
logger:
#hardware_uart: USB_SERIAL_JTAG
hardware_uart: UART0
web_server:
button:
- platform: restart
name: Restartthen I tried to flash it, but no luck, not sure which version I need to upgrade to for the OTA v2 support: |
Hi, I have the same issue with my NsPanel. |
The NSPanel is quite easy to take from the wall and flash via serial/USB |
Unfortunately serial pads are broken on mine =( |
|
Thank you @angelnu for this excellent work! This PR tackles a genuinely difficult problem - enabling bootloader and partition table updates over OTA is incredibly valuable for migrating devices from other firmwares and repairing locked bootloaders without serial access. The community response here speaks volumes - the number of users who have successfully migrated Sonoff and Shelly devices using your branch demonstrates that the core approach is solid. Unfortunately, we need to close this PR for a few reasons:
We're closing this to clear the path for someone else to pick up where you left off. The work here provides an excellent foundation and reference for anyone who wants to tackle this feature in the future - the implementation approach, the edge cases discovered, and the real-world testing feedback from the community are all invaluable. If anyone is interested in continuing this effort, this PR is a great starting point to understand the scope and challenges involved. Thanks again for the contribution! |
What does this implement/fix?
This adds support to update the bootloader and partition tables with OTA. It allows migrating from
firmwares with different layouts (new Tasmota versions) or repair botloaders (such as the locked new Shellies).
Updating the bootloader and partition tables only works with the esp-idf framework. For arduino arduino-esp32 is needed. This is currently in alpha so no platformio package is available. It is possible to move from esp-idf to arduino OTA so you can migrate Tasmota -> esphome(esp-idf) -> esphome(arduino).
New CLI commands
The
upload-factory-otacommand makes a backup of the partition table before flashing the new one. If any operation fails then the backup is automatically restored. This usually happens when the new firmware would override the running partition.Tasmota migration
If you are migrating from Tasmota 1.12 or newer using the Safeboot partition you need the following steps. There are 2 options depending on the used esp-idf framework.
Single command (requires esp-idf>5.1)
This is how to do it without custom partition_tables.
test.yaml) with a minimal configuration (with wifi and OTA) with esp-idf>5.1python -m esphome -v upload-factory-ota test.yaml. ESPHome should reboot and use ESPHome partition table and boot loader.Afterwards you might downgrade to the recommend esp-idf framework.
Using multiple commands
If you are using the recommend esp-idf framework you will need to use a custom partition table:
test.yaml) with a minimal configuration (with wifi and OTA) and the following partition table (this uses the Tasmota OTA data partition and app1 address/size):python -m esphome -v upload test.yaml --partition-table. ESPHome should reboot and still run from address 0x0e0000 as in Tasmotapython -m esphome -v upload test.yaml). ESPHome should boot and it will be running out of the 0x010000 address as in regular ESPHome. At this point OTA works but in order to use all available flash we need the following steps.test.yaml) without the custom partition table from step 1python -m esphome -v upload test.yaml --partition-tableTypes of changes
Related issue or feature (if applicable): NA
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Test Environment
Example entry for
config.yaml:Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed: