mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Change safeboot GUI restart to production partition
This commit is contained in:
parent
ba324b270e
commit
e15990b053
@ -891,7 +891,7 @@ void CmndRestart(void)
|
|||||||
break;
|
break;
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
case 3:
|
case 3:
|
||||||
if (EspPrepSwitchToOtherPartition()) {
|
if (EspPrepSwitchPartition(2)) { // Toggle partition between safeboot and production
|
||||||
TasmotaGlobal.restart_flag = 2;
|
TasmotaGlobal.restart_flag = 2;
|
||||||
ResponseCmndChar(PSTR("Switching"));
|
ResponseCmndChar(PSTR("Switching"));
|
||||||
}
|
}
|
||||||
|
@ -354,15 +354,33 @@ void EspPrepRestartToSafeBoot(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EspPrepSwitchToOtherPartition(void) {
|
bool EspPrepSwitchPartition(uint32_t state) {
|
||||||
bool valid = EspSingleOtaPartition();
|
bool valid = EspSingleOtaPartition();
|
||||||
if (valid) {
|
if (valid) {
|
||||||
bool running_factory = EspRunningFactoryPartition();
|
bool running_factory = EspRunningFactoryPartition();
|
||||||
if (!running_factory) {
|
switch (state) {
|
||||||
EspPrepRestartToSafeBoot();
|
case 0: // Off = safeboot
|
||||||
} else {
|
if (!running_factory) {
|
||||||
const esp_partition_t* partition = esp_ota_get_next_update_partition(nullptr);
|
EspPrepRestartToSafeBoot();
|
||||||
esp_ota_set_boot_partition(partition);
|
} else {
|
||||||
|
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;
|
||||||
|
@ -1002,12 +1002,16 @@ void WSContentStop(void) {
|
|||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
|
|
||||||
void WebRestart(uint32_t type)
|
void WebRestart(uint32_t type) {
|
||||||
{
|
|
||||||
// type 0 = restart
|
// type 0 = restart
|
||||||
// type 1 = restart after config change
|
// type 1 = restart after config change
|
||||||
// type 2 = Checking WiFi Connection - no restart, only refresh page.
|
// type 2 = Checking WiFi Connection - no restart, only refresh page.
|
||||||
// type 3 = restart after WiFi Connection Test Successful
|
// type 3 = restart after WiFi Connection Test Successful
|
||||||
|
// type 4 = type 0 without auto switch to production
|
||||||
|
bool prep_switch_partition = false;
|
||||||
|
if (0 == type) { prep_switch_partition = true; }
|
||||||
|
if (4 == type) { type = 0; }
|
||||||
|
|
||||||
bool reset_only = (HTTP_MANAGER_RESET_ONLY == Web.state);
|
bool reset_only = (HTTP_MANAGER_RESET_ONLY == Web.state);
|
||||||
|
|
||||||
WSContentStart_P((type) ? PSTR(D_SAVE_CONFIGURATION) : PSTR(D_RESTART), !reset_only);
|
WSContentStart_P((type) ? PSTR(D_SAVE_CONFIGURATION) : PSTR(D_RESTART), !reset_only);
|
||||||
@ -1040,7 +1044,7 @@ void WebRestart(uint32_t type)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type<2) {
|
if (type < 2) {
|
||||||
WSContentSend_P(HTTP_MSG_RSTRT);
|
WSContentSend_P(HTTP_MSG_RSTRT);
|
||||||
if (HTTP_MANAGER == Web.state || reset_only) {
|
if (HTTP_MANAGER == Web.state || reset_only) {
|
||||||
Web.state = HTTP_ADMIN;
|
Web.state = HTTP_ADMIN;
|
||||||
@ -1053,6 +1057,9 @@ 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 (prep_switch_partition) { EspPrepSwitchPartition(1); } // Switch to production partition if on safeboot
|
||||||
|
#endif // ESP32
|
||||||
TasmotaGlobal.restart_flag = 2;
|
TasmotaGlobal.restart_flag = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2495,14 +2502,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
|
prog_size = EspProgramSize(part->label); // safeboot partition (slow response)
|
||||||
}
|
}
|
||||||
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
|
prog_size = ESP_getSketchSize(); // Active running ota partition (fast response)
|
||||||
}
|
}
|
||||||
else if (cur_part == ESP_PARTITION_SUBTYPE_APP_FACTORY) {
|
else if (cur_part == ESP_PARTITION_SUBTYPE_APP_FACTORY) {
|
||||||
prog_size = EspProgramSize(part->label); // Only app partition when safeboot partitions
|
prog_size = EspProgramSize(part->label); // One app partition when safeboot partitions (slow response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char running[2] = { 0 };
|
char running[2] = { 0 };
|
||||||
@ -3037,7 +3044,7 @@ void HandleSwitchBootPartition(void)
|
|||||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTART));
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTART));
|
||||||
EspRestart();
|
EspRestart();
|
||||||
} else {
|
} else {
|
||||||
WebRestart(0);
|
WebRestart(4);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (api_mode) {
|
if (api_mode) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user