From d7f3058e40d42b92eb8882f488316466339050bf Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 2 Jan 2025 11:58:42 +0000 Subject: [PATCH] Ignore, define check updates which will be squashed later --- boot/bootutil/include/bootutil/boot_status.h | 1 + boot/bootutil/include/bootutil/bootutil_public.h | 2 +- boot/bootutil/include/bootutil/caps.h | 1 + boot/bootutil/src/boot_record.c | 2 ++ boot/bootutil/src/bootutil_misc.c | 2 +- boot/bootutil/src/caps.c | 2 ++ boot/bootutil/src/loader.c | 6 +++--- boot/bootutil/src/swap_misc.c | 4 ++-- boot/bootutil/src/swap_priv.h | 6 +++--- 9 files changed, 16 insertions(+), 10 deletions(-) diff --git a/boot/bootutil/include/bootutil/boot_status.h b/boot/bootutil/include/bootutil/boot_status.h index fddcc4bc2..91f266bc7 100644 --- a/boot/bootutil/include/bootutil/boot_status.h +++ b/boot/bootutil/include/bootutil/boot_status.h @@ -130,6 +130,7 @@ enum mcuboot_mode { MCUBOOT_MODE_RAM_LOAD, MCUBOOT_MODE_FIRMWARE_LOADER, MCUBOOT_MODE_SINGLE_SLOT_RAM_LOAD, + MCUBOOT_MODE_SWAP_USING_OFFSET, }; enum mcuboot_signature_type { diff --git a/boot/bootutil/include/bootutil/bootutil_public.h b/boot/bootutil/include/bootutil/bootutil_public.h index b2d5a5de8..ffd263591 100644 --- a/boot/bootutil/include/bootutil/bootutil_public.h +++ b/boot/bootutil/include/bootutil/bootutil_public.h @@ -85,7 +85,7 @@ extern "C" { #ifdef MCUBOOT_BOOT_MAX_ALIGN -#if defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_SCRATCH) +#if defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_OFFSET) _Static_assert(MCUBOOT_BOOT_MAX_ALIGN >= 8 && MCUBOOT_BOOT_MAX_ALIGN <= 32, "Unsupported value for MCUBOOT_BOOT_MAX_ALIGN for SWAP upgrade modes"); #endif diff --git a/boot/bootutil/include/bootutil/caps.h b/boot/bootutil/include/bootutil/caps.h index f4ff37334..3227f7e49 100644 --- a/boot/bootutil/include/bootutil/caps.h +++ b/boot/bootutil/include/bootutil/caps.h @@ -53,6 +53,7 @@ uint32_t bootutil_get_caps(void); #define BOOTUTIL_CAP_DIRECT_XIP (1<<17) #define BOOTUTIL_CAP_HW_ROLLBACK_PROT (1<<18) #define BOOTUTIL_CAP_ECDSA_P384 (1<<19) +#define BOOTUTIL_CAP_SWAP_USING_OFFSET (1<<20) /* * Query the number of images this bootloader is configured for. This diff --git a/boot/bootutil/src/boot_record.c b/boot/bootutil/src/boot_record.c index d6c235af9..cfaca2c82 100644 --- a/boot/bootutil/src/boot_record.c +++ b/boot/bootutil/src/boot_record.c @@ -249,6 +249,8 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are uint8_t mode = MCUBOOT_MODE_UPGRADE_ONLY; #elif defined(MCUBOOT_SWAP_USING_MOVE) uint8_t mode = MCUBOOT_MODE_SWAP_USING_MOVE; +#elif defined(MCUBOOT_SWAP_USING_OFFSET) + uint8_t mode = MCUBOOT_MODE_SWAP_USING_OFFSET; #elif defined(MCUBOOT_DIRECT_XIP) #if defined(MCUBOOT_DIRECT_XIP_REVERT) uint8_t mode = MCUBOOT_MODE_DIRECT_XIP_WITH_REVERT; diff --git a/boot/bootutil/src/bootutil_misc.c b/boot/bootutil/src/bootutil_misc.c index 56859d515..5d7c1b5d1 100644 --- a/boot/bootutil/src/bootutil_misc.c +++ b/boot/bootutil/src/bootutil_misc.c @@ -336,7 +336,7 @@ uint32_t bootutil_max_image_size(const struct flash_area *fap) #if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SINGLE_APPLICATION_SLOT) || \ defined(MCUBOOT_FIRMWARE_LOADER) || defined(MCUBOOT_SINGLE_APPLICATION_SLOT_RAM_LOAD) return boot_status_off(fap); -#elif defined(MCUBOOT_SWAP_USING_MOVE) +#elif defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_OFFSET) struct flash_sector sector; /* get the last sector offset */ int rc = flash_area_get_sector(fap, boot_status_off(fap), §or); diff --git a/boot/bootutil/src/caps.c b/boot/bootutil/src/caps.c index d7cd59042..f1cf63c15 100644 --- a/boot/bootutil/src/caps.c +++ b/boot/bootutil/src/caps.c @@ -45,6 +45,8 @@ uint32_t bootutil_get_caps(void) res |= BOOTUTIL_CAP_OVERWRITE_UPGRADE; #elif defined(MCUBOOT_SWAP_USING_MOVE) res |= BOOTUTIL_CAP_SWAP_USING_MOVE; +#elif defined(MCUBOOT_SWAP_USING_OFFSET) + res |= BOOTUTIL_CAP_SWAP_USING_OFFSET; #else res |= BOOTUTIL_CAP_SWAP_USING_SCRATCH; #endif diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c index 94ec0bfc6..99aa3a5e8 100644 --- a/boot/bootutil/src/loader.c +++ b/boot/bootutil/src/loader.c @@ -991,7 +991,7 @@ boot_validate_slot(struct boot_loader_state *state, int slot, if (boot_check_header_erased(state, slot) == 0 || (hdr->ih_flags & IMAGE_F_NON_BOOTABLE)) { -#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) +#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_OFFSET) /* * This fixes an issue where an image might be erased, but a trailer * be left behind. It can happen if the image is in the secondary slot @@ -1921,7 +1921,7 @@ boot_prepare_image_for_update(struct boot_loader_state *state, } #endif -#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) +#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_OFFSET) /* * Must re-read image headers because the boot status might * have been updated in the previous function call. @@ -2094,7 +2094,7 @@ static int check_downgrade_prevention(struct boot_loader_state *state) { #if defined(MCUBOOT_DOWNGRADE_PREVENTION) && \ - (defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_SCRATCH)) + (defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_OFFSET)) uint32_t security_counter[2]; int rc; diff --git a/boot/bootutil/src/swap_misc.c b/boot/bootutil/src/swap_misc.c index 733a39744..b1ce44119 100644 --- a/boot/bootutil/src/swap_misc.c +++ b/boot/bootutil/src/swap_misc.c @@ -30,7 +30,7 @@ BOOT_LOG_MODULE_DECLARE(mcuboot); -#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) +#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_OFFSET) int swap_erase_trailer_sectors(const struct boot_loader_state *state, const struct flash_area *fap) @@ -231,4 +231,4 @@ swap_set_image_ok(uint8_t image_index) } -#endif /* defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) */ +#endif /* defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_OFFSET) */ diff --git a/boot/bootutil/src/swap_priv.h b/boot/bootutil/src/swap_priv.h index 255e74736..13e18e38b 100644 --- a/boot/bootutil/src/swap_priv.h +++ b/boot/bootutil/src/swap_priv.h @@ -21,7 +21,7 @@ #include "mcuboot_config/mcuboot_config.h" -#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) +#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_OFFSET) /** * Calculates the amount of space required to store the trailer, and erases @@ -99,9 +99,9 @@ static inline size_t boot_scratch_area_size(const struct boot_loader_state *stat } #endif -#endif /* defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) */ +#endif /* defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_OFFSET) */ -#if defined(MCUBOOT_SWAP_USING_MOVE) +#if defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_OFFSET) /** * Check if device write block sizes are as expected, function should emit an error if there is * a problem. If true is returned, the slots are marked as compatible, otherwise the slots are