Netcore DFU over BLE by using external flash on nRF5340DK. Nordic SDK v2.8.0.

I am evaluating external flash on nRF5340DK. When I'm doing appcore DFU from external flash so that mcuboot_secondary and settings_storage are located on external flash, everything works fine. Now I try to make DFU also for netcore (mcuboot_secondary_1 located on external flash), it fails to error message "Failed to open flash area ID 1: -2". Error message comes from function int img_mgmt_erased_val(int slot, uint8_t *erased_val), located in file v2.8.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c.

It tries to open flash area ID #1, but memory area table has only following ID's: 0,2,3,4,5,6,7,8,9,10,12. For some reason ID's 1 and 11 are missing and flash area open fails. I have tried to swap  mcuboot_secondary and mcuboot_secondary_1 order in external flash, but netcore DFU (area mcuboot_secodary_1) always fails, physical address does not matter. Is there something wrong in my configuration?

pm_static.yml:

EMPTY_0:
address: 0xfa000
end_address: 0xfc000
placement:
after:
- tfm_otp_nv_counters
region: flash_primary
size: 0x2000
EMPTY_1:
address: 0xf6000
end_address: 0xf8000
placement:
after:
- tfm_its
region: flash_primary
size: 0x2000
app:
address: 0x24000
end_address: 0xf4000
region: flash_primary
size: 0xd0000
external_flash:
address: 0x130000
end_address: 0x800000
region: external_flash
size: 0x6d0000
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:
align:
start: 0x4000
before:
- mcuboot_primary_app
region: flash_primary
size: 0x200
mcuboot_primary:
address: 0xc000
end_address: 0xf4000
orig_span: &id001
- app
- mcuboot_pad
- tfm
region: flash_primary
size: 0xe8000
span: *id001
mcuboot_primary_1:
address: 0x0
device: nordic_ram_flash_controller
end_address: 0x40000
region: ram_flash
size: 0x40000
mcuboot_primary_app:
address: 0xc200
end_address: 0xf4000
orig_span: &id002
- app
- tfm
region: flash_primary
size: 0xe7e00
span: *id002
mcuboot_secondary:
address: 0x8000
device: DT_CHOSEN(nordic_pm_ext_flash)
end_address: 0xf0000
placement:
align:
start: 0x4
region: external_flash
share_size:
- mcuboot_primary
size: 0xe8000
mcuboot_secondary_1:
address: 0xf0000
device: DT_CHOSEN(nordic_pm_ext_flash)
end_address: 0x130000
region: external_flash
size: 0x40000
mcuboot_sram:
address: 0x20000000
end_address: 0x20046000
orig_span: &id003
- pcd_sram
- tfm_sram
region: sram_primary
size: 0x46000
span: *id003
otp:
address: 0xff8100
end_address: 0xff83fc
region: otp
size: 0x2fc
pcd_sram:
address: 0x20000000
end_address: 0x20002000
placement:
before:
- tfm_sram
region: sram_primary
size: 0x2000
ram_flash:
address: 0x40000
end_address: 0x40000
region: ram_flash
size: 0x0
rpmsg_nrf53_sram:
address: 0x20070000
end_address: 0x20080000
placement:
before:
- end
region: sram_primary
size: 0x10000
settings_storage:
address: 0x0
device: DT_CHOSEN(nordic_pm_ext_flash)
end_address: 0x8000
placement:
before:
- tfm_storage
- end
region: external_flash
size: 0x8000
sram_nonsecure:
address: 0x20032000
end_address: 0x20080000
orig_span: &id004
- sram_primary
- rpmsg_nrf53_sram
region: sram_primary
size: 0x4e000
span: *id004
sram_primary:
address: 0x20032000
end_address: 0x20070000
region: sram_primary
size: 0x3e000
sram_secure:
address: 0x20000000
end_address: 0x20032000
orig_span: &id005
- pcd_sram
- tfm_sram
region: sram_primary
size: 0x32000
span: *id005
tfm:
address: 0xc200
end_address: 0x24000
inside:
- mcuboot_primary_app
placement:
before:
- app
region: flash_primary
size: 0x17e00
tfm_its:
address: 0xf4000
end_address: 0xf6000
inside:
- tfm_storage
placement:
align:
start: 0x4000
before:
- tfm_otp_nv_counters
region: flash_primary
size: 0x2000
tfm_nonsecure:
address: 0x24000
end_address: 0xf4000
orig_span: &id006
- app
region: flash_primary
size: 0xd0000
span: *id006
tfm_otp_nv_counters:
address: 0xf8000
end_address: 0xfa000
inside:
- tfm_storage
placement:
align:
start: 0x4000
before:
- tfm_ps
region: flash_primary
size: 0x2000
tfm_ps:
address: 0xfc000
end_address: 0x100000
inside:
- tfm_storage
placement:
align:
start: 0x4000
before:
- end
region: flash_primary
size: 0x4000
tfm_secure:
address: 0xc000
end_address: 0x24000
orig_span: &id007
- mcuboot_pad
- tfm
region: flash_primary
size: 0x18000
span: *id007
tfm_sram:
address: 0x20002000
end_address: 0x20032000
inside:
- sram_secure
placement:
after:
- start
region: sram_primary
size: 0x30000
tfm_storage:
address: 0xf4000
end_address: 0x100000
orig_span: &id008
- tfm_ps
- tfm_its
- tfm_otp_nv_counters
region: flash_primary
size: 0xc000
span: *id008

sysbuild.conf:

# Build MCUboot image
SB_CONFIG_BOOTLOADER_MCUBOOT=y
# Set MCUboot signature type to ECDSA-P256
SB_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
# Build MCUboot and application in overwrite only mode
SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y
# Places the secondary MCUboot update partition in external flash
SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
# nRF Connect SDK ipc_radio image
SB_CONFIG_NETCORE_IPC_RADIO=y
# Enable network core image update support in MCUboot (PCD)
SB_CONFIG_NETCORE_APP_UPDATE=y
# Enable secure boot for network core
SB_CONFIG_SECURE_BOOT_NETCORE=y
prj.conf:
# Enable point to point DFU over SMP
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y

# Use the default configuration for NCS samples
CONFIG_NCS_SAMPLES_DEFAULTS=y

# Enable RTT terminal
CONFIG_LOG=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=n

# General configuration
CONFIG_NCS_APPLICATION_BOOT_BANNER_STRING="Test Name
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_HWINFO=y
CONFIG_DK_LIBRARY=y
CONFIG_PM_SINGLE_IMAGE=y
CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE=y

# Use settings on external flash
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_NVS_LOOKUP_CACHE=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS_NAME_CACHE=y
CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y
CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x8000

# Bluetooth configuration
CONFIG_BT=y
CONFIG_BT_DEVICE_NAME="Test Name"
CONFIG_BT_L2CAP_TX_BUF_COUNT=8

CONFIG_BT_OBSERVER=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_SETTINGS=n

# Increase RX stack size to avoid overflow during provisioning
CONFIG_BT_RX_STACK_SIZE=2700

# Enable Extended Advertiser to advertise BT SMP service
CONFIG_BT_EXT_ADV=y
CONFIG_BT_EXT_ADV_MAX_ADV_SET=6

# One extra connection for mesh GATT/proxy and one for SMP BT.
CONFIG_BT_MAX_CONN=3

# One extra identity for SMP service
CONFIG_BT_ID_MAX=2

# Disable unused Bluetooth features
CONFIG_BT_CTLR_LE_ENC=n
CONFIG_BT_PHY_UPDATE=n
CONFIG_BT_CTLR_CHAN_SEL_2=n
CONFIG_BT_CTLR_MIN_USED_CHAN=n
CONFIG_BT_CTLR_PRIVACY=n

# Bluetooth Mesh configuration
CONFIG_BT_MESH=y
CONFIG_BT_MESH_RELAY=y
CONFIG_BT_MESH_FRIEND=n
CONFIG_BT_MESH_TX_SEG_MAX=10
CONFIG_BT_MESH_PB_GATT=n
CONFIG_BT_MESH_GATT_PROXY=n
CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME=n
CONFIG_BT_MESH_DK_PROV=y
app.overlay:
/ {
  chosen {
    nordic,pm-ext-flash = &mx25r64;
  };
};
sysbuild/mcuboot/prj.conf:
CONFIG_PM=n

CONFIG_MAIN_STACK_SIZE=10240
CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"

CONFIG_BOOT_SWAP_SAVE_ENCTLV=n
CONFIG_BOOT_ENCRYPT_IMAGE=n

CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_BOOT_BOOTSTRAP=n

### mbedTLS has its own heap
# CONFIG_HEAP_MEM_POOL_SIZE is not set

### We never want Zephyr's copy of tinycrypt. If tinycrypt is needed,
### MCUboot has its own copy in tree.
# CONFIG_TINYCRYPT is not set
# CONFIG_TINYCRYPT_ECC_DSA is not set
# CONFIG_TINYCRYPT_SHA256 is not set

CONFIG_FLASH=y
CONFIG_FPROTECT=y

### Various Zephyr boards enable features that we don't want.
# CONFIG_BT is not set
# CONFIG_BT_CTLR is not set
# CONFIG_I2C is not set

CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y # former CONFIG_MODE_MINIMAL
### Ensure Zephyr logging changes don't use more resources
CONFIG_LOG_DEFAULT_LEVEL=0
### Use info log level by default
CONFIG_MCUBOOT_LOG_LEVEL_INF=y
### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y
CONFIG_CBPRINTF_NANO=y
### Use the minimal C library to reduce flash usage
CONFIG_MINIMAL_LIBC=y
CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=0

# NCS boot banner
CONFIG_NCS_APPLICATION_BOOT_BANNER_STRING="MCUboot"

# Set QSPI flash layout configuration
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16

CONFIG_BOOT_MAX_IMG_SECTORS=256
sysbuild/mcuboot/app.overlay:
/ {
  chosen {
    nordic,pm-ext-flash = &mx25r64;
  };
};
Parents
  • Hi,

    ID 1 is assigned to the mcuboot_primary_1 partition residing in RAM, which MCUBoot uses this simulated flash partition to transfer FW updates to the network core. But this partition is not accessible from the app, hence the error message when mcumgr iterates through all the slots. It should be safe to ignore though. Is DFU failing in your case? If so, please try to run the attached sample below on your board and see if you get the same result.

    dfu_samples_v2.8.0.zip

    Thanks,

    Vidar

Reply
  • Hi,

    ID 1 is assigned to the mcuboot_primary_1 partition residing in RAM, which MCUBoot uses this simulated flash partition to transfer FW updates to the network core. But this partition is not accessible from the app, hence the error message when mcumgr iterates through all the slots. It should be safe to ignore though. Is DFU failing in your case? If so, please try to run the attached sample below on your board and see if you get the same result.

    dfu_samples_v2.8.0.zip

    Thanks,

    Vidar

Children
No Data
Related