Skip to content

[nrf fromtree] bootutil: loader: overwrite-only mode fix for trailer erase #452

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2116,19 +2116,19 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
* trailer that was left might trigger a new upgrade.
*/
BOOT_LOG_DBG("erasing secondary header");
rc = boot_erase_region(fap_secondary_slot,
boot_img_sector_off(state, BOOT_SECONDARY_SLOT, 0),
boot_img_sector_size(state, BOOT_SECONDARY_SLOT, 0), false);
rc = boot_scramble_region(fap_secondary_slot,
boot_img_sector_off(state, BOOT_SECONDARY_SLOT, 0),
boot_img_sector_size(state, BOOT_SECONDARY_SLOT, 0), false);
assert(rc == 0);
#endif

last_sector = boot_img_num_sectors(state, BOOT_SECONDARY_SLOT) - 1;
BOOT_LOG_DBG("erasing secondary trailer");
rc = boot_erase_region(fap_secondary_slot,
boot_img_sector_off(state, BOOT_SECONDARY_SLOT,
last_sector),
boot_img_sector_size(state, BOOT_SECONDARY_SLOT,
last_sector), false);
rc = boot_scramble_region(fap_secondary_slot,
boot_img_sector_off(state, BOOT_SECONDARY_SLOT,
last_sector),
boot_img_sector_size(state, BOOT_SECONDARY_SLOT,
last_sector), false);
assert(rc == 0);

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