nrf5340 + QSPI NOR, mcuboot Failed to open flash area ID 1 (image 0 slot 1): -19, cannot continue

Hi Nordic Team

We develop a sensor node for a customer based on nRF5340. For now I use a nRF5340DK to do my tests with NCS 2.8.0 (using VS Code).

Based on examples, I am trying to get mcuboot + img manager to work with the secondary slot in the external flash, as I know that the final FW image will be to large if we don't put the secondary slots in the external QSPI. Updating the hci_rpc firmware on the netcore is not required at the moment, but would be nice to have.

Here are the most improtant files.

sysbuild.conf:

SB_CONFIG_BOOTLOADER_MCUBOOT=y
SB_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
SB_CONFIG_BOOT_SIGNATURE_KEY_FILE="\${APPLICATION_CONFIG_DIR}/priv.pem"
SB_CONFIG_MCUBOOT_UPDATEABLE_IMAGES=1

SB_CONFIG_NETCORE_HCI_IPC=y

SB_CONFIG_PARTITION_MANAGER=y
SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
SB_CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y

prj.conf:

CONFIG_GPIO=y

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="mcu-test"
#CONFIG_BT_FIXED_PASSKEY=y

CONFIG_BOOTLOADER_MCUBOOT=y

CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

CONFIG_NORDIC_QSPI_NOR=y


CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y

CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

mcuboot.conf:

CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y

CONFIG_NORDIC_QSPI_NOR=y

# Enable flash operations
CONFIG_FLASH=y


# enable to get log output on uart
CONFIG_LOG=y
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_SERIAL=y
CONFIG_LOG_BACKEND_UART=y 

CONFIG_FLASH_LOG_LEVEL_DBG=y
CONFIG_MCUBOOT_LOG_LEVEL_DBG=y

dt.overlay:

/ {
    chosen {
      nordic,pm-ext-flash = &mx25r64;
    };
};

Connecting to /dev/ttyACM1 with 115200 I can see mcuboot starting, but it fails to access the flash:

[00:00:00.397,155] <dbg> qspi_nor: configure_chip: RDSR 40 QE 1 need 1: no-change
*** Booting MCUboot v2.1.0-dev-4594a8693738 ***
*** Using nRF Connect SDK v2.8.0-a2386bfc8401 ***
*** Using Zephyr OS v3.7.99-0bc3393fb112 ***
[00:00:00.417,572] <inf> mcuboot: Starting bootloader
[00:00:00.423,065] <err> mcuboot: Failed to open flash area ID 1 (image 0 slot 1): -19, cannot continue

My first suspect was the communication with the external QSPI, but that seems to be OK, reading the QE bit appears to work. (see above).

After some debugging, I suspect an issue with v2.8.0/nrf/subsys/partition_manager/flash_map_partition_manager.c which defines const struct flash_area *flash_map.
My debugging suggests that some entries in flash_map have .fa_dev = NULL.

Am I missing some configuration settings or is this some other problem?

Thank's for your support!

mcuboot-test.zip

Parents
  • Hi Amanda

    Thank you for sharing this example. Is there a special setting required in the build config?

    When I try to build it, TFM fails to compile:

    -- Build files have been written to: /home/lukas/Downloads/peripheral_key/build/peripheral_key/tfm
    [112/139] Building C object secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/target/nordic_nrf/common/core/target_cfg.o
    FAILED: secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/target/nordic_nrf/common/core/target_cfg.o 
    /home/lukas/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DBL1_HEADER_SIZE=0x000 -DBL1_TRAILER_SIZE=0x000 -DBL2_HEADER_SIZE=0x000 -DBL2_TRAILER_SIZE=0x000 -DCONFIG_NFCT_PINS_AS_GPIOS -DCONFIG_TFM_FLOAT_ABI=0 -DCONFIG_TFM_HALT_ON_CORE_PANIC -DCONFIG_TFM_USE_TRUSTZONE -DCRYPTO_HW_ACCELERATOR -DDAUTH_CHIP_DEFAULT -DINSIDE_TFM_BUILD -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE=\"nrf-psa-crypto-config.h\" -DMBEDTLS_PSA_CRYPTO_DRIVERS -DMCUBOOT_IMAGE_NUMBER=1 -DNRF5340_XXAA_APPLICATION -DNRF53_SERIES -DNRF_ALLOW_NON_SECURE_FAULT_HANDLING -DNRF_ALLOW_NON_SECURE_RESET -DNRF_HW_INIT_NRF_PERIPHERALS -DNRF_HW_INIT_RESET_ON_BOOT -DNRF_NS_SECONDARY -DNRF_NS_STORAGE -DNRF_SECURE_UART_INSTANCE=1 -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DPLATFORM_DEFAULT_BL1 -DPLATFORM_NS_NV_COUNTERS=0 -DPROJECT_CONFIG_HEADER_FILE=\"/home/lukas/Downloads/peripheral_key/build/peripheral_key/modules/nrf/modules/trusted-firmware-m/tfm_config.h\" -DPS_CRYPTO_AEAD_ALG_GCM -DPS_ENCRYPTION -DSECURE_UART1 -DTFM_EXCEPTION_INFO_DUMP -DTFM_FIH_PROFILE_OFF -DTFM_INTERNAL_TRUSTED_STORAGE_SERVICE_SID=0x00000070 -DTFM_ISOLATION_LEVEL=1 -DTFM_PARTITION_CRYPTO -DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_SILENCE -DTFM_PARTITION_NS_AGENT_TZ -DTFM_PARTITION_PLATFORM -DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_INFO -DTFM_SPM_LOG_RAW_ENABLED -D__NRF_TFM__ -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/spm -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/spm/include -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/spm/core -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/include -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/lib/runtime -I/home/lukas/Downloads/peripheral_key/build/peripheral_key/tfm/generated -I/home/lukas/Downloads/peripheral_key/build/peripheral_key/tfm/generated/secure_fw/spm/include -I/home/lukas/Downloads/peripheral_key/build/peripheral_key/tfm/generated/secure_fw/spm/core -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/spm/core/arch -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/spm/include/boot -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/spm/include/interface -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/. -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/native_drivers -I/home/lukas/ncs/v2.8.0/modules/hal/nordic/nrfx -I/home/lukas/ncs/v2.8.0/modules/hal/nordic/nrfx/mdk -I/home/lukas/ncs/v2.8.0/modules/hal/nordic/nrfx/drivers/include -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/common -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/.. -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/services/include -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/nrf5340/. -I/home/lukas/ncs/v2.8.0/nrf/modules/trusted-firmware-m/tfm_boards/include -I/home/lukas/ncs/v2.8.0/nrf/modules/trusted-firmware-m/tfm_boards/partition -I/home/lukas/Downloads/peripheral_key/build/peripheral_key/tfm/../zephyr/include/generated -I/home/lukas/ncs/v2.8.0/nrf/modules/trusted-firmware-m/tfm_boards/board -I/home/lukas/Downloads/peripheral_key/build/peripheral_key/tfm/../zephyr/misc/generated/syscalls_links/include -I/home/lukas/ncs/v2.8.0/zephyr/include -I/home/lukas/ncs/v2.8.0/nrf/modules/trusted-firmware-m/tfm_boards/services/include -I/home/lukas/ncs/v2.8.0/nrf/include -I/home/lukas/ncs/v2.8.0/nrf/include/tfm -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/accelerator/interface -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/../secure_fw/spm/include/private -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/common -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/driver -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/include -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/config -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/crypto -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/firmware_update -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/initial_attestation -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/internal_trusted_storage -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/platform -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/protected_storage -I/home/lukas/Downloads/peripheral_key/build/peripheral_key/tfm/generated/interface/include -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/crypto/../../../platform/include -I/home/lukas/Downloads/peripheral_key/build/peripheral_key/generated/interface_nrf_security_psa -I/home/lukas/ncs/v2.8.0/nrf/subsys/nrf_security/include -I/home/lukas/ncs/v2.8.0/modules/crypto/oberon-psa-crypto/include -I/home/lukas/ncs/v2.8.0/nrf/subsys/nrf_security/src/utils -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/lib/fih/inc -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/cmsis/CMSIS/Core/Include -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/cmsis/CMSIS/Core/Include/m-profile -I/home/lukas/Downloads/peripheral_key/build/peripheral_key/tfm/generated/secure_fw/partitions/crypto -I/home/lukas/Downloads/peripheral_key/build/peripheral_key/tfm/generated/secure_fw/partitions/platform -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/lib/runtime/include -I/home/lukas/ncs/v2.8.0/modules/crypto/oberon-psa-crypto/library -I/home/lukas/ncs/v2.8.0/modules/crypto/mbedtls/library -I/home/lukas/ncs/v2.8.0/modules/crypto/mbedtls/include -I/home/lukas/ncs/v2.8.0/modules/crypto/mbedtls/include/library -I/home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/interface/include -mcpu=cortex-m33+nofp -Os -DNDEBUG -specs=nano.specs -specs=nosys.specs -Wall -Wno-format -Wno-return-type -Wno-unused-but-set-variable -c -fdata-sections -ffunction-sections -fno-builtin -fshort-enums -funsigned-char -mthumb -std=c99 -gdwarf-4 -g -mfloat-abi=soft -mcmse -Wno-unused-value -include /home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/include/cmsis_override.h -MD -MT secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/target/nordic_nrf/common/core/target_cfg.o -MF secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/target/nordic_nrf/common/core/target_cfg.o.d -o secure_fw/spm/CMakeFiles/tfm_spm.dir/__/__/platform/ext/target/nordic_nrf/common/core/target_cfg.o -c /home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/target_cfg.c
    In file included from /home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/target_cfg.h:36,
                     from /home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/target_cfg.c:18:
    /home/lukas/ncs/v2.8.0/nrf/modules/trusted-firmware-m/tfm_boards/partition/region_defs.h:26:45: error: 'PM_MCUBOOT_SECONDARY_ADDRESS' undeclared here (not in a function); did you mean 'PM_MCUBOOT_END_ADDRESS'?
       26 | #define S_IMAGE_SECONDARY_PARTITION_OFFSET (PM_MCUBOOT_SECONDARY_ADDRESS)
          |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/lukas/ncs/v2.8.0/nrf/modules/trusted-firmware-m/tfm_boards/partition/region_defs.h:102:36: note: in expansion of macro 'S_IMAGE_SECONDARY_PARTITION_OFFSET'
      102 | #define SECONDARY_PARTITION_START (S_IMAGE_SECONDARY_PARTITION_OFFSET)
          |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/lukas/ncs/v2.8.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/target_cfg.c:763:33: note: in expansion of macro 'SECONDARY_PARTITION_START'
      763 |     .secondary_partition_base = SECONDARY_PARTITION_START,
          |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~
    [122/139] Building C object platform/CMakeFiles/platform_s.dir/home/lukas/ncs/v2.8.0/modules/hal/nordic/nrfx/drivers/src/nrfx_uarte.o
    ninja: build stopped: subcommand failed.

    BR,
    Lukas

  • Hi, 

    Duplicate board/nrf5340dk_nrf5340_cpuapp.conf and overlay for nrf5340dk_nrf5340_cpuapp_ns and add  SB_CONFIG_MCUBOOT_USE_ALL_AVAILABLE_RAM=y to the sysbuild.conf. 

    -Amanda H.

Reply Children
No Data
Related