dfu: mcuboot: add boot_is_img_confirmed()

Applications chainloaded by MCUboot may want to change their behavior
based on whether or not they are confirmed.

Here are some examples:

  - performing a built-in self test (BIST) if the image is not yet
    confirmed, and marking it OK if it passes (this enables reverting
    to an older working image if the BIST fails, and allows future
    resets to skip the BIST if it passes to improve boot time)

  - interacting with persistent metadata related to image state on
    other flash partitions during test upgrades (these are required in
    cases when the update source provides runtime metadata, such as
    monotonic counters, related to an upgrade attempt which must be
    used to report results)

To enable these use cases, add boot_is_img_confirmed(), which reads
the "image OK" field for the current firmware image and returns true
if and only if it is set.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
This commit is contained in:
Marti Bolivar 2018-01-31 18:30:46 -05:00 committed by Anas Nashif
commit 01aa12bffd
2 changed files with 30 additions and 3 deletions

View file

@ -168,6 +168,11 @@ int boot_request_upgrade(int permanent)
return rc;
}
bool boot_is_img_confirmed(void)
{
return boot_image_ok_read(FLASH_BANK0_OFFSET) == BOOT_FLAG_SET;
}
int boot_write_img_confirmed(void)
{
int rc;