Skip to content

Commit 88163ad

Browse files
committed
stop the selSec from being applied twice to lastSector
1 parent 7008f68 commit 88163ad

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/libwolfboot.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,10 +763,11 @@ void RAMFUNCTION wolfBoot_update_trigger(void)
763763
hal_flash_erase(lastSector, SECTOR_FLAGS_SIZE);
764764
#else
765765
selSec = nvm_select_fresh_sector(PART_UPDATE);
766-
lastSector -= selSec * WOLFBOOT_SECTOR_SIZE;
767-
XMEMCPY(NVM_CACHE, (uint8_t*)lastSector, WOLFBOOT_SECTOR_SIZE);
766+
XMEMCPY(NVM_CACHE, (uint8_t*)lastSector - WOLFBOOT_SECTOR_SIZE * selSec,
767+
WOLFBOOT_SECTOR_SIZE);
768768
/* write to the non selected sector */
769-
hal_flash_erase(lastSector - WOLFBOOT_SECTOR_SIZE * !selSec, WOLFBOOT_SECTOR_SIZE);
769+
hal_flash_erase(lastSector - WOLFBOOT_SECTOR_SIZE * !selSec,
770+
WOLFBOOT_SECTOR_SIZE);
770771
hal_flash_write(lastSector - WOLFBOOT_SECTOR_SIZE * !selSec, NVM_CACHE,
771772
WOLFBOOT_SECTOR_SIZE);
772773
/* erase the previously selected sector */

0 commit comments

Comments
 (0)