|
40 | 40 |
|
41 | 41 | /* Network updates can be signed with "--id 2" and placed into the normal update partition, |
42 | 42 | * or they can be placed into the external flash at offset 0x100000 */ |
| 43 | +/* Partition ID should be set HDR_IMG_TYPE_APP=2 */ |
43 | 44 | #ifndef PART_NET_ID |
44 | | -#define PART_NET_ID 2 |
| 45 | +#ifdef HDR_IMG_TYPE_APP |
| 46 | + #define PART_NET_ID HDR_IMG_TYPE_APP |
| 47 | +#else |
| 48 | + #define PART_NET_ID 2 /* default */ |
| 49 | +#endif |
45 | 50 | #endif |
| 51 | + |
| 52 | +/* Offset in external QSPI flash for network update |
| 53 | + * Comes from nrf5340_net.config WOLFBOOT_PARTITION_UPDATE_ADDRESS) */ |
46 | 54 | #ifndef PART_NET_ADDR |
47 | 55 | #define PART_NET_ADDR 0x100000UL |
48 | 56 | #endif |
@@ -244,14 +252,8 @@ void RAMFUNCTION hal_flash_lock(void) |
244 | 252 | /* calculates location in shared memory */ |
245 | 253 | static uintptr_t ext_flash_addr_calc(uintptr_t address) |
246 | 254 | { |
247 | | - if (address >= WOLFBOOT_PARTITION_UPDATE_ADDRESS) { |
248 | | - if (address >= WOLFBOOT_PARTITION_SWAP_ADDRESS) { |
249 | | - address -= WOLFBOOT_PARTITION_SWAP_ADDRESS; |
250 | | - } |
251 | | - else { /* update */ |
252 | | - address -= WOLFBOOT_PARTITION_UPDATE_ADDRESS; |
253 | | - } |
254 | | - } |
| 255 | + /* offset external flash addresses by the update partition address */ |
| 256 | + address -= WOLFBOOT_PARTITION_UPDATE_ADDRESS; |
255 | 257 | /* check address */ |
256 | 258 | if (address >= (FLASH_SIZE_NET + FLASH_PAGESZ_NET)) { |
257 | 259 | address = 0; |
@@ -456,6 +458,9 @@ static void hal_net_check_version(void) |
456 | 458 | wolfBoot_verify_authenticity(&img) == 0) |
457 | 459 | { |
458 | 460 | wolfBoot_printf("Network image valid, loading into shared mem\n"); |
| 461 | + /* initialize remainder of shared memory with 0xFF (erased) */ |
| 462 | + memset(shm->data + shm->app.size, FLASH_BYTE_ERASED, |
| 463 | + sizeof(shm->data) - shm->app.size); |
459 | 464 | /* relocate image to shared ram */ |
460 | 465 | #ifdef EXT_FLASH |
461 | 466 | ret = ext_flash_read(PART_NET_ADDR, shm->data, shm->app.size); |
|
0 commit comments