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 Reply Children
  • 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:

    /* Node's dependency ordinal: */
    #define DT_N_S_soc_S_spi_40004000_ORD 90
    #define DT_N_S_soc_S_spi_40004000_ORD_STR_SORTABLE 00090
    
    /* Ordinals for what this node depends on directly: */
    #define DT_N_S_soc_S_spi_40004000_REQUIRES_ORDS \
    	4, /* /soc */ \
    	5, /* /soc/interrupt-controller@e000e100 */ \
    	9, /* /soc/gpio@50000000 */ \
    	28, /* /pin-controller/spi1_default */ \
    	30, /* /pin-controller/spi1_sleep */

    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:

    {
    
        chosen {
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    		zephyr,bt-mon-uart = &uart0;
    		zephyr,bt-c2h-uart = &uart0;
    		zephyr,sram = &sram0;
    		zephyr,flash = &flash0;
    		zephyr,code-partition = &slot0_partition;
    	};
    	
        aliases {
            spi-flash0 = &mx25r80;
        }
    }
    
    &spi1 {
    	compatible = "nordic,nrf-spi";
    	status = "okay";
    	cs-gpios = 	< &gpio0 28 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi1_default>;
    	pinctrl-1 = <&spi1_sleep>;
    	pinctrl-names = "default", "sleep";
    	mx25r80: mx25r8035f@0 {
    		compatible = "jedec,spi-nor";
    		label = "MX25R8035F";
    		reg = <0>;
    		spi-max-frequency = <8000000>;
    		size = <0x800000>;
    		jedec-id = [c2 28 14];
    		sfdp-bfp = [
    		 	 e5 20 f1 ff  ff ff 7f 00  44 eb 08 6b  08 3b 04 bb
    		 	 ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
    		 	 10 d8 00 ff  23 72 f5 00  82 ed 04 b7  44 83 38 44
    		     30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
    		];
    		has-dpd;
    		t-enter-dpd = < 10000 >;
    		t-exit-dpd = < 35000 >;
    	};
    	
    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x0 0xc000>;
    		};
    		slot0_partition: partition@c000 {
    			label = "image-0";
    			reg = <0xc000 0x6de00>;
    		};
    		slot1_partition: partition@79e00 {
    			label = "image-1";
    			reg = <0x79e00 0x100>;
    		};
    		storage_partition: partition@7a000 {
    			label = "storage";
    			reg = <0x7a000 0x6000>;
    		};
    	};
    };

    Unfortunately I cannot share my whole dts file

    Kind Regards

    Paul

Related