aboutsummaryrefslogtreecommitdiff
path: root/bl2/src/shared_data.c
diff options
context:
space:
mode:
authorJamie Fox <jamie.fox@arm.com>2022-08-15 16:56:33 +0100
committerDavid Hu <david.hu@arm.com>2022-08-19 10:27:07 +0200
commit7980b23f9c4b739bd8ccf1e4b5de1b584cac0b21 (patch)
tree62138c870ec2d7074930a5da106f21e80eb08727 /bl2/src/shared_data.c
parente05c9baa6b9a291a79c55225c9bb39e9d7ff52c0 (diff)
downloadtrusted-firmware-m-7980b23f9c4b739bd8ccf1e4b5de1b584cac0b21.tar.gz
Boot: Consider both image slots for shared data
When saving shared data, look for the supplied image flash area in both the primary and secondary slots instead of only the primary slot. In ram-load and direct-xip modes, the selected image may be in the secondary slot. Signed-off-by: Jamie Fox <jamie.fox@arm.com> Change-Id: Ia4374a46a2c92c392909d3d54e2fad8232001fe4
Diffstat (limited to 'bl2/src/shared_data.c')
-rw-r--r--bl2/src/shared_data.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/bl2/src/shared_data.c b/bl2/src/shared_data.c
index 73d0f732a2..fd2fb7b687 100644
--- a/bl2/src/shared_data.c
+++ b/bl2/src/shared_data.c
@@ -193,15 +193,18 @@ int boot_save_shared_data(const struct image_header *hdr,
/* Look for the given flash area to determine the image ID. */
for (i = 0; i < MCUBOOT_IMAGE_NUMBER; i++) {
- if (flash_area_open(FLASH_AREA_IMAGE_PRIMARY(i),
- &temp_fap) != 0) {
- return -1;
+ if (flash_area_open(FLASH_AREA_IMAGE_PRIMARY(i), &temp_fap) == 0 &&
+ fap == temp_fap) {
+ mcuboot_image_id = i;
+ break;
}
-
- if (fap == temp_fap) {
+#if defined(MCUBOOT_DIRECT_XIP) || defined(MCUBOOT_RAM_LOAD)
+ else if (flash_area_open(FLASH_AREA_IMAGE_SECONDARY(i), &temp_fap) == 0 &&
+ fap == temp_fap) {
mcuboot_image_id = i;
break;
}
+#endif
}
if (i == MCUBOOT_IMAGE_NUMBER) {