Skip to content

Commit

Permalink
boot: bootutil: Fix last sector index computation for swap-offset
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
taltenbach authored and nordicjm committed Feb 24, 2025
1 parent 429e2fe commit 7330df7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion boot/bootutil/src/swap_offset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7330df7

Please sign in to comment.