Skip to content

App rollback /w Arduino as an ESP-IDF component #3318

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

Closed
jakubtopic opened this issue Oct 4, 2019 · 4 comments
Closed

App rollback /w Arduino as an ESP-IDF component #3318

jakubtopic opened this issue Oct 4, 2019 · 4 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@jakubtopic
Copy link

jakubtopic commented Oct 4, 2019

Hello, I use v1.0.3 as an ESP-IDF component and I'd wish to use the app rollback for ensuring functionality after broken firmware update (Update.h is used to perform the update). But after enabling CONFIG_APP_ROLLBACK_ENABLE it does not simply work. After firmware update, the following snippet returns ESP_OTA_IMG_VALID instead of expected ESP_OTA_IMG_PENDING_VERIFY.

const esp_partition_t *cur_app = esp_ota_get_running_partition();
esp_ota_img_states_t ota_state;
esp_ota_get_state_partition(cur_app, &ota_state);

And after restarting without marking the image as valid, the same (updated) image will be loaded again. Not the original one - there is no rollback.

My partition table looks like this:

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x1E0000,
app1,     app,  ota_1,   0x1F0000,0x1E0000,
spiffs,   data, spiffs,  0x3D0000,0x30000,

If there is any relevant data missing, I'll be happy to add it.

Is there a way how to make it work? Is the problem with the combination of ESP-IDF/Arduino framework?

@jakubtopic jakubtopic changed the title App rollback App rollback /w Arduino as an ESP-IDF component Oct 4, 2019
@stale
Copy link

stale bot commented Dec 3, 2019

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Dec 3, 2019
@stale
Copy link

stale bot commented Dec 17, 2019

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Dec 17, 2019
@marcovannoord
Copy link

So i found your issue because i ran into the same issue.
It took me quite some time to find out that during the initArduino() function that is called when CONFIG_AUTOSTART_ARDUINO is enabled in menuconfig, will call the (weakly defined) function verifyOta().
By default, that function will always return true, and before your setup() function is called, it will change from ESP_OTA_IMG_PENDING_VERIFY to ESP_OTA_IMG_VALID.

To fix this:

@Adrian-Samoticha
Copy link

So i found your issue because i ran into the same issue. It took me quite some time to find out that during the initArduino() function that is called when CONFIG_AUTOSTART_ARDUINO is enabled in menuconfig, will call the (weakly defined) function verifyOta(). By default, that function will always return true, and before your setup() function is called, it will change from ESP_OTA_IMG_PENDING_VERIFY to ESP_OTA_IMG_VALID.

To fix this:

For anyone stumbling upon this issue in the future, don’t miss the fact that the verifyOta and verifyRollbackLater functions are defined in a .c file. Therefore, if you wish to disable the automatic verification, do not forget to add extern "C" to your function override:

extern "C" bool verifyRollbackLater(){
    return true;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

3 participants