Skip to content

Commit ff68021

Browse files
committed
bootutil: swap-move: Update maximum size to allow unaligned trailers
This commit updates the computation of the maximum firmware image size for the swap-move strategy to allow the first sector containing part of the trailer to also hold firmware data. This means it is no more necessary to allocate a sector-aligned area for the trailer when using swap-move, the area to allocate is now simply equal to the maximum trailer size. Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
1 parent 5f22ef6 commit ff68021

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

boot/bootutil/src/bootutil_misc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,14 @@ uint32_t bootutil_max_image_size(struct boot_loader_state *state, const struct f
477477
}
478478

479479
return slot_trailer_off - trailer_padding;
480-
#elif defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_OFFSET)
480+
#elif defined(MCUBOOT_SWAP_USING_MOVE)
481+
(void) fap;
482+
483+
const struct flash_area *fap_pri = BOOT_IMG_AREA(state, BOOT_PRIMARY_SLOT);
484+
assert(fap_pri != NULL);
485+
486+
return boot_status_off(fap_pri) - boot_img_sector_size(state, BOOT_PRIMARY_SLOT, 0);
487+
#elif defined(MCUBOOT_SWAP_USING_OFFSET)
481488
(void) state;
482489

483490
struct flash_sector sector;

0 commit comments

Comments
 (0)