Skip to content

Commit

Permalink
bootutil: Adapt swap offset for devices without erase
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Ermel <[email protected]>
  • Loading branch information
de-nordic committed Feb 3, 2025
1 parent ecf1ca0 commit 97e041a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions boot/bootutil/src/swap_offset.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ void fixup_revert(const struct boot_loader_state *state, struct boot_status *bs,
BOOT_LOG_SWAP_STATE("Secondary image", &swap_state);

if (swap_state.magic == BOOT_MAGIC_UNSET) {
rc = swap_erase_trailer_sectors(state, fap_sec);
rc = swap_scramble_trailer_sectors(state, fap_sec);
assert(rc == 0);

rc = boot_write_copy_done(fap_sec);
Expand Down Expand Up @@ -674,14 +674,14 @@ void swap_run(struct boot_loader_state *state, struct boot_status *bs,
int rc;

if (bs->source != BOOT_STATUS_SOURCE_PRIMARY_SLOT) {
rc = swap_erase_trailer_sectors(state, fap_pri);
rc = swap_scramble_trailer_sectors(state, fap_pri);
assert(rc == 0);

rc = swap_status_init(state, fap_pri, bs);
assert(rc == 0);
}

rc = swap_erase_trailer_sectors(state, fap_sec);
rc = swap_scramble_trailer_sectors(state, fap_sec);
assert(rc == 0);
}

Expand Down Expand Up @@ -715,10 +715,10 @@ void swap_run(struct boot_loader_state *state, struct boot_status *bs,
* status is not wrongly used as a valid header. Also erase the trailer in the secondary
* to allow for a future update to be loaded
*/
rc = boot_erase_region(fap_sec, boot_img_sector_off(state, BOOT_SECONDARY_SLOT, 0),
sector_sz);
rc = boot_scramble_region(fap_sec, boot_img_sector_off(state, BOOT_SECONDARY_SLOT, 0),
sector_sz);
assert(rc == 0);
rc = swap_erase_trailer_sectors(state, fap_sec);
rc = swap_scramble_trailer_sectors(state, fap_sec);
assert(rc == 0);
} else {
while (idx <= last_idx) {
Expand Down

0 comments on commit 97e041a

Please sign in to comment.