Skip to content

Commit 7330df7

Browse files
taltenbachnordicjm
authored andcommitted
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 <[email protected]>
1 parent 429e2fe commit 7330df7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

boot/bootutil/src/swap_offset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ uint32_t find_last_idx(struct boot_loader_state *state, uint32_t swap_size)
6868

6969
while (1) {
7070
sz += sector_sz;
71-
last_idx++;
7271
if (sz >= swap_size) {
7372
break;
7473
}
74+
last_idx++;
7575
}
7676

7777
return last_idx;

0 commit comments

Comments
 (0)