Boot: Save image sequence number to image trailer
Overload the swap_type field in image trailer to store as an addition
the image sequence number. It indicates which image's swap was
interrupted. It is required by multi image boot to determine which
image the trailer belongs to if boot status is found on scratch area
when the swap operation is resumed.
Change-Id: I1a695fa7b51ccf7fb7969496517617d76bc44c02
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
Co-authored-by: David Vincze <david.vincze@arm.com>
diff --git a/bl2/ext/mcuboot/bootutil/src/loader.c b/bl2/ext/mcuboot/bootutil/src/loader.c
index 3631018..80789e5 100644
--- a/bl2/ext/mcuboot/bootutil/src/loader.c
+++ b/bl2/ext/mcuboot/bootutil/src/loader.c
@@ -678,6 +678,7 @@
{
const struct flash_area *fap;
uint32_t off;
+ uint8_t swap_info;
int status_loc;
int area_id;
int rc;
@@ -717,13 +718,15 @@
rc = boot_read_status_bytes(fap, bs);
if (rc == 0) {
- off = boot_swap_type_off(fap);
- rc = flash_area_read_is_empty(fap, off, &bs->swap_type,
- sizeof bs->swap_type);
+ off = boot_swap_info_off(fap);
+ rc = flash_area_read_is_empty(fap, off, &swap_info, sizeof swap_info);
if (rc == 1) {
- bs->swap_type = BOOT_SWAP_TYPE_NONE;
+ BOOT_SET_SWAP_INFO(swap_info, 0, BOOT_SWAP_TYPE_NONE);
rc = 0;
}
+
+ /* Extract the swap type info */
+ bs->swap_type = BOOT_GET_SWAP_TYPE(swap_info);
}
flash_area_close(fap);
@@ -945,7 +948,9 @@
assert(rc == 0);
if (bs->swap_type != BOOT_SWAP_TYPE_NONE) {
- rc = boot_write_swap_type(fap, bs->swap_type);
+ rc = boot_write_swap_info(fap,
+ bs->swap_type,
+ 0);
assert(rc == 0);
}
@@ -1154,8 +1159,9 @@
}
if (swap_state.swap_type != BOOT_SWAP_TYPE_NONE) {
- rc = boot_write_swap_type(fap_primary_slot,
- swap_state.swap_type);
+ rc = boot_write_swap_info(fap_primary_slot,
+ swap_state.swap_type,
+ 0);
assert(rc == 0);
}