Skip to content

Commit bb644c7

Browse files
nordic-mik7nvlsianpu
authored andcommitted
bootutil: loader: overwrite-only mode fix for trailer erase
This fixes issues when trying to erase secondary slot trailer for platforms with MCUBOOT_SUPPORT_DEV_WITHOUT_ERASE set from flash driver. Calling explicitly to 'scramble' region ensures we delete the trailer. Signed-off-by: Michal Kozikowski <[email protected]>
1 parent 11982df commit bb644c7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

boot/bootutil/src/loader.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,19 +1687,19 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
16871687
* trailer that was left might trigger a new upgrade.
16881688
*/
16891689
BOOT_LOG_DBG("erasing secondary header");
1690-
rc = boot_erase_region(fap_secondary_slot,
1691-
boot_img_sector_off(state, BOOT_SECONDARY_SLOT, 0),
1692-
boot_img_sector_size(state, BOOT_SECONDARY_SLOT, 0), false);
1690+
rc = boot_scramble_region(fap_secondary_slot,
1691+
boot_img_sector_off(state, BOOT_SECONDARY_SLOT, 0),
1692+
boot_img_sector_size(state, BOOT_SECONDARY_SLOT, 0), false);
16931693
assert(rc == 0);
16941694
#endif
16951695

16961696
last_sector = boot_img_num_sectors(state, BOOT_SECONDARY_SLOT) - 1;
16971697
BOOT_LOG_DBG("erasing secondary trailer");
1698-
rc = boot_erase_region(fap_secondary_slot,
1699-
boot_img_sector_off(state, BOOT_SECONDARY_SLOT,
1700-
last_sector),
1701-
boot_img_sector_size(state, BOOT_SECONDARY_SLOT,
1702-
last_sector), false);
1698+
rc = boot_scramble_region(fap_secondary_slot,
1699+
boot_img_sector_off(state, BOOT_SECONDARY_SLOT,
1700+
last_sector),
1701+
boot_img_sector_size(state, BOOT_SECONDARY_SLOT,
1702+
last_sector), false);
17031703
assert(rc == 0);
17041704

17051705
/* TODO: Perhaps verify the primary slot's signature again? */

0 commit comments

Comments
 (0)