Problem using an external flash together with MCUBOOT

I have I custom board based on a NRF52832. I also have an external SPI Nor flash I use to store data.

I want to add MCUBOOT and don't use the external flash to store the second image. In fact I use the serial recovery if the DFU fails.

If I compile my project with

CONFIG_BOOTLOADER_MCUBOOT=n

I get no compiler error.

If I set

CONFIG_BOOTLOADER_MCUBOOT=y

I get the following compiler error (I couldn't insert it as code):

[25/30] Linking C executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
cmd.exe /C "cd . && C:\ncs\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe  
-gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o
zephyr\zephyr_pre0.elf  -fuse-ld=bfd  -T  zephyr/linker_zephyr_pre0.cmd  
-Wl,-Map=C:/Nordic/my_repo/my-project/my_name/build/mcuboot/zephyr/zephyr_pre0.map  
-Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  
zephyr/arch/common/libarch__common.a  
zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a  
zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a  
zephyr/arch/arch/arm/core/aarch32/mpu/libarch__arm__core__aarch32__mpu.a  
zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/lib/libc/common/liblib__libc__common.a  
zephyr/soc/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a  
zephyr/soc/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a  
zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/flash/libdrivers__flash.a  
zephyr/drivers/gpio/libdrivers__gpio.a  
zephyr/drivers/pinctrl/libdrivers__pinctrl.a  
zephyr/drivers/serial/libdrivers__serial.a  
zephyr/drivers/timer/libdrivers__timer.a  
modules/nrf/lib/fprotect/lib..__nrf__lib__fprotect.a  
modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a  
modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a  
modules/mbedtls/libmbedTLSBase.a  modules/mbedtls/libmbedTLSCrypto.a  modules/mbedtls/libmbedTLSX509.a  modules/mbedtls/libmodules__mbedtls.a  
modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  
modules/zcbor/libmodules__zcbor.a  -Wl,--no-whole-archive  
zephyr/kernel/libkernel.a  
zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  
-L"c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m/nofp"  
-LC:/Nordic/my_repo/my-project/my_name/build/mcuboot/zephyr  
-lgcc  zephyr/arch/common/libisr_tables.a  
modules/mbedtls/libmbedTLSBase.a  
modules/mbedtls/libmbedTLSCrypto.a  
modules/mbedtls/libmbedTLSX509.a  
-mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfp16-format=ieee  -Wl,--gc-sections  
-Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  
-Wl,-u,_OffsetAbsSyms  
-Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  
-Wl,-N  -Wl,--orphan-handling=warn  -Wl,-no-pie && cmd.exe /C
"cd /D C:\Nordic\my_repo\my-project\my_name\build\mcuboot\zephyr && C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.exe -E true""
c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe:
zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj): in function `k_sleep':
C:\Nordic\my_repo\my-project\my_name\build\mcuboot/zephyr/include/generated/syscalls/kernel.h:135: undefined reference to `z_impl_k_sleep'
c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe:
C:\Nordic\my_repo\my-project\my_name\build\mcuboot/zephyr/include/generated/syscalls/kernel.h:135: undefined reference to `z_impl_k_sleep'
c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe:
zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj):(.rodata.spi_nor_config_0+0x0): undefined reference to `__device_dts_ord_90'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

[...]

ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\Nordic\my_repo\my_project\My_name\build'

What does this error mean? Especially what means the error undefined reference to `__device_dts_ord_90'

Parents
  • Hi,

    What does this error mean? Especially what means the error undefined reference to `__device_dts_ord_90'

    This is coming from devicetree_generated.h located in build/zephyr/include/generated. It might mean that you have not specifically enabled flash support in your project configuration.

    Best regards,
    Dejan

  • Hi Dejan,

    thank you for your response. How do I enable the flash support in my project?

    my prf.conf looks like this:

    CONFIG_SPI=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SPI_NOR=y
    CONFIG_STDOUT_CONSOLE=y
    CONFIG_FLASH_JESD216_API=y

    My project woks with this setup as long as I don't set

    CONFIG_BOOTLOADER_MCUBOOT=y

    Do I need to add some defines to mcuboot.conf?

    I tried adding these defines to mcuboot.conf but I still get the compiling error.

    The only thing that works is, if I remove the Flash from my devicetree.dts.

    But then I can't use the flash at all so this is not an option for me.

    Kind Regards

    Paul

  • I added CONFIG_BOOTLOADER_MCUBOOT=y in my prf.conf.

    I use ncs v2.5.0

    Kind Regards

    Paul

  • Hi Paul,

    Could you show the line with ordinal 90 from your devicetree_generated.h?

    Best regards,
    Dejan

  • Hi Dejan,

    I am not sure what line you mean but here is the section of ordinal 90:

    Is this the write code line?

    Kind Regards Paul

  • Hi Paul,

    Could you share your dts and overlay files?

    Best regards,
    Dejan

  • Hi Dejan,

    here are the relevant parts of my device tree:

    Unfortunately I cannot share my whole dts file

    Kind Regards

    Paul

Reply
  • Hi Dejan,

    here are the relevant parts of my device tree:

    Unfortunately I cannot share my whole dts file

    Kind Regards

    Paul

Children
  • Hi Paul,

    Do you have any overlay file?

    Best regards,
    Dejan

  • Hi Dejan,

    I don't have an overlay file. I made a custom dts file

    Kind regards

    Paul

  • Hi Paul,

    Is your project based on any of the NCS samples?

    Best regards,
    Dejan

  • Hi Dejan,

    I started my project based on different samples such as the peripheral sample, but it grew bigger and bigger. It is basically a BLE project, and the last issue is to add DFU. If I don't use the SPI Flash the application works fine. But if I want to use the Flash and have DFU function, I get the described compile error.

    What other information do you need?

    Kind Regards

    Paul

  • Hi Paul,

    You would need to have "chosen" added in an overlay file for both the application and bootloader as it is shown in external flash memory partitions. Since SPI NOR driver requires multithreading support and is required to be enabled in bootloader configuration, you could try to add the following configuration options to your bootloader configuration in <your_project_folder>\child_image\mcuboot.conf


    Best regards,
    Dejan