Skip to content

Commit

Permalink
Fix offset updating trailer: swap_and_final_erase
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danielinux committed Dec 6, 2024
1 parent 21a4082 commit 2f5b764
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/update_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down

0 comments on commit 2f5b764

Please sign in to comment.