Skip to content

Commit bcffc62

Browse files
committed
boot: bootutil: boot_record: Fix issue with saving image data
Fixes an issue with saving shared boot data when the number of images is more than 1. This is caused becuase the function is called once per image but the function itself saves common data plus data for all images, so prevent saving when it has already ran once Signed-off-by: Jamie McCrae <[email protected]>
1 parent 099f428 commit bcffc62

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

boot/bootutil/src/boot_record.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include "bootutil/image.h"
3333
#include "flash_map_backend/flash_map_backend.h"
3434

35+
#if defined(MCUBOOT_DATA_SHARING_BOOTINFO)
36+
static bool saved_bootinfo = false;
37+
#endif
38+
3539
#if !defined(MCUBOOT_CUSTOM_DATA_SHARING_FUNCTION)
3640
/**
3741
* @var shared_memory_init_done
@@ -296,6 +300,11 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are
296300
};
297301
#endif
298302

303+
if (saved_bootinfo) {
304+
/* Boot info has already been saved, nothing to do */
305+
return 0;
306+
}
307+
299308
/* Write out all fields */
300309
rc = boot_add_data_to_shared_area(TLV_MAJOR_BLINFO, BLINFO_MODE,
301310
sizeof(mode), &mode);
@@ -340,6 +349,10 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are
340349
++image;
341350
}
342351

352+
if (!rc) {
353+
saved_bootinfo = true;
354+
}
355+
343356
return rc;
344357
}
345358
#endif /* MCUBOOT_DATA_SHARING_BOOTINFO */

0 commit comments

Comments
 (0)