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 <jamie.mccrae@nordicsemi.no>
(cherry picked from commit bcffc62c66
)
This commit is contained in:
parent
03b6482899
commit
ea2410697d
|
@ -32,6 +32,10 @@
|
||||||
#include "bootutil/image.h"
|
#include "bootutil/image.h"
|
||||||
#include "flash_map_backend/flash_map_backend.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)
|
#if !defined(MCUBOOT_CUSTOM_DATA_SHARING_FUNCTION)
|
||||||
/**
|
/**
|
||||||
* @var shared_memory_init_done
|
* @var shared_memory_init_done
|
||||||
|
@ -293,6 +297,11 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (saved_bootinfo) {
|
||||||
|
/* Boot info has already been saved, nothing to do */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Write out all fields */
|
/* Write out all fields */
|
||||||
rc = boot_add_data_to_shared_area(TLV_MAJOR_BLINFO, BLINFO_MODE,
|
rc = boot_add_data_to_shared_area(TLV_MAJOR_BLINFO, BLINFO_MODE,
|
||||||
sizeof(mode), &mode);
|
sizeof(mode), &mode);
|
||||||
|
@ -332,6 +341,10 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are
|
||||||
(void *)&max_app_size);
|
(void *)&max_app_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!rc) {
|
||||||
|
saved_bootinfo = true;
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
#endif /* MCUBOOT_DATA_SHARING_BOOTINFO */
|
#endif /* MCUBOOT_DATA_SHARING_BOOTINFO */
|
||||||
|
|
Loading…
Reference in New Issue