@@ -1327,11 +1327,17 @@ int wolfBoot_verify_integrity(struct wolfBoot_image *img)
13271327 return 0 ;
13281328}
13291329
1330- #ifdef ELF_SCATTERED
1330+ #ifdef WOLFBOOT_ELF_SCATTERED
13311331#include "elf.h"
13321332
13331333#define PADDING_BLOCK_SIZE 64
13341334
1335+ #ifdef ARCH_SIM
1336+ #define BASE_OFF ARCH_FLASH_OFFSET
1337+ #else
1338+ #define BASE_OFF 0
1339+ #endif
1340+
13351341int elf_check_image_scattered (uint8_t part , unsigned long * entry_out )
13361342{
13371343 /* Open the partition containing the image */
@@ -1448,12 +1454,12 @@ int elf_check_image_scattered(uint8_t part, unsigned long *entry_out)
14481454 wolfBoot_printf ("Feeding stored segment, len %d\n" , len );
14491455 while (len > 0 ) {
14501456 if (len > WOLFBOOT_SHA_BLOCK_SIZE ) {
1451- update_hash (& ctx , (void * )(paddr + ARCH_FLASH_OFFSET ),
1457+ update_hash (& ctx , (void * )(paddr + BASE_OFF ),
14521458 WOLFBOOT_SHA_BLOCK_SIZE );
14531459 len -= WOLFBOOT_SHA_BLOCK_SIZE ;
14541460 paddr += WOLFBOOT_SHA_BLOCK_SIZE ;
14551461 } else {
1456- update_hash (& ctx , (void * )(paddr + ARCH_FLASH_OFFSET ),
1462+ update_hash (& ctx , (void * )(paddr + BASE_OFF ),
14571463 len );
14581464 break ;
14591465 }
@@ -1532,12 +1538,12 @@ int elf_check_image_scattered(uint8_t part, unsigned long *entry_out)
15321538 wolfBoot_printf ("Feeding stored segment, len %d\n" , len );
15331539 while (len > 0 ) {
15341540 if (len > WOLFBOOT_SHA_BLOCK_SIZE ) {
1535- update_hash (& ctx , (void * )(paddr + ARCH_FLASH_OFFSET ),
1541+ update_hash (& ctx , (void * )(paddr + BASE_OFF ),
15361542 WOLFBOOT_SHA_BLOCK_SIZE );
15371543 len -= WOLFBOOT_SHA_BLOCK_SIZE ;
15381544 paddr += WOLFBOOT_SHA_BLOCK_SIZE ;
15391545 } else {
1540- update_hash (& ctx , (void * )(paddr + ARCH_FLASH_OFFSET ),
1546+ update_hash (& ctx , (void * )(paddr + BASE_OFF ),
15411547 len );
15421548 break ;
15431549 }
@@ -1598,6 +1604,7 @@ int elf_check_image_scattered(uint8_t part, unsigned long *entry_out)
15981604 wolfBoot_printf ("Scattered ELF verified.\n" );
15991605 return 0 ;
16001606}
1607+ #undef BASE_OFF
16011608
16021609#endif
16031610
0 commit comments