Skip to content

[Feature] Rollback after OTA Update #13

Description

@Yoshi367

In case the user flashed a faulty firmware e.g. the webserver is not working or the board is stuck in a bootloop the bootloader shall perform a rollback to the last functioning partition. In this case the factory partition containing the PixelixUpdater. Take a look at espressifs documentation:

https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/ota.html

To enable the rollback following define needs to be set in the sdkconfig file: CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
Using only the arduino framework the functions which are part of the rollback process (coming from the espressif framework) are accessible. But these functions seem to come pre compiled with a default configuration where rollback is not enabled.

The rollback process (described in the documentation provided above) starts by setting the state of the newly uploaded firmware image to new.
In the PixelixUpdater this is done after the upload is finished by calling:

-> Update.end
->_verifyEnd
->esp_ota_set_boot_partition
->esp_rewrite_ota_data
->set_new_state_otadata

The set_new_state_otadata is one of those pre compiled functions. Therefore the new state is never set and the rollback process can't begin.

static esp_ota_img_states_t set_new_state_otadata(void)
{
#ifdef CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE
ESP_LOGD(TAG, "Monitoring the first boot of the app is enabled.");
return ESP_OTA_IMG_NEW;
#else
return ESP_OTA_IMG_UNDEFINED;
#endif
}

Functions part of the rollback process:
https://github.com/espressif/esp-idf/blob/master/components/app_update/esp_ota_ops.c#L813
https://github.com/espressif/esp-idf/blob/master/components/bootloader_support/src/bootloader_utility.c#L450

The only way it is possible to still use the arduino framework and have rollback enabled is to use the espressif framework with arduino as a component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions