Skip to content

Commit

Permalink
New OVERWRITE_ONLY_KEEP_BACKUP option
Browse files Browse the repository at this point in the history
It builds on top of OVERWRITE_ONLY mode and uses secondary slot
as a backup of the primary slot. The main difference is that after
image copy to the primary slot the secondary slot is not erased.
This is meant to be used together with BOOTSTRAP option that will
reinstall the primary image with the backup in case it's not valid.

Signed-off-by: Petr Buchta <[email protected]>
  • Loading branch information
PetrBuchtaNXP authored and d3zd3z committed Apr 5, 2024
1 parent a65ea49 commit c5a528b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,7 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
}
#endif /* MCUBOOT_HW_ROLLBACK_PROT */

#ifndef MCUBOOT_OVERWRITE_ONLY_KEEP_BACKUP
/*
* Erases header and trailer. The trailer is erased because when a new
* image is written without a trailer as is the case when using newt, the
Expand All @@ -1460,6 +1461,8 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
boot_img_sector_off(state, BOOT_SECONDARY_SLOT, 0),
boot_img_sector_size(state, BOOT_SECONDARY_SLOT, 0));
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,
Expand Down

0 comments on commit c5a528b

Please sign in to comment.