Fix OTA update for C3 from 0.15 (#5072)

* change C3 to DIO, add explicit QIO env for C3, add markOTAvalid() to support OTA from 0.15
This commit is contained in:
Damian Schneider
2025-11-15 07:41:11 +01:00
committed by GitHub
parent f1d708ca43
commit 194829336f
4 changed files with 27 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ default_envs = nodemcuv2
esp32_wrover esp32_wrover
lolin_s2_mini lolin_s2_mini
esp32c3dev esp32c3dev
esp32c3dev_qio
esp32s3dev_16MB_opi esp32s3dev_16MB_opi
esp32s3dev_8MB_opi esp32s3dev_8MB_opi
esp32s3_4M_qspi esp32s3_4M_qspi
@@ -543,6 +544,12 @@ build_flags = ${common.build_flags} ${esp32c3.build_flags} -D WLED_RELEASE_NAME=
upload_speed = 460800 upload_speed = 460800
build_unflags = ${common.build_unflags} build_unflags = ${common.build_unflags}
lib_deps = ${esp32c3.lib_deps} lib_deps = ${esp32c3.lib_deps}
board_build.flash_mode = dio ; safe default, required for OTA updates to 0.16 from older version which used dio (must match the bootloader!)
[env:esp32c3dev_qio]
extends = env:esp32c3dev
build_flags = ${common.build_flags} ${esp32c3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-C3-QIO\"
board_build.flash_mode = qio ; qio is faster and works on almost all boards (some boards may use dio to get 2 extra pins)
[env:esp32s3dev_16MB_opi] [env:esp32s3dev_16MB_opi]
;; ESP32-S3 development board, with 16MB FLASH and >= 8MB PSRAM (memory_type: qio_opi) ;; ESP32-S3 development board, with 16MB FLASH and >= 8MB PSRAM (memory_type: qio_opi)

View File

@@ -259,6 +259,19 @@ void handleOTAData(AsyncWebServerRequest *request, size_t index, uint8_t *data,
} }
} }
void markOTAvalid() {
#ifndef ESP8266
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) {
esp_ota_mark_app_valid_cancel_rollback(); // only needs to be called once, it marks the ota_state as ESP_OTA_IMG_VALID
DEBUG_PRINTLN(F("Current firmware validated"));
}
}
#endif
}
#if defined(ARDUINO_ARCH_ESP32) && !defined(WLED_DISABLE_OTA) #if defined(ARDUINO_ARCH_ESP32) && !defined(WLED_DISABLE_OTA)
// Cache for bootloader SHA256 digest as hex string // Cache for bootloader SHA256 digest as hex string
static String bootloaderSHA256HexCache = ""; static String bootloaderSHA256HexCache = "";

View File

@@ -51,6 +51,12 @@ std::pair<bool, String> getOTAResult(AsyncWebServerRequest *request);
*/ */
void handleOTAData(AsyncWebServerRequest *request, size_t index, uint8_t *data, size_t len, bool isFinal); void handleOTAData(AsyncWebServerRequest *request, size_t index, uint8_t *data, size_t len, bool isFinal);
/**
* Mark currently running firmware as valid to prevent auto-rollback on reboot.
* This option can be enabled in some builds/bootloaders, it is an sdkconfig flag.
*/
void markOTAvalid();
#if defined(ARDUINO_ARCH_ESP32) && !defined(WLED_DISABLE_OTA) #if defined(ARDUINO_ARCH_ESP32) && !defined(WLED_DISABLE_OTA)
/** /**
* Calculate and cache the bootloader SHA256 digest * Calculate and cache the bootloader SHA256 digest

View File

@@ -555,6 +555,7 @@ void WLED::setup()
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET) #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET)
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1); //enable brownout detector WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1); //enable brownout detector
#endif #endif
markOTAvalid();
} }
void WLED::beginStrip() void WLED::beginStrip()