Linking fails with CONFIG_BOOTLOADER_MCUBOOT with external SPI flash enabled

Hi, 

So my project builds as is when I comment out the config option CONFIG_BOOTLOADER_MCUBOOT, or if I leave it enabled and then comment out the external flash memory decleration in the device tree file. When the build fails I get the following error:

[184/194] Linking C executable zephyr/zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map 
: && ccache /home/cmabon/ncs/toolchains/1f9b40e71a/opt/zephyr-sdk/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  -fuse-ld=bfd  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/home/cmabon/Documents/Projects/SG-Firmware/build_1/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/cortex_m/cmse/libarch__arm__core__aarch32__cortex_m__cmse.a  zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/boards/boards/arm/actinius_icarus/actinius_common/libboards__common__actinius.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/nrf/drivers/hw_cc310/lib..__nrf__drivers__hw_cc310.a  modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.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"/home/cmabon/ncs/toolchains/1f9b40e71a/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v8-m.main+fp/hard"  -L/home/cmabon/Documents/Projects/SG-Firmware/build_1/mcuboot/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m33  -mthumb  -mabi=aapcs  -mfpu=fpv5-sp-d16  -mfloat-abi=hard  -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/cmabon/ncs/v2.4.2/nrfxlib/crypto/nrf_cc310_platform/lib/cortex-m33/hard-float/no-interrupts/libnrf_cc310_platform_0.9.17.a  /home/cmabon/ncs/v2.4.2/nrfxlib/crypto/nrf_cc310_bl/lib/cortex-m33/hard-float/no-interrupts/libnrf_cc310_bl_0.9.12.a && cd /home/cmabon/Documents/Projects/SG-Firmware/build_1/mcuboot/zephyr && /home/cmabon/ncs/toolchains/1f9b40e71a/usr/local/bin/cmake -E echo
/home/cmabon/ncs/toolchains/1f9b40e71a/opt/zephyr-sdk/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_config_0+0x0): undefined reference to `__device_dts_ord_113'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed

My config file:

#MCUBoot
CONFIG_BOOTLOADER_MCUBOOT=y

#C++ Support Stuff
CONFIG_CPP=y
CONFIG_STD_CPP11=y
CONFIG_GLIBCXX_LIBCPP=y
CONFIG_CPP_MAIN=y

#Other Stuff so far
CONFIG_PM_DEVICE=y

#Shell Stuff
CONFIG_SHELL=y
CONFIG_DEVICE_SHELL=y
CONFIG_KERNEL_SHELL=y
CONFIG_PRINTK=y

#I2C Stuff
CONFIG_I2C=y
CONFIG_RTC=y
CONFIG_RTC_PCF8523=y

#SPI Stuff
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_FLASH=y

And my SPI and flash device definitions: 

&spi3 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	cs-gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;
	pinctrl-0 = <&spi3_default>;
	pinctrl-1 = <&spi3_sleep>;
	pinctrl-names = "default", "sleep";

	w25q64: w25q64jv@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <80000000>;
		jedec-id = [ef 40 17];
		size = <0x4000000>;
		has-dpd;
		t-enter-dpd = <3500>;
		t-exit-dpd = <3500>;
		status = "okay";
	};
};

Currently there isn't any parition definitions of the space on the external flash, however they will be added later when I add a filesystem for storage later in the project. 

I've done a fair amount of searching and havn't been able to find anything that has fixed this issue. Any help would be very appreciated.

Thank you.

Parents
  • Hi!

    When removing the spi dts related things, try also to remove these configs:

    #SPI Stuff
    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_FLASH=y

  • Hi my appologies, 

    Everything builds and links with the CONFIG_BOOTLOADER_MCUBOOT option disabled (ie.. with all of the SPI settings). The issue I'm having is building with the MCUBoot option enabled since I need it. 

    EDIT:

    Dug into the build directory. Looking for the error from the device tree in "/build/mcuboot/zephyr/include/devictree_generated.h" (looking for __device_dts_ord_108) shows that it is indeed the SPI bus (or the SPI device?) that is cuasing the issue:

     *   104 /soc/peripheral@50000000/i2c@a000/lis2dh12-accel@19
     *   105 /soc/peripheral@50000000/power@5000
     *   106 /soc/peripheral@50000000/power@5000/gpregret1@551c
     *   107 /soc/peripheral@50000000/power@5000/gpregret2@5520
     *   108 /soc/peripheral@50000000/spi@b000
     *   109 /soc/peripheral@50000000/spi@b000/w25q64jv@0

    (in the orginal post the missing device is __device_dts_ord_113 but this is a refrence to a different build configuration that I didn't want to post. The exact same issue is happening on both just with different id #'s)

    Finding the matching device for 108 in "/build/mcuboot/zephyr/zephyr.dts" gives the following for the devices configuration:

    spi3: feather_spi: arduino_spi: spi@b000 {
    				compatible = "nordic,nrf-spim";
    				#address-cells = < 0x1 >;
    				#size-cells = < 0x0 >;
    				reg = < 0xb000 0x1000 >;
    				interrupts = < 0xb 0x1 >;
    				max-frequency = < 0x7a1200 >;
    				easydma-maxcnt-bits = < 0xd >;
    				status = "okay";
    				cs-gpios = < &gpio0 0x19 0x1 >;
    				pinctrl-0 = < &spi3_default >;
    				pinctrl-1 = < &spi3_sleep >;
    				pinctrl-names = "default", "sleep";
    				w25q64: w25q64jv@0 {
    					compatible = "jedec,spi-nor";
    					reg = < 0x0 >;
    					spi-max-frequency = < 0x4c4b400 >;
    					jedec-id = [ EF 40 17 ];
    					size = < 0x4000000 >;
    					has-dpd;
    					t-enter-dpd = < 0xdac >;
    					t-exit-dpd = < 0xdac >;
    				};

    This however doesn't look wrong to my eyes. From what I've read however there should be an issue in the device tree configuration for the board. 

  • 4DoorToyota said:
    This however doesn't look wrong to my eyes.

    I agree, everything looks right here.  Could you post the entire  "/build/mcuboot/zephyr/zephyr.dts" file, as well as these files:

    "/build/zephyr/zephyr.dts"

    "/build/mcuboot/zephyr/include/devictree_generated.h"

    "/build/zephyr/include/devictree_generated.h"

  • Hi, I have exactly the same problem.
    You can reproduce it with the jesd216 sample and the following command: west build zephyr/samples/drivers/jesd216 -b nrf52840dk_nrf52840 -p -- -DEXTRA_CONF_FILE=boards/nrf52840dk_nrf52840_spi.conf -DDTC_OVERLAY_FILE=boards/nrf52840dk_nrf52840_spi.overlay
    and setting CONFIG_BOOTLOADER_MCUBOOT=y

    Have you found a solution ?

  • Hi!

    I tried building this with NCS 2.5.0, but I did not get any build errors.

Reply Children
Related