diff --git a/CHANGELOG.md b/CHANGELOG.md index 73bd2c9d4..fef384784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. ## [11.1.0.2] ### Added - +- ESP32 Command ``Restart 3`` to switch between SafeBoot and Production ### Changed - ESP32 Tasmota SafeBoot with changed partition scheme allowing larger binaries diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 0176bf68f..e3fd22fb0 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -114,6 +114,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - Support for daisy chaining MAX7219 displays [#15345](https://github.com/arendst/Tasmota/issues/15345) - Sonoff SPM delayed SetPowerOnState [#13447](https://github.com/arendst/Tasmota/issues/13447) - Support for flowrate meters like YF-DN50 and similary [#15474](https://github.com/arendst/Tasmota/issues/15474) +- ESP32 Command ``Restart 3`` to switch between SafeBoot and Production ### Breaking Changed diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 33c055caf..6d0da8ced 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -875,6 +875,14 @@ void CmndRestart(void) TasmotaGlobal.restart_halt = true; ResponseCmndChar(PSTR(D_JSON_HALTING)); break; +#ifdef ESP32 + case 3: + if (EspPrepSwitchToOtherPartition()) { + TasmotaGlobal.restart_flag = 2; + ResponseCmndChar(PSTR("Switching")); + } + break; +#endif // ESP32 case -1: CmndCrash(); // force a crash break; diff --git a/tasmota/support_esp.ino b/tasmota/support_esp.ino index c3835ecdc..5e960166d 100644 --- a/tasmota/support_esp.ino +++ b/tasmota/support_esp.ino @@ -312,6 +312,20 @@ void EspPrepRestartToSafeBoot(void) { } } +bool EspPrepSwitchToOtherPartition(void) { + bool valid = EspSingleOtaPartition(); + if (valid) { + bool running_factory = EspRunningFactoryPartition(); + if (!running_factory) { + EspPrepRestartToSafeBoot(); + } else { + const esp_partition_t* partition = esp_ota_get_next_update_partition(nullptr); + esp_ota_set_boot_partition(partition); + } + } + return valid; +} + uint32_t EspFlashBaseAddress(void) { if (EspSingleOtaPartition()) { // Only one partition so start at end of sketch const esp_partition_t *running = esp_ota_get_running_partition();