Skip to content

Commit

Permalink
Merge pull request wolfSSL#351 from jpbland1/bad-last-sector-address-fix
Browse files Browse the repository at this point in the history
handle case where PART_UPDATE_ENDFLAGS % WOLFBOOT_SECTOR_SIZE == 0
  • Loading branch information
dgarske authored Aug 22, 2023
2 parents 6bb05d5 + ed68b46 commit ee628f1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/libwolfboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,13 @@ void RAMFUNCTION wolfBoot_update_trigger(void)
#if defined(NVM_FLASH_WRITEONCE) || defined(WOLFBOOT_FLAGS_INVERT)
uintptr_t lastSector = PART_UPDATE_ENDFLAGS -
(PART_UPDATE_ENDFLAGS % WOLFBOOT_SECTOR_SIZE);

#ifndef FLAGS_HOME
/* if PART_UPDATE_ENDFLAGS stradles a sector, (all non FLAGS_HOME builds)
* align it to the correct sector */
if (PART_UPDATE_ENDFLAGS % WOLFBOOT_SECTOR_SIZE == 0)
lastSector -= WOLFBOOT_SECTOR_SIZE;
#endif
#endif
#ifdef NVM_FLASH_WRITEONCE
uint8_t selSec = 0;
Expand Down

0 comments on commit ee628f1

Please sign in to comment.