Skip to content

Commit

Permalink
Merge pull request #339 from jpbland1/address-fix
Browse files Browse the repository at this point in the history
fix bad address copy if base is not the same as addr_read
  • Loading branch information
dgarske authored Aug 15, 2023
2 parents 059d0f8 + 171d19b commit 98cbde7
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 98cbde7

Please sign in to comment.