Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ default_envs = nodemcuv2
esp32_wrover
lolin_s2_mini
esp32c3dev
esp32c3dev_qio
esp32s3dev_16MB_opi
esp32s3dev_8MB_opi
esp32s3_4M_qspi
Expand Down Expand Up @@ -543,6 +544,13 @@ build_flags = ${common.build_flags} ${esp32c3.build_flags} -D WLED_RELEASE_NAME=
upload_speed = 460800
build_unflags = ${common.build_unflags}
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_unflags = -D WLED_RELEASE_NAME
build_flags = ${env:esp32c3dev.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]
;; ESP32-S3 development board, with 16MB FLASH and >= 8MB PSRAM (memory_type: qio_opi)
Expand Down
13 changes: 13 additions & 0 deletions wled00/ota_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
// Cache for bootloader SHA256 digest as hex string
static String bootloaderSHA256HexCache = "";
Expand Down
6 changes: 6 additions & 0 deletions wled00/ota_update.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
* 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)
/**
* Calculate and cache the bootloader SHA256 digest
Expand Down
1 change: 1 addition & 0 deletions wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ void WLED::setup()
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET)
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1); //enable brownout detector
#endif
markOTAvalid();
}

void WLED::beginStrip()
Expand Down
Loading