From 7330df7c783b0da75190459860257fc9f758fd50 Mon Sep 17 00:00:00 2001 From: Thomas Altenbach Date: Sat, 22 Feb 2025 02:02:20 +0100 Subject: [PATCH] boot: bootutil: Fix last sector index computation for swap-offset When using swap-offset, the index of the last sector of the primary slot that have to be swapped is computed at the beginning of the upgrade process. This computation was in fact returning the number of sector to swap rather than the index of the last sectpr (so N+1 instead of N). This was causing the upgrade to fail for large image, using all the available sectors. Signed-off-by: Thomas Altenbach --- boot/bootutil/src/swap_offset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/bootutil/src/swap_offset.c b/boot/bootutil/src/swap_offset.c index c7df0c0da..2a63ee863 100644 --- a/boot/bootutil/src/swap_offset.c +++ b/boot/bootutil/src/swap_offset.c @@ -68,10 +68,10 @@ uint32_t find_last_idx(struct boot_loader_state *state, uint32_t swap_size) while (1) { sz += sector_sz; - last_idx++; if (sz >= swap_size) { break; } + last_idx++; } return last_idx;