Skip to content

Commit 3ef8c60

Browse files
twcook86danielinux
authored andcommitted
Fix XMEMSET's per correct erased byte polarity.
1 parent 3b1ef9d commit 3ef8c60

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/libwolfboot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ static int RAMFUNCTION trailer_write(uint8_t part, uintptr_t addr, uint8_t val)
357357
addr_read = addr_align - (nvm_cached_sector * NVM_CACHE_SIZE);
358358
#ifdef NO_DIRECT_READ_OF_ERASED_SECTOR
359359
if (hal_flash_is_erased_at((uintptr_t)addr_read))
360-
XMEMSET(NVM_CACHE, 0xFF, NVM_CACHE_SIZE);
360+
XMEMSET(NVM_CACHE, FLASH_BYTE_ERASED, NVM_CACHE_SIZE);
361361
else
362362
#endif
363363
XMEMCPY(NVM_CACHE, (void*)addr_read, NVM_CACHE_SIZE);
@@ -406,7 +406,7 @@ static int RAMFUNCTION partition_magic_write(uint8_t part, uintptr_t addr)
406406
addr_write = base - (!nvm_cached_sector * NVM_CACHE_SIZE);
407407
#ifdef NO_DIRECT_READ_OF_ERASED_SECTOR
408408
if (hal_flash_is_erased_at((uintptr_t)addr_read))
409-
XMEMSET(NVM_CACHE, 0xFF, NVM_CACHE_SIZE);
409+
XMEMSET(NVM_CACHE, FLASH_BYTE_ERASED, NVM_CACHE_SIZE);
410410
else
411411
#endif
412412
XMEMCPY(NVM_CACHE, (void*)addr_read, NVM_CACHE_SIZE);
@@ -868,7 +868,7 @@ void RAMFUNCTION wolfBoot_update_trigger(void)
868868
selSec = nvm_select_fresh_sector(PART_UPDATE);
869869
# ifdef NO_DIRECT_READ_OF_ERASED_SECTOR
870870
if (hal_flash_is_erased_at((uintptr_t)lastSector - WOLFBOOT_SECTOR_SIZE * selSec))
871-
XMEMSET(NVM_CACHE, 0xFF, WOLFBOOT_SECTOR_SIZE);
871+
XMEMSET(NVM_CACHE, FLASH_BYTE_ERASED, WOLFBOOT_SECTOR_SIZE);
872872
else
873873
# endif
874874
XMEMCPY(NVM_CACHE, (uint8_t*)lastSector - WOLFBOOT_SECTOR_SIZE * selSec,

src/update_flash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static int RAMFUNCTION wolfBoot_swap_and_final_erase(int resume)
449449
#else
450450
# ifdef NO_DIRECT_READ_OF_ERASED_SECTOR
451451
if (hal_flash_is_erased_at((uintptr_t)(boot->hdr + tmpBootPos)))
452-
memset(tmpBuffer, 0xFF, sizeof(tmpBuffer));
452+
memset(tmpBuffer, FLASH_BYTE_ERASED, sizeof(tmpBuffer));
453453
else
454454
# endif
455455
memcpy(tmpBuffer, boot->hdr + tmpBootPos, sizeof(tmpBuffer));

0 commit comments

Comments
 (0)