-
Notifications
You must be signed in to change notification settings - Fork 7.6k
How to use OTA Rollback? [ QUESTION ] #7422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If i include It compiles but void checkFirmware(){
Serial.printf("[SYSTEM] - Checking firmware...\n");
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) {
const char* otaState = ota_state == ESP_OTA_IMG_NEW ? "ESP_OTA_IMG_NEW"
: ota_state == ESP_OTA_IMG_PENDING_VERIFY ? "ESP_OTA_IMG_PENDING_VERIFY"
: ota_state == ESP_OTA_IMG_VALID ? "ESP_OTA_IMG_VALID"
: ota_state == ESP_OTA_IMG_INVALID ? "ESP_OTA_IMG_INVALID"
: ota_state == ESP_OTA_IMG_ABORTED ? "ESP_OTA_IMG_ABORTED"
: "ESP_OTA_IMG_UNDEFINED";
Serial.printf("[System] - Ota state: %s\n",otaState);
if (ota_state == ESP_OTA_IMG_PENDING_VERIFY) {
if (esp_ota_mark_app_valid_cancel_rollback() == ESP_OK) {
Serial.printf("[System] - App is valid, rollback cancelled successfully\n");
} else {
Serial.printf("[System] - Failed to cancel rollback\n");
}
}
}else{
Serial.printf("[System] - OTA partition has no record in OTA data\n");
}
} Debug: [SYSTEM] - Checking firmware...
[System] - Ota state: ESP_OTA_IMG_VALID every time |
#include "esp_ota_ops.h"
#define CONFIG_APP_ROLLBACK_ENABLE
// Redefine function to return true instead of false??
// Not working??
// Commit: https://github.com/espressif/arduino-esp32/pull/6779/commits/b9b4f07a01b461c782ea79af5b84767d915fb2c5
boolean verifyRollbackLater(){
return true;
}
void checkFirmware(){
Serial.printf("[SYSTEM] - Checking firmware...\n");
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) {
const char* otaState = ota_state == ESP_OTA_IMG_NEW ? "ESP_OTA_IMG_NEW"
: ota_state == ESP_OTA_IMG_PENDING_VERIFY ? "ESP_OTA_IMG_PENDING_VERIFY"
: ota_state == ESP_OTA_IMG_VALID ? "ESP_OTA_IMG_VALID"
: ota_state == ESP_OTA_IMG_INVALID ? "ESP_OTA_IMG_INVALID"
: ota_state == ESP_OTA_IMG_ABORTED ? "ESP_OTA_IMG_ABORTED"
: "ESP_OTA_IMG_UNDEFINED";
Serial.printf("[System] - Ota state: %s\n",otaState);
if (ota_state == ESP_OTA_IMG_PENDING_VERIFY) {
if (esp_ota_mark_app_valid_cancel_rollback() == ESP_OK) {
Serial.printf("[System] - App is valid, rollback cancelled successfully\n");
} else {
Serial.printf("[System] - Failed to cancel rollback\n");
}
}
}else{
Serial.printf("[System] - OTA partition has no record in OTA data\n");
}
}
void setup(){
Serial.begin(115200);
checkFirmware();
}
void loop(){
} |
This PR https://github.com/espressif/arduino-esp32/pull/6779/files Does not work. bool verifyRollbackLater(){
return true;
}
void Sys::verifyFirmware(){
if( !shouldCheckFirmware ){ return; }
if( (millis() - startMS) <= FIRMWARE_CHECK_MS ){ return; }
shouldCheckFirmware = false;
debug.print(DEBUG_INFO,"[SYSTEM] - Verifying firmware...\n");
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) {
const char* otaState = ota_state == ESP_OTA_IMG_NEW ? "ESP_OTA_IMG_NEW"
: ota_state == ESP_OTA_IMG_PENDING_VERIFY ? "ESP_OTA_IMG_PENDING_VERIFY"
: ota_state == ESP_OTA_IMG_VALID ? "ESP_OTA_IMG_VALID"
: ota_state == ESP_OTA_IMG_INVALID ? "ESP_OTA_IMG_INVALID"
: ota_state == ESP_OTA_IMG_ABORTED ? "ESP_OTA_IMG_ABORTED"
: "ESP_OTA_IMG_UNDEFINED";
debug.print(DEBUG_INFO, "[System] - Ota state: %s\n",otaState);
if (ota_state == ESP_OTA_IMG_PENDING_VERIFY) {
if (esp_ota_mark_app_valid_cancel_rollback() == ESP_OK) {
debug.print(DEBUG_INFO, "[System] - App is valid, rollback cancelled successfully\n");
} else {
debug.print(DEBUG_WARN, "[System] - Failed to cancel rollback\n");
}
}
}else{
debug.print(DEBUG_ERROR,"[System] - OTA partition has no record in OTA data\n");
}
} I always get: [SYSTEM] - Verifying firmware...
[System] - Ota state: ESP_OTA_IMG_VALID |
Opened a clear ticket |
just call You need to include Source (documentation): |
Board
ESP32-Wrover-E
Device Description
custom
Hardware Configuration
custom
Version
latest master (checkout manually)
IDE Name
PlatformIO
Operating System
Windows 11
Flash frequency
80mhz
PSRAM enabled
yes
Upload speed
115200
Description
I use OTA heavily. If i upload a new sketch which crashes at some point, how to roll back to the previous update?
I tracked some issues and forums but i couldn't find any example related to arduino.
How to enable OTA rollback feature?
How to overwrite
verifyRollbackLater()
orverifyOTA()
?Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: