Skip to content

Commit

Permalink
fix bad address copy if base is not the same as addr_read
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbland1 committed Aug 15, 2023
1 parent db032d1 commit 171d19b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libwolfboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static int RAMFUNCTION partition_magic_write(uint8_t part, uintptr_t addr)
nvm_cached_sector = nvm_select_fresh_sector(part);
addr_read = base - (nvm_cached_sector * NVM_CACHE_SIZE);
addr_write = base - (!nvm_cached_sector * NVM_CACHE_SIZE);
XMEMCPY(NVM_CACHE, (void*)base, NVM_CACHE_SIZE);
XMEMCPY(NVM_CACHE, (void*)addr_read, NVM_CACHE_SIZE);
XMEMCPY(NVM_CACHE + off, &wolfboot_magic_trail, sizeof(uint32_t));
ret = hal_flash_write(addr_write, NVM_CACHE, WOLFBOOT_SECTOR_SIZE);
nvm_cached_sector = !nvm_cached_sector;
Expand Down

0 comments on commit 171d19b

Please sign in to comment.