Commit 4af73169 authored by Jamie McCrae's avatar Jamie McCrae Committed by Jamie
Browse files

boot: bootutil: Add swap using offset algorithm



Adds a new variation of the swap using move mode, named swap using
offset, whereby instead of moving all the sectors in the primary
image, the sectors in the secondary image are offset instead. This
fastens image swapping time both for updates and reverts as each
sector in both slots is erased only once, which also reduces flash
wear, and uses less swap status bits to represent

Signed-off-by: default avatarJamie McCrae <jamie.mccrae@nordicsemi.no>
parent 2fe9cd4b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 {
+2 −0
Original line number Diff line number Diff line
@@ -90,6 +90,8 @@ struct boot_loader_state;
void boot_state_clear(struct boot_loader_state *state);
fih_ret context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp);
const struct image_max_size *boot_get_max_app_size(void);
uint32_t boot_get_state_secondary_offset(struct boot_loader_state *state,
                                         const struct flash_area *fap);

#define SPLIT_GO_OK                 (0)
#define SPLIT_GO_NON_MATCHING       (-1)
+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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
+3 −0
Original line number Diff line number Diff line
@@ -211,6 +211,9 @@ struct image_tlv_iter {
    uint32_t prot_end;
    uint32_t tlv_off;
    uint32_t tlv_end;
#if defined(MCUBOOT_SWAP_USING_OFFSET)
    uint32_t start_off;
#endif
};

int bootutil_tlv_iter_begin(struct image_tlv_iter *it,
Loading