PM_Static with MCU_Boot and external Flash

Hello and thanks for reading. I am working with the NRF5340DK and Zephyr (SDK 2.5.0).

As our project has grown, we can no longer fit all our code and MCU boot in the internal flash. Seeing as the DK has an external flash chip on QSPI, we figured we would use that to store our code.

We started out with the example provided in the developer academy, and that worked well.

It seemed wasteful, however, to have 8K of flash and to only use ~1K, keeping the second MCUBOOT image on the NRF5340's internal flash.

Also, our code has kept growing, so we decided to try and put both the primary and secondary slots for MCUBOOT on the external flash, with two images of 4K each.

This is leading to problems with setting up our PM_Static.yml, and I was hopeful you could take a look and help us figure out what we are doing wrong.

Here is my PM_Static.yml right now:

# Custom NVS storage partition (flash_primary)
custom_nvs_storage:
  address: 0x00000
  size: 0x2000  # 8 KB
  region: flash_primary

# Settings storage partition (flash_primary)
settings_storage:
  address: 0x2000
  size: 0x2000  # 8 KB
  region: flash_primary

# External QSPI Flash (8 MB)
qspi_flash:
  address: 0x0
  region: external_flash
  size: 0x800000  # 8 MB

# mcuboot partitions in QSPI flash (external flash)
mcuboot_primary:
  address: 0x0
  size: 0x400000  # 4 MB
  region: qspi_flash

mcuboot_secondary:
  address: 0x400000
  size: 0x400000  # 4 MB
  region: qspi_flash

And here are the relevant error messages:

-- Found partition manager static configuration: C:/Users/foo/Documents/GitHub/foo/pm_static.yml
Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_secondary' is not included in the dynamic resolving since it is statically defined.
Partition manager failed: End of last partition is after last valid address
Failed to partition region flash_primary, size of region: 1048576
Partition Configuration:
custom_nvs_storage:
  size: 8192
mcuboot:
  placement: {}
  size: 49152
mcuboot_pad:
  placement:
    before:
    - mcuboot_primary_app
  size: 512
settings_storage:
  size: 8192

And here are the project configs in case that helps you:

MCUBoot project config:

CONFIG_FLASH=y

CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
# CONFIG_BOOT_SIGNATURE_KEY_FILE="dev_ec256_priv.pem"
CONFIG_MAIN_STACK_SIZE=10240
CONFIG_MULTITHREADING=y

CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y

CONFIG_BOOT_ENCRYPT_IMAGE=y
# CONFIG_BOOT_ENCRYPTION_KEY_FILE="dev_ec256_priv.pem"

#clock config
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

CONFIG_SOC_HFXO_CAP_EXTERNAL=n
CONFIG_SOC_HFXO_CAP_INTERNAL=y
CONFIG_SOC_HFXO_CAP_INT_VALUE_X2=16

#Code protection
CONFIG_NRF_APPROTECT_LOCK=y

CONFIG_NORDIC_QSPI_NOR=y
CONFIG_BOOT_MAX_IMG_SECTORS=512

mcuboot overlay:

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

prj.conf

#GPIO
CONFIG_GPIO=y
CONFIG_PINCTRL=y

#UART & SERIAL & system
CONFIG_SERIAL=y
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y

CONFIG_MAIN_STACK_SIZE=8192
CONFIG_LOG=y
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192

CONFIG_TIMESLICING=y

#CPP
CONFIG_CPP=y
CONFIG_REQUIRES_FULL_LIBCPP=y
CONFIG_STD_CPP20=y

#i2C
CONFIG_I2C=y

#spi
CONFIG_SPI=y

#usb
CONFIG_USB_DEVICE_VID=0xC0FF
CONFIG_USB_DEVICE_PID=0xA55A


#flash
CONFIG_SETTINGS=y
CONFIG_BT_SETTINGS_CCC_STORE_ON_WRITE=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_NVS=y
CONFIG_FLASH_MAP=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FILE_SYSTEM=y
CONFIG_SOC_FLASH_NRF=y
CONFIG_NORDIC_QSPI_NOR=y

#PM
CONFIG_PARTITION_MANAGER_ENABLED=y

#math
CONFIG_CMSIS_DSP=y
CONFIG_CMSIS_DSP_SVM=y
CONFIG_NEWLIB_LIBC=y
CONFIG_FPU=y
# CONFIG_CMSIS_DSP_TRANSFORM=y
# CONFIG_TFM_ENABLE_CP10CP11=y
CONFIG_CMSIS_DSP_FILTERING=y

#BLE
CONFIG_BT=y
CONFIG_BT_BONDABLE=n #dont need bonding for HID, get rid of it.
CONFIG_BT_SETTINGS=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_BROADCASTER=y
CONFIG_BT_OBSERVER=y

CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=30

#NUS
CONFIG_BT_NUS=y
CONFIG_BT_NUS_AUTHEN=n

#BT BATTERY SERVICE (BAS)
CONFIG_BT_BAS=y

#DIS
CONFIG_BT_DIS=y #all non-pnp DIS settings are done dynamically
CONFIG_BT_DIS_PNP=n
CONFIG_SETTINGS_RUNTIME=y
CONFIG_BT_DIS_SETTINGS=y

CONFIG_BT_DIS_MODEL="foo"
CONFIG_BT_DIS_MANUF="foo"
CONFIG_BT_DIS_SERIAL_NUMBER=y
CONFIG_BT_DIS_FW_REV=y
CONFIG_BT_DIS_HW_REV=y
CONFIG_BT_DIS_SW_REV=y
CONFIG_BT_DIS_SERIAL_NUMBER_STR="xxxxxxxx"
CONFIG_BT_DIS_FW_REV_STR="0"
CONFIG_BT_DIS_HW_REV_STR="0"
CONFIG_BT_DIS_SW_REV_STR="0"

#BT HID
CONFIG_NCS_SAMPLES_DEFAULTS=y

CONFIG_BT_MAX_CONN=6
CONFIG_BT_SMP=y
CONFIG_BT_L2CAP_TX_BUF_COUNT=5
CONFIG_BT_DEVICE_APPEARANCE=962

CONFIG_BT_HIDS=y
CONFIG_BT_HIDS_MAX_CLIENT_COUNT=2
CONFIG_BT_HIDS_DEFAULT_PERM_RW_ENCRYPT=y
CONFIG_BT_GATT_UUID16_POOL_SIZE=40
CONFIG_BT_GATT_CHRC_POOL_SIZE=20

CONFIG_BT_CONN_CTX=y

#2MEG PHY & MTU
CONFIG_BT_AUTO_PHY_UPDATE=n
# CONFIG_BT_CTLR_PHY_2M=y
# CONFIG_BT_AUTO_PHY_UPDATE=y
# CONFIG_BT_USER_PHY_UPDATE=y

CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_L2CAP_TX_MTU=247

CONFIG_BT_ATT_PREPARE_COUNT=4
CONFIG_BT_CONN_TX_MAX=10
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y


CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=24
CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400

#ADC
CONFIG_ADC=y
CONFIG_ADC_ASYNC=y

#timer
CONFIG_COUNTER=y

CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y 
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y 
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y 
CONFIG_SOC_HFXO_CAP_EXTERNAL=n 
CONFIG_SOC_HFXO_CAP_INTERNAL=y 
CONFIG_SOC_HFXO_CAP_INT_VALUE_X2=16 
CONFIG_BOOTLOADER_MCUBOOT=y 
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y 
CONFIG_BT_MAX_PAIRED=1 
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y 

Parents
  • Hello,

    Also, our code has kept growing, so we decided to try and put both the primary and secondary slots for MCUBOOT on the external flash, with two images of 4K each.

    Executing code from external flash will cause a performance penalty (processing speed and power consumption). Also, support for running the whole app from xip is not implemented. However, it should be possible to use XiP for parts of the application code by following the instructions provided in the documentation here: https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/nrf/device_guides/working_with_nrf/nrf53/qspi_xip_guide.html 

    Best regards,

    Vidar

  • Hello,

    Thank you for your reply. I have followed the link you provided, and also the documentation I found here: https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/app_dev/bootloaders_dfu/qspi_xip_split_image.html

    I seem to have encountered a new problem however, in that

    CONFIG_XIP_SPLIT_IMAGE=y

    Is not recognized.

    warning: attempt to assign the value 'y' to the undefined symbol XIP_SPLIT_IMAGE

    error: Aborting due to Kconfig warnings

    Is this an issue because we are using 2.5.0?

    As a further experiment, I tried commenting out just that line and rebuilding. I get a different error, instead I see:

    [206/618] Building C object zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/zephyr_img_mgmt.c.obj
    FAILED: zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/zephyr_img_mgmt.c.obj
    C:\ncs\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DADC_BATTERY_CHANNEL=5 -DADC_EXTERNAL_DIVIDER=2 -DARM_ALL_FAST_TABLES -DARM_DSP_CONFIG_TABLES -DARM_FAST_ALLOW_TABLES -DARM_FFT_ALLOW_TABLES -DARM_TABLE_RECIP_Q15 -DARM_TABLE_RECIP_Q31 -DARM_TABLE_SIN_F32 -DARM_TABLE_SIN_Q15 -DARM_TABLE_SIN_Q31 -DCENTER_CURSOR_ON_INACTIVITY_FLAG -DCPU_NRF5340=1 -DDEVICE_NAME_STRING="\"Glasses PCB\"" -DHEAD_MOVEMENT_THRESHOLD=1 -DKERNEL -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DN_ACTIVE_CHANNELS=4 -DPD_CHANNEL_ONEHOT=0x33 -DSCROLL_OFFSET=0 -DUSE_PARTITION_MANAGER=1 -DUSING_DEV_KEY -DZCBOR_ASSERTS -D_ANSI_SOURCE -D_FORTIFY_SOURCE=1 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/include -IC:/ncs/v2.5.0/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.5.0/zephyr/soc/arm/nordic_nrf/nrf53 -IC:/ncs/v2.5.0/zephyr/lib/libc/newlib/include -IC:/ncs/v2.5.0/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/util/include -IC:/ncs/v2.5.0/bootloader/mcuboot/boot/bootutil/include -IC:/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/transport/include -IC:/ncs/v2.5.0/bootloader/mcuboot/boot/zephyr/include -IC:/ncs/v2.5.0/zephyr/subsys/bluetooth -IC:/ncs/v2.5.0/zephyr/subsys/settings/include -IC:/ncs/v2.5.0/nrf/include -IC:/ncs/v2.5.0/nrf/tests/include -IC:/ncs/v2.5.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.5.0/modules/hal/cmsis/CMSIS/DSP/Include -IC:/ncs/v2.5.0/zephyr/modules/cmsis/. -IC:/ncs/v2.5.0/modules/hal/nordic/nrfx -IC:/ncs/v2.5.0/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.5.0/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.5.0/zephyr/modules/hal_nordic/nrfx/. -Imodules/libmetal/libmetal/lib/include -IC:/ncs/v2.5.0/modules/lib/open-amp/open-amp/lib/include -IC:/ncs/v2.5.0/modules/crypto/tinycrypt/lib/include -IC:/ncs/v2.5.0/modules/lib/zcbor/include -IC:/ncs/v2.5.0/nrfxlib/softdevice_controller/include -IC:/ncs/v2.5.0/bootloader/mcuboot/boot/bootutil/zephyr/.. -IC:/ncs/v2.5.0/bootloader/mcuboot/boot/bootutil/zephyr/../include -IC:/ncs/v2.5.0/bootloader/mcuboot/boot/bootutil/zephyr/../../zephyr/include -isystem C:/ncs/v2.5.0/nrfxlib/crypto/nrf_cc312_platform/include -Wshadow -fno-strict-aliasing -Os -imacros C:/Users/foo/Documents/GitHub/foo_V4/Earbud_V4_5/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mfp16-format=ieee --sysroot=C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.5.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/Users/foo/Documents/GitHub/foo_V4=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.5.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.5.0=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/zephyr_img_mgmt.c.obj -MF zephyr\subsys\mgmt\mcumgr\grp\img_mgmt\CMakeFiles\subsys__mgmt__mcumgr__grp__img_mgmt.dir\src\zephyr_img_mgmt.c.obj.d -o zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/zephyr_img_mgmt.c.obj -c C:/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c
    In file included from C:/ncs/v2.5.0/zephyr/include/zephyr/toolchain.h:50,
                     from C:/ncs/v2.5.0/zephyr/include/zephyr/kernel_includes.h:19,
                     from C:/ncs/v2.5.0/zephyr/include/zephyr/kernel.h:17,
                     from C:/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:7:
    C:/ncs/v2.5.0/zephyr/include/zephyr/toolchain/gcc.h:81:36: error: static assertion failed: "Missing partitions?"
       81 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
          |                                    ^~~~~~~~~~~~~~
    C:/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:44:1: note: in expansion of macro 'BUILD_ASSERT'
       44 | BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT4_PARTITION) &&
          | ^~~~~~~~~~~~
    [214/618] Building C object zephyr/subsys/fs/CMakeFiles/subsys__fs.dir/fs.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\Users\foo\Documents\GitHub\foo_V4\Earbud_V4_5'

    My relevant files at this point:

    Added to prj.config:

    #XIP
    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_CODE_DATA_RELOCATION=y
    CONFIG_HAVE_CUSTOM_LINKER_SCRIPT=y
    CONFIG_BUILD_NO_GAP_FILL=y
    CONFIG_XIP=y
    CONFIG_NORDIC_QSPI_NOR_XIP=y
    # CONFIG_XIP_SPLIT_IMAGE=y
    CONFIG_CUSTOM_LINKER_SCRIPT="linker_file_for_relocation.ld"
    CONFIG_UPDATEABLE_IMAGE_NUMBER=3
    CONFIG_FLASH_INIT_PRIORITY=40

    Added to mcuboot prj.config

    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_BOOT_MAX_IMG_SECTORS=256
    CONFIG_PARTITION_MANAGER_ENABLED=y
    CONFIG_XIP=y
    CONFIG_BOOT_DIRECT_XIP=y

    PM_Static.yml, almost exactly like this link here for XIP with no network core support but I added a little partition for my own code to use

    app:
      address: 0x10200
      end_address: 0x7a000
      region: flash_primary
      size: 0x69e00
    external_flash:
      address: 0x120000
      device: MX25R64
      end_address: 0x800000
      region: external_flash
      size: 0x6e0000
    mcuboot:
      address: 0x0
      end_address: 0x10000
      region: flash_primary
      size: 0x10000
    mcuboot_pad:
      address: 0x10000
      end_address: 0x10200
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x10000
      end_address: 0x7a000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      size: 0x6a000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0x7a000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x69e00
      span: *id002
    mcuboot_secondary_pad:
      address: 0x7a000
      end_address: 0x7a200
      region: flash_primary
      size: 0x200
    mcuboot_secondary:
      address: 0x7a000
      end_address: 0xe4000
      orig_span: &id003
      - mcuboot_secondary_pad
      - mcuboot_secondary_app
      region: flash_primary
      size: 0x6a000
      span: *id003
    mcuboot_secondary_app:
      address: 0x7a200
      end_address: 0xe4000
      region: flash_primary
      size: 0x69e00
    EMPTY_3:
      address: 0xe4000
      end_address: 0x100000
      region: flash_primary
      size: 0x1c000
    mcuboot_primary_1:
      address: 0x120000
      device: external_flash
      end_address: 0x160000
      orig_span: &id004
      - mcuboot_primary_1_pad
      - mcuboot_primary_1_app
      region: external_flash
      size: 0x40000
      span: *id004
    mcuboot_primary_1_pad:
      address: 0x120000
      end_address: 0x120200
      region: external_flash
      size: 0x200
    mcuboot_primary_1_app:
      address: 0x120200
      device: MX25R64
      end_address: 0x160000
      region: external_flash
      size: 0x3FE00
    mcuboot_secondary_1:
      address: 0xd4000
      device: MX25R64
      end_address: 0x114000
      region: external_flash
      size: 0x40000
    EMPTY_1:
      address: 0x0
      device: MX25R64
      end_address: 0xd4000
      region: external_flash
      size: 0xd4000
    EMPTY_2:
      address: 0x114000
      device: MX25R64
      end_address: 0x120000
      region: external_flash
      size: 0xc000
    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
    settings_storage:
      address: 0xf0000
      end_address: 0xf8000
      region: flash_primary
      size: 0x8000
    custom_nvs_storage:
      address: 0xf8000
      end_address: 0x100000
      region: flash_primary
      size: 0x8000
    sram_primary:
      address: 0x20000000
      end_address: 0x20070000
      region: sram_primary
      size: 0x70000
    

    And finally mt linker script, currently just a shell:

    #include <zephyr/linker/sections.h>
    #include <zephyr/devicetree.h>
    #include <zephyr/linker/linker-defs.h>
    #include <zephyr/linker/linker-tool.h>
    
    MEMORY
    {
        /* This maps in mcuboot_primary_2 partition defined in pm_static.yaml
        * components for ORIGIN calculation:
        *  - 0x10000000: offset of QSPI external memory in SoC memory mapping.
        *  - 0x120000: mcuboot_primary_2 offset in QSPI external memory
        *  - 0x200: image header size.
        * The size of this region is size of mcuboot_primary_2 reduced by the
        * image header size.
        */
        EXTFLASH (wx) : ORIGIN = 0x10120200, LENGTH = 0x3FE00
    }
    
    #include <zephyr/arch/arm/cortex_m/scripts/linker.ld>
    

    Thanks for all your time!

  • Hello,

    Sorry, I did not realize that this was not available in v2.5.0. The feature that allows portions of the app to run in XIP was introduced in SDK v2.6.0. 

    Best regards,

    Vidar

  • Hello, I upgraded to 2.7.0, figuring I might as well go all the way. The issue with the config is gone, but unfortunately I am still getting the same error as before when I had it commented out:

    [140/655] Building C object zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/zephyr_img_mgmt.c.obj    
    FAILED: zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/zephyr_img_mgmt.c.obj
    C:\ncs\toolchains\ce3b5ff664\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DADC_BATTERY_CHANNEL=5 -DADC_EXTERNAL_DIVIDER=2 -DCENTER_CURSOR_ON_INACTIVITY_FLAG -DCPU_NRF5340=1 -DDEVICE_NAME_STRING="\"Glasses PCB\"" -DHEAD_MOVEMENT_THRESHOLD=1 -DKERNEL -DK_HEAP_MEM_POOL_SIZE=4096 -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DN_ACTIVE_CHANNELS=4 -DPD_CHANNEL_ONEHOT=0x33 -DSCROLL_OFFSET=0 -DUSE_PARTITION_MANAGER=1 
    -DUSING_DEV_KEY -DZCBOR_ASSERTS -D_ANSI_SOURCE -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/ncs/v2.7.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/include -IC:/ncs/v2.7.0/zephyr/include -IC:/Users/Isaac/Documents/GitHub/AAVAA_V4/Earbud_V4_5/zephyr/include/generated -IC:/ncs/v2.7.0/zephyr/soc/nordic -IC:/ncs/v2.7.0/zephyr/lib/libc/newlib/include -IC:/ncs/v2.7.0/zephyr/soc/nordic/nrf53/. -IC:/ncs/v2.7.0/zephyr/soc/nordic/common/. -IC:/ncs/v2.7.0/zephyr/subsys/mgmt/mcumgr/util/include -IC:/ncs/v2.7.0/bootloader/mcuboot/boot/bootutil/include -IC:/ncs/v2.7.0/zephyr/subsys/mgmt/mcumgr/transport/include -IC:/ncs/v2.7.0/bootloader/mcuboot/boot/zephyr/include -IC:/ncs/v2.7.0/zephyr/subsys/bluetooth -IC:/ncs/v2.7.0/zephyr/subsys/settings/include -IC:/ncs/v2.7.0/nrf/include -IC:/ncs/v2.7.0/nrf/tests/include -IC:/ncs/v2.7.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.7.0/zephyr/modules/cmsis/. -IC:/ncs/v2.7.0/modules/lib/cmsis-dsp/Include -IC:/ncs/v2.7.0/modules/hal/nordic/nrfx -IC:/ncs/v2.7.0/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.7.0/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.7.0/zephyr/modules/hal_nordic/nrfx/. -IC:/Users/Isaac/Documents/GitHub/AAVAA_V4/Earbud_V4_5/modules/libmetal/libmetal/lib/include -IC:/ncs/v2.7.0/modules/lib/open-amp/open-amp/lib/include -IC:/ncs/v2.7.0/modules/crypto/tinycrypt/lib/include -IC:/ncs/v2.7.0/modules/lib/zcbor/include -IC:/ncs/v2.7.0/nrfxlib/softdevice_controller/include -IC:/ncs/v2.7.0/bootloader/mcuboot/boot/bootutil/zephyr/.. -IC:/ncs/v2.7.0/bootloader/mcuboot/boot/bootutil/zephyr/../include -IC:/ncs/v2.7.0/bootloader/mcuboot/boot/bootutil/zephyr/../../zephyr/include -isystem C:/ncs/v2.7.0/zephyr/lib/libc/common/include -isystem C:/ncs/v2.7.0/nrfxlib/crypto/nrf_cc312_platform/include -Wshadow -fno-strict-aliasing -Os -imacros C:/Users/Isaac/Documents/GitHub/AAVAA_V4/Earbud_V4_5/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mfp16-format=ieee --sysroot=C:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.7.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/Users/Isaac/Documents/GitHub/AAVAA_V4=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.7.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.7.0=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/zephyr_img_mgmt.c.obj -MF zephyr\subsys\mgmt\mcumgr\grp\img_mgmt\CMakeFiles\subsys__mgmt__mcumgr__grp__img_mgmt.dir\src\zephyr_img_mgmt.c.obj.d -o zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/zephyr_img_mgmt.c.obj -c C:/ncs/v2.7.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c
    In file included from C:/ncs/v2.7.0/zephyr/include/zephyr/toolchain.h:50,
                     from C:/ncs/v2.7.0/zephyr/include/zephyr/kernel_includes.h:23,
                     from C:/ncs/v2.7.0/zephyr/include/zephyr/kernel.h:17,
                     from C:/ncs/v2.7.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:7:
    C:/ncs/v2.7.0/zephyr/include/zephyr/toolchain/gcc.h:87:36: error: static assertion failed: "Missing partitions?"
       87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
          |                                    ^~~~~~~~~~~~~~
    C:/ncs/v2.7.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:43:1: note: in expansion of macro 'BUILD_ASSERT'
       43 | BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT2_PARTITION) &&

      I have changed my pm_static to exactly match the example, other than my added partition for my code to store stuff:

    app:
        address: 0x10200
        end_address: 0xe4000
        region: flash_primary
        size: 0xd3e00
    external_flash:
        address: 0x120000
        device: MX25R64
        end_address: 0x800000
        region: external_flash
        size: 0x6e0000
    mcuboot:
        address: 0x0
        end_address: 0x10000
        region: flash_primary
        size: 0x10000
    mcuboot_pad:
        address: 0x10000
        end_address: 0x10200
        region: flash_primary
        size: 0x200
    mcuboot_primary:
        address: 0x10000
        end_address: 0xf0000
        orig_span: &id001
        - mcuboot_pad
        - app
        region: flash_primary
        size: 0xe0000
        span: *id001
    mcuboot_primary_1:
        address: 0x0
        device: flash_ctrl
        end_address: 0x40000
        region: ram_flash
        size: 0x40000
    mcuboot_primary_app:
        address: 0x10200
        end_address: 0xf0000
        orig_span: &id002
        - app
        region: flash_primary
        size: 0xdfe00
        span: *id002
    mcuboot_secondary:
        address: 0x0
        device: MX25R64
        end_address: 0xe0000
        region: external_flash
        size: 0xe0000
    mcuboot_secondary_1:
        address: 0xe0000
        device: MX25R64
        end_address: 0x120000
        region: external_flash
        size: 0x40000
    mcuboot_primary_2:
        address: 0x120000
        device: MX25R64
        end_address: 0x160000
        region: external_flash
        size: 0x40000
    mcuboot_secondary_2:
        address: 0x160000
        device: MX25R64
        end_address: 0x1a0000
        region: external_flash
        size: 0x40000
    otp:
        address: 0xff8100
        end_address: 0xff83fc
        region: otp
        size: 0x2fc
    pcd_sram:
        address: 0x20000000
        end_address: 0x20002000
        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: 0xf0000
        end_address: 0xf8000
        region: flash_primary
        size: 0x8000
    custom_nvs_storage:
      address: 0xf8000
      end_address: 0x100000
      region: flash_primary
      size: 0x8000
    sram_primary:
        address: 0x20002000
        end_address: 0x20070000
        region: sram_primary
        size: 0x6e000
    
    
    
    
    
    
    

    Thanks for your continued assistance

  • Hello,

    The assert is raised because the emulated mcuboot_primary_1 partition in ram is not enabled in kconfig. Please try adding CONFIG_NRF53_UPGRADE_NETWORK_CORE=y to your project configuration file (prj.conf). Please also note that in SDK v2.7.0 the project must be built without sysbuild enabled.

    Best regards,

    Vidar

Reply Children
  • Hello, thanks again for your help!

    We are making progress, but now we have a new issue, in that region "RAM" is now overflowing... Im a little confused about what might be causing this, as my understanding is that we have not made any changes to what goes in ram? Does this mean my code is too large for the the sizes of the partitions in the example PM_Static.yml file?

    c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr\zephyr_pre0.elf section `bss' will not fit in region `RAM'
    c:/ncs/toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: region `RAM' overflowed by 273688 bytes

    Thanks for all your help

  • Hello,

    I assume this linker error is raised when building MCUBoot since you got this after enabling the netcore update functionality. The RAM partition which holds the emulated flash partition (mcuboot_primary_1) is 256K.

    Is the application built for the non-secure processing environment (i.e. are you building for cpuapp/ns) by any chance? In that case, please ensure the  CONFIG_MCUBOOT_USE_ALL_AVAILABLE_RAM symbol is selected in the MCUBoot build (build/mcuboot/zephyr/.config). 

    I have also started working on an example to try this out myself. I'm including it here if you want to compare the configurations:

    1016.peripheral_lbs_dfu_w_xip_test.zip

    Best regards,

    Vidar

  • Thanks for all of your help, I think we are almost there. I switched to the secure instead of ns, and that seems to have resolved the final error I was getting and it now builds. Is there anything else I should be aware of for having made this change?

    Looking at my output, I notice that my EXTFLASH is actually quite small:

    [590/608] Linking CXX executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used

            EXTFLASH:         360 B     261632 B      0.14%

               FLASH:      712056 B     916992 B     77.65%

                 RAM:      124488 B       440 KB     27.63%

            IDT_LIST:          0 GB        32 KB      0.00%

    Looking at the memory report, it seems the problem is just that the partitions need to be made bigger in pm_static.yml.

    Do I just need to make mcuboot_primary_2 and mcuboot_secondary_2 larger?

    Lastly, I tried downloading the code to my 5340DK and are getting no signs of life. No output in console, no LEDs and not detectable on NRF Connect app. Do you have any suggestions where I should start looking for debugging this?

    Thanks!

  • Thanks for the update. For ns builds, the bootloader will only have the access to the secure RAM by default, so this explains the linker error.

    i_4556 said:
    Do I just need to make mcuboot_primary_2 and mcuboot_secondary_2 larger?

    In addition to that, you will need to update the linker script which defines the EXTFLASH section to reflect the new partition size.

    i_4556 said:
    Lastly, I tried downloading the code to my 5340DK and are getting no signs of life. No output in console, no LEDs and not detectable on NRF Connect app. Do you have any suggestions where I should start looking for debugging this?

    To help narrow down the problem, could you please try running the sample I uploaded to your DK and see if you get the same result?

Related