diff --git a/docs/API.md b/docs/API.md index aedfe3d3..a0c3630c 100644 --- a/docs/API.md +++ b/docs/API.md @@ -32,21 +32,25 @@ and - `wolfBoot_update()` is used to trigger an update upon the next reboot, and it is normally used by an update application that has retrieved a new version of the running firmware, and has stored it in the UPDATE partition on the flash. This function will set the state of the UPDATE partition -to `ST_UPDATE`, instructing the bootloader to perform the update upon the next execution (after reboot). +to `STATE_UPDATING`, instructing the bootloader to perform the update upon the next execution (after reboot). wolfBoot update process consist in swapping the content of the UPDATE and the BOOT partitions, using a temporary single-block SWAP space. +### Confirm current image + - `wolfBoot_success()` indicates a successful boot of a new firmware. This can be called by the application at any time, but it will only be effective to mark the current firmware (in the BOOT partition) with the state -`ST_SUCCESS`, indicating that no roll-back is required. An application should typically call `wolfBoot_success()` +`STATE_SUCCESS`, indicating that no roll-back is required. An application should typically call `wolfBoot_success()` only after verifying that the basic system features are up and running, including the possibility to retrieve a new firmware for the next upgrade. -If after an upgrade wolfBoot detects that the active firmware is still in `ST_TESTING` state, it means that +If after an upgrade wolfBoot detects that the active firmware is still in `STATE_TESTING` state, it means that a successful boot has not been confirmed for the application, and will attempt to revert the update by swapping the two images again. For more information about the update process, see [Firmware Update](firmware_update.md) +For the image format, see [Firmware Image](firmware_image.md) + diff --git a/docs/firmware_update.md b/docs/firmware_update.md index 79d89b03..f5e09028 100644 --- a/docs/firmware_update.md +++ b/docs/firmware_update.md @@ -13,6 +13,8 @@ The steps to follow to complete a firmware update with wolfBoot are: At any given time, an application or OS running on a wolfBoot system can receive an updated version of itself, and store the updated image in the second partition in the FLASH memory. +![Update and Rollback](png/wolfboot_update_rollback.png) + Applications or OS threads can be linked to the [libwolfboot library](API.md), which exports the API to trigger the update at the next reboot, and some helper functions to access the flash partition for erase/write through the target specific [HAL](HAL.md). @@ -27,7 +29,7 @@ After storing the new firmware image in the UPDATE partition, the application sh - Validate the new firmware image stored in the UPDATE partition - Verify the signature attached against a known public key stored in the bootloader image - Swap the content of the BOOT and the UPDATE partitions - - Mark the new firmware in the BOOT partition as in state `ST_TESTING` + - Mark the new firmware in the BOOT partition as in state `STATE_TESTING` - Boot into the newly received firmware ### Successful boot @@ -35,7 +37,7 @@ After storing the new firmware image in the UPDATE partition, the application sh Upon a successful boot, the application should inform the bootloader by calling `wolfBoot_success()`, after verifying that the system is up and running again. This operation confirms the update to a new firmware. -Failing to set the BOOT partition to `ST_SUCCESS` before the next reboot triggers a roll-back operation. +Failing to set the BOOT partition to `STATE_SUCCESS` before the next reboot triggers a roll-back operation. Roll-back is initiated by the bootloader by triggering a new update, this time starting from the backup copy of the original (pre-update) firmware, which is now stored in the UPDATE partition due to the swap occurring earlier. diff --git a/docs/png/wolfboot_update_rollback.png b/docs/png/wolfboot_update_rollback.png new file mode 100644 index 00000000..fbf26137 Binary files /dev/null and b/docs/png/wolfboot_update_rollback.png differ