|
SimpleOTA client v1.0.0
Shared core of the SimpleOTA Arduino and ESP-IDF clients
|
What a boot means for a saved trial record. More...
Go to the source code of this file.
Data Structures | |
| struct | sota_boot_facts_t |
| The trial record and the boot's facts that sota_classify_boot() reads. More... | |
Enumerations | |
| enum | sota_boot_outcome_t { SOTA_BOOT_NONE = 0 , SOTA_BOOT_TRIAL , SOTA_BOOT_ROLLED_BACK , SOTA_BOOT_REPORT_PENDING , SOTA_BOOT_WAITING , SOTA_BOOT_ABANDONED , SOTA_BOOT_INCOMPLETE , SOTA_BOOT_TRIAL_RESET , SOTA_BOOT_ROLLBACK_CUT } |
| What a boot means for the saved trial record, and what to do about it. More... | |
| enum | { SOTA_TRIAL_STAGED = 1 , SOTA_TRIAL_ROLLED_BACK = 2 , SOTA_TRIAL_BOOTED = 3 } |
| sota_trial values. More... | |
| enum | { SOTA_STAGED_STARTED = 1 , SOTA_STAGED_SNAPSHOT = 2 } |
| sota_staged values. More... | |
| enum | { SOTA_RST_POWERON = 1 , SOTA_RST_SW = 3 , SOTA_RST_PANIC = 4 , SOTA_RST_INT_WDT = 5 , SOTA_RST_TASK_WDT = 6 , SOTA_RST_WDT = 7 , SOTA_RST_DEEPSLEEP = 8 , SOTA_RST_BROWNOUT = 9 } |
| esp_reset_reason_t values used for rollback reasons. | |
Functions | |
| static bool | sota_on_new_image (const sota_boot_facts_t *f) |
| Whether the running image is the update's, from sota_new_part or else sota_prev_part. | |
| static sota_boot_outcome_t | sota_classify_boot (const sota_boot_facts_t *f) |
| Classify this boot against the trial record. | |
| static bool | sota_abandon_restores_identity (uint8_t staged) |
| An abandoned record puts the previous identity back only when it was saved in full. | |
| static bool | sota_hold_pending_image (bool image_pending, sota_boot_outcome_t outcome) |
| Arduino's verifyRollbackLater(): keep an image the bootloader still has on probation (pending verify) only when it is a SimpleOTA trial. | |
| static bool | sota_reset_is_crash (int reset_reason) |
| The reset was a crash or a watchdog. | |
| static const char * | sota_rollback_reason (int reset_reason) |
| Reason sent with rolled_back, from the reset that ended the trial. | |
What a boot means for a saved trial record.
The trial record uses NVS keys that every release of both clients reads and writes: sota_trial (1 = trial, 3 = a trial whose image has booted, 2 = a rollback happened), sota_new_part (where the update went) and sota_prev_part (the partition the update replaced). Arduino releases up to 0.6.0 write only sota_prev_part; ESP-IDF releases write both. The classifier uses sota_new_part when it is there and falls back to sota_prev_part, so a record from any earlier release of either client reads the way that release meant it.
The apply path also writes sota_staged before the boot slot switches and removes it straight after, so a record whose slot switch never happened can be told apart from a rollback. A release that does not know sota_staged ignores it, and a record written without it reads like any other, so updates in either direction between releases read the same way.
Any trial value other than 0 and 2 is a trial, so a release that does not know 3 reads it as one.
No platform types, so the host tests can include this header.
| enum sota_boot_outcome_t |
What a boot means for the saved trial record, and what to do about it.
| anonymous enum |
| anonymous enum |
|
inlinestatic |
Whether the running image is the update's, from sota_new_part or else sota_prev_part.
False when neither is known.
|
inlinestatic |
Classify this boot against the trial record.
Pure, so the host tests cover every power-cut point.
|
inlinestatic |
An abandoned record puts the previous identity back only when it was saved in full.
Before that, the live identity was not touched.
|
inlinestatic |
Arduino's verifyRollbackLater(): keep an image the bootloader still has on probation (pending verify) only when it is a SimpleOTA trial.
Any other pending image, such as one written by ArduinoOTA, is left for the Arduino core to accept.
|
inlinestatic |
The reset was a crash or a watchdog.
A trial that crashed before it could save its first boot (SOTA_TRIAL_BOOTED), such as in a global constructor, has failed it too. Other resets cannot be told apart from the restart into the update.