Skip to content

Commit

Permalink
boot: bootutil: boot_record: Fix issue with saving image data
Browse files Browse the repository at this point in the history
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 <jamie.mccrae@nordicsemi.no>
  • Loading branch information
nordicjm committed Nov 15, 2024
1 parent 099f428 commit bcffc62
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions boot/bootutil/src/boot_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "bootutil/image.h"
#include "flash_map_backend/flash_map_backend.h"

#if defined(MCUBOOT_DATA_SHARING_BOOTINFO)
static bool saved_bootinfo = false;
#endif

#if !defined(MCUBOOT_CUSTOM_DATA_SHARING_FUNCTION)
/**
* @var shared_memory_init_done
Expand Down Expand Up @@ -296,6 +300,11 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are
};
#endif

if (saved_bootinfo) {
/* Boot info has already been saved, nothing to do */
return 0;
}

/* Write out all fields */
rc = boot_add_data_to_shared_area(TLV_MAJOR_BLINFO, BLINFO_MODE,
sizeof(mode), &mode);
Expand Down Expand Up @@ -340,6 +349,10 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are
++image;
}

if (!rc) {
saved_bootinfo = true;
}

return rc;
}
#endif /* MCUBOOT_DATA_SHARING_BOOTINFO */

0 comments on commit bcffc62

Please sign in to comment.