Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boot: zephyr: boot_record: Save boot data with single image #2138

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions boot/bootutil/src/boot_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are
const uint8_t slot, const struct image_max_size *max_app_sizes)
{
int rc;
#if !defined(MCUBOOT_SINGLE_APPLICATION_SLOT)
uint8_t image = 0;
dpw13 marked this conversation as resolved.
Show resolved Hide resolved
#endif

#if defined(MCUBOOT_SINGLE_APPLICATION_SLOT)
uint8_t mode = MCUBOOT_MODE_SINGLE_SLOT;
Expand Down Expand Up @@ -322,11 +324,13 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are
sizeof(recovery), &recovery);
}

#if !defined(MCUBOOT_SINGLE_APPLICATION_SLOT)
if (!rc) {
rc = boot_add_data_to_shared_area(TLV_MAJOR_BLINFO,
BLINFO_RUNNING_SLOT,
sizeof(slot), (void *)&slot);
}
#endif

#if defined(MCUBOOT_VERSION_AVAILABLE)
if (!rc) {
Expand All @@ -337,6 +341,7 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are
}
#endif

#if !defined(MCUBOOT_SINGLE_APPLICATION_SLOT)
while (image < BOOT_IMAGE_NUMBER && !rc) {
if (max_app_sizes[image].calculated == true) {
rc = boot_add_data_to_shared_area(TLV_MAJOR_BLINFO,
Expand All @@ -348,6 +353,7 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are

++image;
}
#endif

if (!rc) {
saved_bootinfo = true;
Expand Down
18 changes: 18 additions & 0 deletions boot/zephyr/single_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <assert.h>
#include "bootutil/image.h"
#include "bootutil_priv.h"
#include "bootutil/boot_record.h"
#include "bootutil/bootutil.h"
#include "bootutil/bootutil_log.h"
#include "bootutil/bootutil_public.h"
#include "bootutil/fault_injection_hardening.h"
Expand Down Expand Up @@ -140,6 +142,22 @@ boot_go(struct boot_rsp *rsp)
fih_rc = FIH_SUCCESS;
#endif /* MCUBOOT_VALIDATE_PRIMARY_SLOT */

#ifdef MCUBOOT_MEASURED_BOOT
rc = boot_save_boot_status(0, &_hdr, _fa_p);
if (rc != 0) {
BOOT_LOG_ERR("Failed to add image data to shared area");
return rc;
}
#endif /* MCUBOOT_MEASURED_BOOT */

#ifdef MCUBOOT_DATA_SHARING
rc = boot_save_shared_data(&_hdr, _fa_p, 0, NULL);
if (rc != 0) {
BOOT_LOG_ERR("Failed to add data to shared memory area.");
return rc;
}
#endif /* MCUBOOT_DATA_SHARING */

rsp->br_flash_dev_id = flash_area_get_device_id(_fa_p);
rsp->br_image_off = flash_area_get_off(_fa_p);
rsp->br_hdr = &_hdr;
Expand Down
Loading