From 2f5b7644e4da27383bb2e7a9f5b7fafc53ffef86 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Fri, 6 Dec 2024 07:59:37 +0100 Subject: [PATCH] Fix offset updating trailer: swap_and_final_erase When wolfBoot_swap_and_final_erase() is invoked, it was calculating the wrong offset, ending up erasing the third-last sector of the boot partition. This might cause erasing part of the firmware, eventually causing failed boot. --- src/update_flash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/update_flash.c b/src/update_flash.c index 20cc67cc0..694518eb7 100644 --- a/src/update_flash.c +++ b/src/update_flash.c @@ -218,8 +218,7 @@ static int wolfBoot_swap_and_final_erase(int resume) #endif ); int swapDone = 0; - uintptr_t tmpBootPos = WOLFBOOT_PARTITION_SIZE - eraseLen - - WOLFBOOT_SECTOR_SIZE; + uintptr_t tmpBootPos = WOLFBOOT_PARTITION_SIZE - eraseLen; uint32_t tmpBuffer[TRAILER_OFFSET_WORDS + 1]; /* open partitions (ignore failure) */