Skip to content

Commit

Permalink
stop the selSec from being applied twice to lastSector
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbland1 committed Dec 23, 2024
1 parent 7008f68 commit 88163ad
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libwolfboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,11 @@ void RAMFUNCTION wolfBoot_update_trigger(void)
hal_flash_erase(lastSector, SECTOR_FLAGS_SIZE);
#else
selSec = nvm_select_fresh_sector(PART_UPDATE);
lastSector -= selSec * WOLFBOOT_SECTOR_SIZE;
XMEMCPY(NVM_CACHE, (uint8_t*)lastSector, WOLFBOOT_SECTOR_SIZE);
XMEMCPY(NVM_CACHE, (uint8_t*)lastSector - WOLFBOOT_SECTOR_SIZE * selSec,
WOLFBOOT_SECTOR_SIZE);
/* write to the non selected sector */
hal_flash_erase(lastSector - WOLFBOOT_SECTOR_SIZE * !selSec, WOLFBOOT_SECTOR_SIZE);
hal_flash_erase(lastSector - WOLFBOOT_SECTOR_SIZE * !selSec,
WOLFBOOT_SECTOR_SIZE);
hal_flash_write(lastSector - WOLFBOOT_SECTOR_SIZE * !selSec, NVM_CACHE,
WOLFBOOT_SECTOR_SIZE);
/* erase the previously selected sector */
Expand Down

0 comments on commit 88163ad

Please sign in to comment.