mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 10:46:31 +00:00
Add ESP32 intermediate safemode OTA
This commit is contained in:
parent
ff6342cad0
commit
5c136bf0cc
@ -295,9 +295,16 @@ extern "C" {
|
||||
#include "rom/spi_flash.h"
|
||||
#endif
|
||||
|
||||
bool EspSingleOtaPartition(void) {
|
||||
return (1 == esp_ota_get_app_partition_count());
|
||||
}
|
||||
|
||||
void EspRestartToSaveMode(void) {
|
||||
esp_ota_mark_app_invalid_rollback_and_reboot();
|
||||
}
|
||||
|
||||
uint32_t EspFlashBaseAddress(void) {
|
||||
uint32_t part_count = esp_ota_get_app_partition_count();
|
||||
if (1 == part_count) { // Only one partition so start at end of sketch
|
||||
if (EspSingleOtaPartition()) { // Only one partition so start at end of sketch
|
||||
const esp_partition_t *running = esp_ota_get_running_partition();
|
||||
if (!running) { return 0; }
|
||||
return running->address + ESP_getSketchSize();
|
||||
@ -309,8 +316,7 @@ uint32_t EspFlashBaseAddress(void) {
|
||||
}
|
||||
|
||||
uint32_t EspFlashBaseEndAddress(void) {
|
||||
uint32_t part_count = esp_ota_get_app_partition_count();
|
||||
const esp_partition_t* partition = (1 == part_count) ? esp_ota_get_running_partition() : esp_ota_get_next_update_partition(nullptr);
|
||||
const esp_partition_t* partition = (EspSingleOtaPartition()) ? esp_ota_get_running_partition() : esp_ota_get_next_update_partition(nullptr);
|
||||
if (!partition) { return 0; }
|
||||
return partition->address + partition->size; // For tasmota 0x00200000 or 0x003F0000
|
||||
}
|
||||
|
@ -1242,6 +1242,20 @@ void Every250mSeconds(void)
|
||||
}
|
||||
}
|
||||
#endif // ESP8266
|
||||
|
||||
#ifdef ESP32
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
if (EspSingleOtaPartition()) {
|
||||
RtcSettings.ota_loader = 1; // Try safemode image next
|
||||
SettingsSaveAll();
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
|
||||
ResetPwm();
|
||||
WifiShutdown(true);
|
||||
EspRestartToSaveMode();
|
||||
}
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
#endif // ESP32
|
||||
|
||||
char version[50];
|
||||
snprintf_P(version, sizeof(version), PSTR("%s%s"), TasmotaGlobal.version, TasmotaGlobal.image_name);
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s %s"), full_ota_url, version);
|
||||
|
@ -617,8 +617,7 @@ void WifiConnect(void)
|
||||
#endif // WIFI_RF_PRE_INIT
|
||||
}
|
||||
|
||||
void WifiShutdown(bool option = false)
|
||||
{
|
||||
void WifiShutdown(bool option) {
|
||||
// option = false - Legacy disconnect also used by DeepSleep
|
||||
// option = true - Disconnect with SDK wifi calibrate sector erase when WIFI_FORCE_RF_CAL_ERASE enabled
|
||||
delay(100); // Allow time for message xfer - disabled v6.1.0b
|
||||
|
@ -38,6 +38,7 @@ extern "C" {
|
||||
void KNX_CB_Action(message_t const &msg, void *arg);
|
||||
#endif // USE_KNX
|
||||
|
||||
void WifiShutdown(bool option = false);
|
||||
void DomoticzTempHumPressureSensor(float temp, float hum, float baro = -1);
|
||||
char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, char inbetween = '\0');
|
||||
extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack, uint32_t stack_end);
|
||||
|
Loading…
x
Reference in New Issue
Block a user