arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.04k stars 4.78k forks source link

Avoid connection errors when switching to safeboot to upload OTA firmware #21428

Closed s-hadinger closed 4 months ago

s-hadinger commented 4 months ago

Description:

Fix occasional connection error when flashing ESP32 firmware via file upload.

Explanation: when uploading a new firmware with file upload, the first step is to restart Tasmota and switch to Safeboot partition. The browser polls the Tasmota device until it reboots and confirms that the safeboot is the active partition.

The partition switch is done by calling /u4?u4=fct&api=" which returns false if the partition is the normal one (and forces reboot) and true if it's the safeboot.

As soon as true is received, the browser send a POST request to upload the firmware. The problem is that sometimes the POST is sent too soon. I'm not sure why but the webserver initialization does not seem to be complete.

This patch adds a delay of 1 second between the confirmation of safeboot switch and sending the firmware.

Checklist:

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass