Skip to content

Commit

Permalink
only call nvm_select_fresh_sector on internal partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbland1 committed Aug 15, 2023
1 parent 20184d2 commit d08ed5c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/libwolfboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,16 @@ static uint8_t* RAMFUNCTION get_trailer_at(uint8_t part, uint32_t at)
{
uint8_t *ret = NULL;
uint32_t sel_sec = 0;
#ifdef NVM_FLASH_WRITEONCE
sel_sec = nvm_select_fresh_sector(part);
#endif
if (part == PART_BOOT) {
if (FLAGS_BOOT_EXT()){
ext_flash_check_read(PART_BOOT_ENDFLAGS - (sizeof(uint32_t) + at),
(void *)&ext_cache, sizeof(uint32_t));
ret = (uint8_t *)&ext_cache;
} else {
/* only internal flash should be writeonce */
#ifdef NVM_FLASH_WRITEONCE
sel_sec = nvm_select_fresh_sector(part);
#endif
ret = (void *)(PART_BOOT_ENDFLAGS -
(WOLFBOOT_SECTOR_SIZE * sel_sec + (sizeof(uint32_t) + at)));
}
Expand All @@ -287,6 +288,10 @@ static uint8_t* RAMFUNCTION get_trailer_at(uint8_t part, uint32_t at)
(void *)&ext_cache, sizeof(uint32_t));
ret = (uint8_t *)&ext_cache;
} else {
/* only internal flash should be writeonce */
#ifdef NVM_FLASH_WRITEONCE
sel_sec = nvm_select_fresh_sector(part);
#endif
ret = (void *)(PART_UPDATE_ENDFLAGS -
(WOLFBOOT_SECTOR_SIZE * sel_sec + (sizeof(uint32_t) + at)));
}
Expand Down

0 comments on commit d08ed5c

Please sign in to comment.