Revert "Change safeboot GUI restart to production partition"

This reverts commit b3f3e29b0c.
This commit is contained in:
Theo Arends 2022-05-15 14:23:50 +02:00
parent b3f3e29b0c
commit ba324b270e
3 changed files with 10 additions and 31 deletions

View File

@ -891,7 +891,7 @@ void CmndRestart(void)
break; break;
#ifdef ESP32 #ifdef ESP32
case 3: case 3:
if (EspPrepSwitchPartition(2)) { // Toggle partition between safeboot and production if (EspPrepSwitchToOtherPartition()) {
TasmotaGlobal.restart_flag = 2; TasmotaGlobal.restart_flag = 2;
ResponseCmndChar(PSTR("Switching")); ResponseCmndChar(PSTR("Switching"));
} }

View File

@ -354,33 +354,15 @@ void EspPrepRestartToSafeBoot(void) {
} }
} }
bool EspPrepSwitchPartition(uint32_t state) { bool EspPrepSwitchToOtherPartition(void) {
bool valid = EspSingleOtaPartition(); bool valid = EspSingleOtaPartition();
if (valid) { if (valid) {
bool running_factory = EspRunningFactoryPartition(); bool running_factory = EspRunningFactoryPartition();
switch (state) { if (!running_factory) {
case 0: // Off = safeboot EspPrepRestartToSafeBoot();
if (!running_factory) { } else {
EspPrepRestartToSafeBoot(); const esp_partition_t* partition = esp_ota_get_next_update_partition(nullptr);
} else { esp_ota_set_boot_partition(partition);
valid = false;
}
break;
case 1: // On = ota0
if (running_factory) {
const esp_partition_t* partition = esp_ota_get_next_update_partition(nullptr);
esp_ota_set_boot_partition(partition);
} else {
valid = false;
}
break;
case 2: // Toggle
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; return valid;

View File

@ -1053,9 +1053,6 @@ void WebRestart(uint32_t type)
if (!(2 == type)) { if (!(2 == type)) {
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTART)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTART));
ShowWebSource(SRC_WEBGUI); ShowWebSource(SRC_WEBGUI);
#ifdef ESP32
if (0 == type) { EspPrepSwitchPartition(1); } // Switch to production partition if on safeboot
#endif // ESP32
TasmotaGlobal.restart_flag = 2; TasmotaGlobal.restart_flag = 2;
} }
} }
@ -2498,14 +2495,14 @@ void HandleInformation(void)
if (ESP_PARTITION_TYPE_APP == part->type) { if (ESP_PARTITION_TYPE_APP == part->type) {
uint32_t prog_size = 0; // No active ota partition uint32_t prog_size = 0; // No active ota partition
if (part->subtype == ESP_PARTITION_SUBTYPE_APP_FACTORY) { if (part->subtype == ESP_PARTITION_SUBTYPE_APP_FACTORY) {
prog_size = EspProgramSize(part->label); // safeboot partition (slow response) prog_size = EspProgramSize(part->label); // safeboot partition
} }
else if ((part->subtype >= ESP_PARTITION_SUBTYPE_APP_OTA_MIN) && (part->subtype <= ESP_PARTITION_SUBTYPE_APP_OTA_MAX)) { else if ((part->subtype >= ESP_PARTITION_SUBTYPE_APP_OTA_MIN) && (part->subtype <= ESP_PARTITION_SUBTYPE_APP_OTA_MAX)) {
if (cur_part == part->subtype) { if (cur_part == part->subtype) {
prog_size = ESP_getSketchSize(); // Active running ota partition (fast response) prog_size = ESP_getSketchSize(); // Active running ota partition
} }
else if (cur_part == ESP_PARTITION_SUBTYPE_APP_FACTORY) { else if (cur_part == ESP_PARTITION_SUBTYPE_APP_FACTORY) {
prog_size = EspProgramSize(part->label); // One app partition when safeboot partitions (slow response) prog_size = EspProgramSize(part->label); // Only app partition when safeboot partitions
} }
} }
char running[2] = { 0 }; char running[2] = { 0 };