1515#include "bootutil/fault_injection_hardening.h"
1616#include "flash_map_backend/flash_map_backend.h"
1717
18- #define NET_CORE_SECONDARY_SLOT 1
18+ #if CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER != -1
19+ /* Sysbuild */
20+ /* MCUboot image update image number */
21+ #define NET_CORE_SECONDARY_IMAGE CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER
22+ /* MCUboot serial recovery slot number */
23+ #define NET_CORE_VIRTUAL_PRIMARY_SLOT (CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER * 2) + 1
24+ #else
25+ /* Legacy child/parent */
26+ #define NET_CORE_SECONDARY_IMAGE 1
1927#define NET_CORE_VIRTUAL_PRIMARY_SLOT 3
28+ #endif
2029
2130#include <dfu/pcd.h>
2231#if defined(CONFIG_PCD_APP ) && defined(CONFIG_NRF53_MULTI_IMAGE_UPDATE ) \
@@ -53,7 +62,6 @@ int pcd_version_cmp_net(const struct flash_area *fap, struct image_header *hdr)
5362
5463 firmware_info = fw_info_find ((uint32_t )& read_buf );
5564 if (firmware_info != NULL ) {
56-
5765 if (firmware_info -> version > version ) {
5866 return 1 ;
5967 }
@@ -71,7 +79,7 @@ int pcd_version_cmp_net(const struct flash_area *fap, struct image_header *hdr)
7179
7280int boot_read_image_header_hook (int img_index , int slot , struct image_header * img_head )
7381{
74- if (img_index == 1 && slot == 0 ) {
82+ if (img_index == NET_CORE_SECONDARY_IMAGE && slot == 0 ) {
7583 img_head -> ih_magic = IMAGE_MAGIC ;
7684 img_head -> ih_hdr_size = PM_MCUBOOT_PAD_SIZE ;
7785 img_head -> ih_load_addr = PM_MCUBOOT_PRIMARY_1_ADDRESS ;
@@ -90,7 +98,7 @@ int boot_read_image_header_hook(int img_index, int slot, struct image_header *im
9098
9199fih_ret boot_image_check_hook (int img_index , int slot )
92100{
93- if (img_index == 1 && slot == 0 ) {
101+ if (img_index == NET_CORE_SECONDARY_IMAGE && slot == 0 ) {
94102 FIH_RET (FIH_SUCCESS );
95103 }
96104
@@ -106,7 +114,7 @@ int boot_perform_update_hook(int img_index, struct image_header *img_head,
106114int boot_read_swap_state_primary_slot_hook (int image_index ,
107115 struct boot_swap_state * state )
108116{
109- if (image_index == 1 ) {
117+ if (image_index == NET_CORE_SECONDARY_IMAGE ) {
110118 /* Populate with fake data */
111119 state -> magic = BOOT_MAGIC_UNSET ;
112120 state -> swap_type = BOOT_SWAP_TYPE_NONE ;
@@ -160,7 +168,7 @@ int network_core_update(bool wait)
160168int boot_copy_region_post_hook (int img_index , const struct flash_area * area ,
161169 size_t size )
162170{
163- if (img_index == NET_CORE_SECONDARY_SLOT ) {
171+ if (img_index == NET_CORE_SECONDARY_IMAGE ) {
164172 return network_core_update (true);
165173 }
166174
0 commit comments