Skip to content

Commit f803fe6

Browse files
committed
bootutil: swap-scratch: Fix conflicts after support of devices w/o erase
Before the PR #2206 fixing issues in the swap-scratch logic when the trailer is larger than the last sector was merged, the PR #2114 was reverted (see #2211). This changes made by #2211 were then reapplied (see #2216) after #2206 was merged, leading to some conflicts: a call to swap_erase_trailer_sectors was moved by #2206 but the old call to that function was added back by #2216 and a new call to swap_erase_trailer_sectors was added by #2206 but not converted to a call to swap_scramble_trailer_sectors by #2216.
1 parent 572b8fb commit f803fe6

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

boot/bootutil/src/swap_scratch.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ boot_swap_sectors(int idx, uint32_t sz, struct boot_loader_state *state,
665665
* trailer since in case the trailer spreads over multiple sector erasing the [img_off,
666666
* img_off + sz) might not erase the entire trailer.
667667
*/
668-
rc = swap_erase_trailer_sectors(state, fap_secondary_slot);
668+
rc = swap_scramble_trailer_sectors(state, fap_secondary_slot);
669669
assert(rc == 0);
670670

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

694-
if (bs->idx == BOOT_STATUS_IDX_0 && !bs->use_scratch) {
695-
/* If not all sectors of the slot are being swapped,
696-
* guarantee here that only the primary slot will have the state.
697-
*/
698-
rc = swap_scramble_trailer_sectors(state, fap_secondary_slot);
699-
assert(rc == 0);
700-
}
701-
702694
rc = boot_write_status(state, bs);
703695
bs->state = BOOT_STATUS_STATE_2;
704696
BOOT_STATUS_ASSERT(rc == 0);
@@ -713,7 +705,7 @@ boot_swap_sectors(int idx, uint32_t sz, struct boot_loader_state *state,
713705
* able to write the new trailer. This is not always equivalent to erasing the [img_off,
714706
* img_off + sz) range when the trailer spreads across multiple sectors.
715707
*/
716-
rc = swap_erase_trailer_sectors(state, fap_primary_slot);
708+
rc = swap_scramble_trailer_sectors(state, fap_primary_slot);
717709
assert(rc == 0);
718710

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

0 commit comments

Comments
 (0)