Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/*
Expand Down Expand Up @@ -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
Expand Down