Skip to content

bootutil: swap-scratch: Fix conflicts after support of device without erase #2255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions boot/bootutil/src/swap_scratch.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ boot_swap_sectors(int idx, uint32_t sz, struct boot_loader_state *state,
* trailer since in case the trailer spreads over multiple sector erasing the [img_off,
* img_off + sz) might not erase the entire trailer.
*/
rc = swap_erase_trailer_sectors(state, fap_secondary_slot);
rc = swap_scramble_trailer_sectors(state, fap_secondary_slot);
assert(rc == 0);

if (bs->use_scratch) {
Expand All @@ -691,14 +691,6 @@ boot_swap_sectors(int idx, uint32_t sz, struct boot_loader_state *state,
img_off, img_off, copy_sz);
assert(rc == 0);

if (bs->idx == BOOT_STATUS_IDX_0 && !bs->use_scratch) {
/* If not all sectors of the slot are being swapped,
* guarantee here that only the primary slot will have the state.
*/
rc = swap_scramble_trailer_sectors(state, fap_secondary_slot);
assert(rc == 0);
}

rc = boot_write_status(state, bs);
bs->state = BOOT_STATUS_STATE_2;
BOOT_STATUS_ASSERT(rc == 0);
Expand All @@ -713,7 +705,7 @@ boot_swap_sectors(int idx, uint32_t sz, struct boot_loader_state *state,
* able to write the new trailer. This is not always equivalent to erasing the [img_off,
* img_off + sz) range when the trailer spreads across multiple sectors.
*/
rc = swap_erase_trailer_sectors(state, fap_primary_slot);
rc = swap_scramble_trailer_sectors(state, fap_primary_slot);
assert(rc == 0);

/* Ensure the sector(s) containing the beginning of the trailer won't be erased twice */
Expand Down
Loading