Compare commits

...

4 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
aaad22acc6 Move OTA validation earlier and add IDF version logging for debugging
Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com>
2025-11-10 07:17:42 +00:00
copilot-swe-agent[bot]
d04c9dc90a Complete ESP32-C3 OTA update fix implementation
Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com>
2025-11-10 06:50:50 +00:00
copilot-swe-agent[bot]
6fe7fb677c Fix ESP32-C3 OTA update issue by adding ESP-IDF OTA validation
Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com>
2025-11-10 06:49:02 +00:00
copilot-swe-agent[bot]
9db6a44809 Initial plan 2025-11-10 06:39:00 +00:00

View File

@@ -12,6 +12,10 @@
#include "soc/rtc_cntl_reg.h"
#endif
#ifdef ARDUINO_ARCH_ESP32
#include <esp_ota_ops.h>
#endif
extern "C" void usePWMFixedNMI();
/*
@@ -361,6 +365,26 @@ void WLED::setup()
DEBUG_PRINTF_P(PSTR("---WLED %s %u INIT---\n"), versionString, VERSION);
DEBUG_PRINTLN();
#ifdef ARDUINO_ARCH_ESP32
// Mark OTA app as valid IMMEDIATELY to prevent automatic rollback by ESP-IDF bootloader
// This MUST happen as early as possible, before any potential crashes
// Critical for OTA updates from 0.15 to 0.16+ on ESP32-C3 and other ESP32 variants
const esp_partition_t* running = esp_ota_get_running_partition();
esp_ota_img_states_t ota_state;
if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK) {
if (ota_state == ESP_OTA_IMG_PENDING_VERIFY) {
DEBUG_PRINTLN(F("*** OTA UPDATE DETECTED - Marking app as valid to prevent rollback ***"));
if (esp_ota_mark_app_valid_cancel_rollback() == ESP_OK) {
DEBUG_PRINTLN(F("OTA app marked valid successfully"));
} else {
DEBUG_PRINTLN(F("WARNING: Failed to mark OTA app as valid!"));
}
}
}
// Check IDF version for compatibility warnings
const char* idf_ver = esp_get_idf_version();
DEBUG_PRINTF_P(PSTR("ESP-IDF version: %s\n"), idf_ver);
DEBUG_PRINTF_P(PSTR("esp32 %s\n"), ESP.getSdkVersion());
#if defined(ESP_ARDUINO_VERSION)
DEBUG_PRINTF_P(PSTR("arduino-esp32 v%d.%d.%d\n"), int(ESP_ARDUINO_VERSION_MAJOR), int(ESP_ARDUINO_VERSION_MINOR), int(ESP_ARDUINO_VERSION_PATCH)); // available since v2.0.0