I am using a custom board with a nrf5340 and vs code with sdk/toolchain version 3.0.2 and trying to get mcuboot working for FOTA. I have been stepping through mcuboot with my segger and have breakpoints in mcuboot/main.c

I am using dynamic partitioning as recommended.
The error is happening on the second pass through this code within context_boot_go in loader.c:
for (slot = 0; slot < BOOT_NUM_SLOTS; slot++) {
fa_id = flash_area_id_from_multi_image_slot(image_index, slot);
rc = flash_area_open(fa_id, &BOOT_IMG_AREA(state, slot));
assert(rc == 0);
if (rc != 0) {
BOOT_LOG_ERR("Failed to open flash area ID %d (image %d slot %d): %d, "
"cannot continue", fa_id, image_index, (int8_t)slot, rc);
FIH_PANIC;
}
}
- slot = 1
- flash_map_entries = 5
- fa_id = 6
which calls:
int flash_area_open(uint8_t id, const struct flash_area **fap)
{
const struct flash_area *area;
if (flash_map == NULL) {
return -EACCES;
}
area = get_flash_area_from_id(id);
if (area == NULL) {
return -ENOENT;
}
if (!device_is_ready(area->fa_dev)) {
return -ENODEV;
}
*fap = area;
return 0;
}
- id = 6
which calls flash_map_priv.h:
static inline struct flash_area const *get_flash_area_from_id(int idx)
{
for (int i = 0; i < flash_map_entries; i++) {
if (flash_map[i].fa_id == idx) {
return &flash_map[i];
}
}
return NULL;
}
- i=4
- flash_map[i].fa_id = 5
This call returns a -2:
rc = flash_area_open(fa_id, &BOOT_IMG_AREA(state, slot));
- slot = 1
and finally dies on this call in nrf53_cpunet_mgmt.c
static void onoff_stop(struct onoff_manager *mgr, onoff_notify_fn notify)
{
nrf_reset_network_force_off(NRF_RESET, true);
notify(mgr, 0);
}
Here is the flash:
When I have SB_CONFIG_BOOTLOADER_MCUBOOT=n it runs
I have read Simultaneous updates for both cores of the nRF5340, but get errors when I get to:
# STEP 7.2 - Add b0n image SB_CONFIG_SECURE_BOOT_NETCORE=y
the error is:
In file included from /opt/nordic/ncs/v3.0.2/nrf/include/dfu/pcd.h:28,
from /opt/nordic/ncs/v3.0.2/bootloader/mcuboot/boot/zephyr/main.c:96:
/opt/nordic/ncs/v3.0.2/nrf/include/dfu/pcd_common.h: In function 'pcd_write_cmd_lock_debug':
/opt/nordic/ncs/v3.0.2/nrf/include/dfu/pcd_common.h:39:25: error: 'PM__PCD_SRAM_ADDRESS' undeclared (first use in this function); did you mean 'PM_SRAM_ADDRESS'?
I have also looked at Exercise 5 – FOTA over Bluetooth Low Energy and loosly followed it, but there are a lot of differences with my using a custom board and spi external flash.
My regions.yml looks like this when I build successfully:
external_flash: base_address: 0x0 default_driver_kconfig: CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK device: DT_CHOSEN(nordic_pm_ext_flash) dynamic_partition: null name: external_flash placement_strategy: start_to_end size: 0x1000000 flash_primary: base_address: 0x0 default_driver_kconfig: CONFIG_SOC_FLASH_NRF device: flash_controller dynamic_partition: null name: flash_primary placement_strategy: complex size: 0x100000 otp: base_address: 0xff8100 default_driver_kconfig: '' device: '' dynamic_partition: null name: otp placement_strategy: start_to_end size: 0x2fc sram_primary: base_address: 0x20000000 default_driver_kconfig: '' device: '' dynamic_partition: sram_primary name: sram_primary placement_strategy: complex size: 0x80000
and my partitions.yml look like this:
app:
address: 0xc200
end_address: 0x100000
region: flash_primary
size: 0xf3e00
external_flash:
address: 0xcf4000
end_address: 0x1000000
region: external_flash
size: 0x30c000
littlefs_storage:
address: 0x0
device: DT_CHOSEN(nordic_pm_ext_flash)
end_address: 0xc00000
placement:
before:
- tfm_storage
- end
region: external_flash
size: 0xc00000
mcuboot:
address: 0x0
end_address: 0xc000
placement:
align:
end: 0x1000
before:
- mcuboot_primary
region: flash_primary
size: 0xc000
mcuboot_pad:
address: 0xc000
end_address: 0xc200
placement:
before:
- mcuboot_primary_app
region: flash_primary
size: 0x200
mcuboot_primary:
address: 0xc000
end_address: 0x100000
orig_span: &id001
- mcuboot_pad
- app
region: flash_primary
size: 0xf4000
span: *id001
mcuboot_primary_app:
address: 0xc200
end_address: 0x100000
orig_span: &id002
- app
region: flash_primary
size: 0xf3e00
span: *id002
mcuboot_secondary:
address: 0xc00000
device: DT_CHOSEN(nordic_pm_ext_flash)
end_address: 0xcf4000
placement:
align:
start: 0x4
region: external_flash
share_size:
- mcuboot_primary
size: 0xf4000
otp:
address: 0xff8100
end_address: 0xff83fc
region: otp
size: 0x2fc
rpmsg_nrf53_sram:
address: 0x20070000
end_address: 0x20080000
placement:
before:
- end
region: sram_primary
size: 0x10000
sram_primary:
address: 0x20000000
end_address: 0x20070000
region: sram_primary
size: 0x70000





