sysbuild + MCUboot can't resolve SPI NOR symbols (NCS v2.7.0)

I'm using Zephyr/NCS v2.7.0 with a custom multi-image project based on sysbuild. My top-level project has a sysbuild.conf at the root, and a sysbuild/ folder containing a mcuboot.conf that enables CONFIG_SPI_NOR=y, CONFIG_MULTITHREADING=y, etc. Despite this, building fails with an error like:

```
/opt/toolchains/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj):(.rodata.spi_nor_0_config+0x0): undefined reference to `__device_dts_ord_24'
```

This implies MCUboot can't resolve the SPI NOR driver, even though it's configured and works in the main app. I've verified that CONFIG_SPI_NOR is enabled for MCUboot via build logs.

Project structure looks like this:

project/
├── sysbuild.conf
├── CmakeLists.txt.conf
├── prj.conf
├── pm_static.yml
├── sysbuild/
│ └── mcuboot.conf
│ └── CMakeLists.txt
│ └── mcuboot.overlay

Any ideas why the SPI NOR driver instance isn’t being linked correctly into MCUboot? Do I need to mirror the devicetree overlay into sysbuild/mcuboot.overlay, or manually define a node alias to make it resolve properly?

I am happy to share the contents of any of these files on the public forum.
Parents
  • Hi,

     

    In your build folder, more specifically at this location:

    build/MY_APP_NAME/zephyr/include/generated/zephyr/devicetree_generated.h

    there will be a list at the top of this file, looking like this:

     * Node dependency ordering (ordinal and path):
     *   0   /
     *   1   /aliases
     *   2   /analog-connector
     *   3   /chosen
     *   4   /soc
     *   5   /soc/interrupt-controller@e000e100
     *   6   /soc/gpiote@4002f000
     *   7   /soc/peripheral@40000000
     *   8   /soc/peripheral@40000000/gpio@842500
     *   9   /coex
     ....
     

    nr 24 in this list will correspond to the non-enabled device in your device tree:

    (.rodata.spi_nor_0_config+0x0): undefined reference to `__device_dts_ord_24'
    ```

    I highly suspect that is your SPI flash.

    Is this enabled in your mcuboot.overlay file?

     

    Could you share your full build output as well?

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    In your build folder, more specifically at this location:

    build/MY_APP_NAME/zephyr/include/generated/zephyr/devicetree_generated.h

    there will be a list at the top of this file, looking like this:

     * Node dependency ordering (ordinal and path):
     *   0   /
     *   1   /aliases
     *   2   /analog-connector
     *   3   /chosen
     *   4   /soc
     *   5   /soc/interrupt-controller@e000e100
     *   6   /soc/gpiote@4002f000
     *   7   /soc/peripheral@40000000
     *   8   /soc/peripheral@40000000/gpio@842500
     *   9   /coex
     ....
     

    nr 24 in this list will correspond to the non-enabled device in your device tree:

    (.rodata.spi_nor_0_config+0x0): undefined reference to `__device_dts_ord_24'
    ```

    I highly suspect that is your SPI flash.

    Is this enabled in your mcuboot.overlay file?

     

    Could you share your full build output as well?

     

    Kind regards,

    Håkon

Children
  • Hi Håkon, thank you for the fast reply!

    In my devicetree_generated,h I can see:

    ```

     *   22  /soc/gpiote@40006000
     *   23  /soc/gpio@50000000
     *   24  /soc/spi@40023000
     *   25  /soc/spi@40023000/external_flash@0
     *   26  /soc/spi@40023000/external_flash@0/partitions
     *   27  /soc/spi@40023000/external_flash@0/partitions/partition@e7000
     *   28  /fstab/lfs
    ```

    I have attempted to modify my mcuboot.overlay to enable this devices, currently it is as follows:

    ```
    / {
        chosen {
            nordic,pm-ext-flash = &external_flash;
            zephyr,code-partition = &slot0_partition;
        };
    };

    &spi2 {
        compatible = "nordic,nrf-spi";
        status = "okay";
        cs-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; // Flash SPI CS pin
        pinctrl-0 = <&spi2_default>;
        pinctrl-1 = <&spi2_sleep>;
        pinctrl-names = "default", "sleep";

        external_flash: external_flash@0 {
            compatible = "jedec,spi-nor";
            status = "okay";
            reg = <0>;
            spi-max-frequency = <130000000>;
            jedec-id = [ c8 40 18  ];
            size = <0x8000000>; // 128Mbit
            has-dpd;        // Device Power Down
            t-enter-dpd = <10000>;
            t-exit-dpd = <35000>;

            partitions {
                compatible = "fixed-partitions";
                #address-cells = <1>;
                #size-cells = <1>;

                slot1_partition: partition@0 {
                    label = "image-1";
                    reg = <0x00000000 0x000e7000>;
                };

            };
        };
    };

    ```

     Below is my full build output:

    -- west build: making build dir /home/ee/juna-fw/build pristine
    -- west build: generating a build system
    Loading Zephyr module(s) (Zephyr base): sysbuild_default
    -- Found Python3: /usr/bin/python3 (found suitable version "3.10.12", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: /root/.cache/zephyr
    -- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
    -- Board: JUNA, qualifiers: nrf52840
    Parsing /home/ee/ncs/zephyr/share/sysbuild/Kconfig
    Loaded configuration '/home/ee/juna-fw/build/_sysbuild/empty.conf'
    Merged configuration '/home/ee/juna-fw/sysbuild.conf'
    Configuration saved to '/home/ee/juna-fw/build/zephyr/.config'
    Kconfig header saved to '/home/ee/juna-fw/build/_sysbuild/autoconf.h'
    --
    *****************************
    * Running CMake for mcuboot *
    *****************************
    
    -- Application: /home/ee/ncs/bootloader/mcuboot/boot/zephyr
    -- CMake version: 3.21.0
    Loading Zephyr default modules (Zephyr base).
    -- Found Python3: /usr/bin/python (found suitable version "3.10.12", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: /root/.cache/zephyr
    -- Zephyr version: 3.6.99 (/home/ee/ncs/zephyr)
    -- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
    -- Board: JUNA, qualifiers: nrf52840
    -- Found host-tools: zephyr 0.16.1 (/opt/toolchains/zephyr-sdk-0.16.1)
    -- Found toolchain: zephyr 0.16.1 (/opt/toolchains/zephyr-sdk-0.16.1)
    -- Found Dtc: /opt/toolchains/zephyr-sdk-0.16.1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
    -- Found BOARD.dts: /home/ee/juna-fw/boards/chiaro/JUNA/JUNA.dts
    -- Found devicetree overlay: /home/ee/ncs/bootloader/mcuboot/boot/zephyr/app.overlay
    -- Generated zephyr.dts: /home/ee/juna-fw/build/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/ee/juna-fw/build/mcuboot/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /home/ee/juna-fw/build/mcuboot/zephyr/dts.cmake
    Parsing /home/ee/ncs/bootloader/mcuboot/boot/zephyr/Kconfig
    Loaded configuration '/home/ee/juna-fw/boards/chiaro/JUNA/JUNA_defconfig'
    Merged configuration '/home/ee/ncs/bootloader/mcuboot/boot/zephyr/prj.conf'
    Merged configuration '/home/ee/ncs/nrf/subsys/bootloader/bl_override/override_external_mcuboot.conf'
    Merged configuration '/home/ee/ncs/nrf/subsys/partition_manager/ext_flash_mcuboot_secondary.conf'
    Merged configuration '/home/ee/juna-fw/build/mcuboot/zephyr/.config.sysbuild'
    Configuration saved to '/home/ee/juna-fw/build/mcuboot/zephyr/.config'
    Kconfig header saved to '/home/ee/juna-fw/build/mcuboot/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: /opt/toolchains/zephyr-sdk-0.16.1/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /opt/toolchains/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    CMake Warning at /home/ee/ncs/nrf/lib/flash_patch/CMakeLists.txt:8 (message):
    
    ----------------------------------------------------------
    --- WARNING: To maintain the integrity of secure boot, ---
    --- enable CONFIG_DISABLE_FLASH_PATCH in production. ---
    ----------------------------------------------------------
    
    
    -- Using ccache: /usr/bin/ccache
    CMake Warning at /home/ee/ncs/zephyr/CMakeLists.txt:895 (message):
    No SOURCES given to Zephyr library: drivers__spi
    
    Excluding target from build.
    
    
    MCUBoot bootloader key file: /home/ee/ncs/bootloader/mcuboot/root-ec-p256.pem
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/ee/juna-fw/build/mcuboot
    --
    *****************************
    * Running CMake for juna-fw *
    *****************************
    
    -- Found Git: /usr/bin/git (found version "2.34.1")
    -- [MunkeiVersionFromGit] Version: 4.1.0
    Git tag: [v4.1.0]
    Git hash: [5b017006]
    Git branch: [ncs_upgrade]
    Git dirty: [dirty]
    Decorated: [v4.1.0-15-g5b017006]
    Identifiers: []
    Metadata: []
    SemVer: [4.1.0]
    Loading Zephyr default modules (Zephyr base).
    -- Application: /home/ee/juna-fw
    -- CMake version: 3.21.0
    -- Found Python3: /usr/bin/python (found suitable version "3.10.12", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: /root/.cache/zephyr
    -- Zephyr version: 3.6.99 (/home/ee/ncs/zephyr)
    -- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
    -- Board: JUNA, qualifiers: nrf52840
    -- Found host-tools: zephyr 0.16.1 (/opt/toolchains/zephyr-sdk-0.16.1)
    -- Found toolchain: zephyr 0.16.1 (/opt/toolchains/zephyr-sdk-0.16.1)
    -- Found Dtc: /opt/toolchains/zephyr-sdk-0.16.1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
    -- Found BOARD.dts: /home/ee/juna-fw/boards/chiaro/JUNA/JUNA.dts
    -- Generated zephyr.dts: /home/ee/juna-fw/build/juna-fw/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/ee/juna-fw/build/juna-fw/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /home/ee/juna-fw/build/juna-fw/zephyr/dts.cmake
    
    
    Parsing /home/ee/juna-fw/Kconfig
    Loaded configuration '/home/ee/juna-fw/boards/chiaro/JUNA/JUNA_defconfig'
    Merged configuration '/home/ee/juna-fw/prj.conf'
    Merged configuration '/home/ee/juna-fw/build/juna-fw/zephyr/.config.sysbuild'
    Configuration saved to '/home/ee/juna-fw/build/juna-fw/zephyr/.config'
    Kconfig header saved to '/home/ee/juna-fw/build/juna-fw/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: /opt/toolchains/zephyr-sdk-0.16.1/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /opt/toolchains/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    -- Using ccache: /usr/bin/ccache
    CMake Warning at /home/ee/ncs/zephyr/CMakeLists.txt:895 (message):
    No SOURCES given to Zephyr library: ..__nrf__subsys__caf__modules
    
    Excluding target from build.
    
    
    -- Including signing script: /home/ee/ncs/nrf/cmake/sysbuild/image_signing.cmake
    CMake Warning at /home/ee/ncs/zephyr/CMakeLists.txt:2027 (message):
    __ASSERT() statements are globally ENABLED
    
    
    -- Setup Protobuf...
    -- Found Nanopb: /home/ee/ncs/modules/lib/nanopb
    -- Found protoc: /home/ee/ncs/modules/lib/nanopb/generator/protoc
    --2025-06-17 14:34:42-- https://raw.githubusercontent.com/boost-ext/sml/v1.1.11/include/boost/sml.hpp
    Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.109.133, ...
    Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 126527 (124K) [text/plain]
    Saving to: ‘/home/ee/juna-fw/build/juna-fw/boost/sml.hpp’
    
    0K .......... .......... .......... .......... .......... 40% 1.82M 0s
    50K .......... .......... .......... .......... .......... 80% 7.44M 0s
    100K .......... .......... ... 100% 15.2M=0.03s
    
    2025-06-17 14:34:42 (3.46 MB/s) - ‘/home/ee/juna-fw/build/juna-fw/boost/sml.hpp’ saved [126527/126527]
    
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/ee/juna-fw/build/juna-fw
    -- Found Python3: /usr/bin/python3 (found version "3.10.12") found components: Interpreter
    -- Found partition manager static configuration : /home/ee/juna-fw/pm_static.yml
    Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
    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_primary_app' is not included in the dynamic resolving since it is statically defined.
    Partition 'littlefs_storage' 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.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/ee/juna-fw/build
    -- west build: building application
    [8/21] Performing build step for 'juna-fw'
    [0/1] Re-running CMake...
    -- [MunkeiVersionFromGit] Version: 4.1.0
    Git tag: [v4.1.0]
    Git hash: [5b017006]
    Git branch: [ncs_upgrade]
    Git dirty: [dirty]
    Decorated: [v4.1.0-15-g5b017006]
    Identifiers: []
    Metadata: []
    SemVer: [4.1.0]
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: /home/ee/juna-fw
    -- CMake version: 3.21.0
    -- Cache files will be written to: /root/.cache/zephyr
    -- Zephyr version: 3.6.99 (/home/ee/ncs/zephyr)
    -- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
    -- Board: JUNA, qualifiers: nrf52840
    -- Found host-tools: zephyr 0.16.1 (/opt/toolchains/zephyr-sdk-0.16.1)
    -- Found toolchain: zephyr 0.16.1 (/opt/toolchains/zephyr-sdk-0.16.1)
    -- Found BOARD.dts: /home/ee/juna-fw/boards/chiaro/JUNA/JUNA.dts
    -- Generated zephyr.dts: /home/ee/juna-fw/build/juna-fw/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/ee/juna-fw/build/juna-fw/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /home/ee/juna-fw/build/juna-fw/zephyr/dts.cmake
    Parsing /home/ee/juna-fw/Kconfig
    Loaded configuration '/home/ee/juna-fw/build/juna-fw/zephyr/.config'
    Merged configuration '/home/ee/juna-fw/build/juna-fw/zephyr/.config.sysbuild'
    No change to configuration in '/home/ee/juna-fw/build/juna-fw/zephyr/.config'
    No change to Kconfig header in '/home/ee/juna-fw/build/juna-fw/zephyr/include/generated/autoconf.h'
    -- Using ccache: /usr/bin/ccache
    CMake Warning at /home/ee/ncs/zephyr/CMakeLists.txt:895 (message):
    No SOURCES given to Zephyr library: ..__nrf__subsys__caf__modules
    
    Excluding target from build.
    
    
    -- Including signing script: /home/ee/ncs/nrf/cmake/sysbuild/image_signing.cmake
    CMake Warning at /home/ee/ncs/zephyr/CMakeLists.txt:2027 (message):
    __ASSERT() statements are globally ENABLED
    
    
    -- Setup Protobuf...
    -- Found protoc: /home/ee/ncs/modules/lib/nanopb/generator/protoc
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/ee/juna-fw/build/juna-fw
    [1/415] Preparing syscall dependency handling
    
    [6/415] Generating include/generated/version.h
    -- Zephyr version: 3.6.99 (/home/ee/ncs/zephyr), build: v3.6.99-ncs2
    [415/415] Linking CXX executable zephyr/zephyr.elf
    Memory region Used Size Region Size %age Used
    FLASH: 765296 B 945664 B 80.93%
    RAM: 159136 B 256 KB 60.71%
    IDT_LIST: 0 GB 32 KB 0.00%
    Generating files from /home/ee/juna-fw/build/juna-fw/zephyr/zephyr.elf for board: JUNA
    image.py: sign the payload
    image.py: sign the payload
    [11/21] Performing build step for 'mcuboot'
    [1/190] Preparing syscall dependency handling
    
    [7/190] Generating include/generated/version.h
    -- Zephyr version: 3.6.99 (/home/ee/ncs/zephyr), build: v3.6.99-ncs2
    [185/190] Linking C executable zephyr/zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /home/ee/juna-fw/build/mcuboot/zephyr/zephyr_pre0.map
    : && ccache /opt/toolchains/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj -fuse-ld=bfd -T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=/home/ee/juna-fw/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/libarch__arm__core.a zephyr/arch/arch/arm/core/cortex_m/libarch__arm__core__cortex_m.a zephyr/arch/arch/arm/core/mpu/libarch__arm__core__mpu.a zephyr/lib/libc/minimal/liblib__libc__minimal.a zephyr/lib/libc/common/liblib__libc__common.a zephyr/soc/soc/nrf52840/libsoc__nordic.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.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/drivers/hw_cc3xx/lib..__nrf__drivers__hw_cc3xx.a modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a modules/segger/libmodules__segger.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a -L"/opt/toolchains/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m+fp/hard" -L/home/ee/juna-fw/build/mcuboot/zephyr -lgcc zephyr/arch/common/libisr_tables.a -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -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 /home/ee/ncs/nrfxlib/crypto/nrf_cc310_platform/lib/cortex-m4/hard-float/no-interrupts/libnrf_cc310_platform_0.9.19.a /home/ee/ncs/nrfxlib/crypto/nrf_cc310_bl/lib/cortex-m4/hard-float/no-interrupts/libnrf_cc310_bl_0.9.12.a && cd /home/ee/juna-fw/build/mcuboot/zephyr && /usr/local/bin/cmake -E true
    /opt/toolchains/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj):(.rodata.spi_nor_0_config+0x0): undefined reference to `__device_dts_ord_24'
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    [16/21] Generating ../dfu_application.zip
    FAILED: _sysbuild/sysbuild/images/bootloader/mcuboot-prefix/src/mcuboot-stamp/mcuboot-build /home/ee/juna-fw/build/_sysbuild/sysbuild/images/bootloader/mcuboot-prefix/src/mcuboot-stamp/mcuboot-build
    cd /home/ee/juna-fw/build/mcuboot && /usr/local/bin/cmake --build .
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: /usr/local/bin/cmake --build /home/ee/juna-fw/build

  • Hi,

     

    Are you missing CONFIG_SPI=y in mcuboot?

    ando20 said:
    compatible = "nordic,nrf-spi";

    You should consider using "nordic,nrf-spim" instead, as this will enable DMA usage (NRF_SPI vs. NRF_SPIM hardware module)

     

    Kind regards,

    Håkon

  • Hi,

    ```

    CONFIG_SPI=y
    ```

    Is enabled in mcuboot.conf and I can see that it is present in the: build/mcuboot/zephyr/.config.

    I will look at enabling spim once this build issue is resolved.

    Thank you,

    Andy

Related