From 6e7d2214807073239dd7af509c5b06cf3f40a43b Mon Sep 17 00:00:00 2001 From: Michal Kozikowski Date: Fri, 8 Aug 2025 16:42:15 +0200 Subject: [PATCH] [nrf fromtree] bootutil: Fix scratch scrambling This commit fixes the scrambling of the scratch area after persisting a trailer to the primary slot. Previous use of boot_erase_region() didn't guarantee that the scratch area is scrambled, as it only erases memory for devices that selects CONFIG_MCUBOOT_STORAGE_WITH_ERASE. Signed-off-by: Michal Kozikowski (cherry picked from commit 800868a951dd6042ba11de6d056dad5e76bbf738) --- boot/bootutil/src/swap_scratch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/bootutil/src/swap_scratch.c b/boot/bootutil/src/swap_scratch.c index 360dbe88c..6581b55a6 100644 --- a/boot/bootutil/src/swap_scratch.c +++ b/boot/bootutil/src/swap_scratch.c @@ -926,7 +926,7 @@ boot_swap_sectors(int idx, uint32_t sz, struct boot_loader_state *state, * happens then the scratch which is partially erased would be wrote back to the * primary slot, causing a corrupt unbootable image */ - rc = boot_erase_region(fap_scratch, 0, flash_area_get_size(fap_scratch), true); + rc = boot_scramble_region(fap_scratch, 0, flash_area_get_size(fap_scratch), true); assert(rc == 0); } }