SPI and GPIOs defined via device tree report as "undefined references" at linking time.

NCS 2.3.0

nrf5340dk_nrf5340_ns  -- problem is in non-secure domain for an app built with TFM.

I have this in my nrf5340dk_nrf5340_cpuapp_ns.overlay:

&pinctrl {	
	spi2_default: spi2_default {
		group1 {
			psels = <NRF_PSEL(SPIS_SCK, 1, 0)>,
				<NRF_PSEL(SPIS_MISO, 1, 1)>,
				<NRF_PSEL(SPIS_MOSI, 1, 4)>,
				<NRF_PSEL(SPIS_CSN, 1, 5)>;
		};
	};

	spi2_sleep: spi2_sleep {
		group1 {
			psels = <NRF_PSEL(SPIS_SCK, 1, 0)>,
				<NRF_PSEL(SPIS_MISO, 1, 1)>,
				<NRF_PSEL(SPIS_MOSI, 1, 4)>,
				<NRF_PSEL(SPIS_CSN, 1, 5)>;
			low-power-enable;
		};
	};
};
&spi2 {
	compatible = "nordic,nrf-spis";
	status = "okay";
	pinctrl-0 = <&spi2_default>;
	pinctrl-1 = <&spi2_sleep>;
	pinctrl-names = "default", "sleep";
	def-char = <0xFF>;
	overrun-character = <0xaa>;
	ipc_spi_device: spi-device@0 {
		reg = <0>;
	};
};

/ {
    spi_ipc_outputs 
    {
	compatible = "gpio-leds";
	spi_ipc_sync: spi_ipc_sync_pin 
        {
		gpios = <&gpio1 6 (GPIO_PULL_UP | GPIO_OPEN_DRAIN)>;
		label = "SPI_IPC_SYNC pin";
	};
    };
    spi_ipc_inputs 
    {
	compatible = "gpio-keys";
	spi_csn: spi_csn_pin 
        {
		gpios = <&gpio1 5 0>;
		label = "SPI_IPC_CSN pin";
	};
    };
};


/ {
	aliases {
		ipc-spi = &spi2;
		ipc-sync = &spi_ipc_sync;
		ipc-csn = &spi_csn;
	};
};

at compile time everything is fine, but at linking I get these errors:

[421/442] Linking C executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
cmd.exe /C "cd . && D:\AAA\toolchains\v2.3.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -gdwarf-4 @CMakeFiles\zephyr_pre0.rsp -o zephyr\zephyr_pre0.elf && cmd.exe /C "cd /D D:\AAA\AAAProject\fota\app\build_shell\zephyr && D:\AAA\toolchains\v2.3.0\opt\bin\cmake.exe -E echo ""
d:/AAA/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.c.obj):(.rodata.m_spi_ipc_mod+0x8): undefined reference to `__device_dts_ord_144'
d:/AAA/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.c.obj):(.rodata.m_spi_ipc_mod+0x10): undefined reference to `__device_dts_ord_142'
d:/AAA/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.c.obj):(.rodata.m_spi_ipc_mod+0x30): undefined reference to `__device_dts_ord_139

Is there something special I need to do to make these device tree entries available in the non-secure partition?  

How do I fix this error?

Parents
  • Hello Anthony,

    Searching for the numbers at the end of __device_dts_ord_ in build/zephyr/include/generated/devicetree_generated.h will lead you to the dts node which causes the error. You can then find the relevant node in build/zephyr/zephyr.dts and examine it to find the reason for the errors.

    This blogpost from Golioth describes the steps with more detail and they use an example with demo code.

    Best regards,

    Maria

  • Thanks for this resource - it gives invaluable insight to the noobs.

    My case was similar (the configuration of the accelerometer of Thingy:91) and all my settings were OK according to the above blog-post, so the issue was elsewhere. And yes, just like the reporter I had a disabled configuration property:

    CONFIG_ADXL362=n
    Once I enabled it, the build was OK. Now I have "error: 2" in the serial terminal somewhere from the ext_sensor code but that is another story.
    Once again thanks for the resource - these are hard to find.
    Regards
Reply
  • Thanks for this resource - it gives invaluable insight to the noobs.

    My case was similar (the configuration of the accelerometer of Thingy:91) and all my settings were OK according to the above blog-post, so the issue was elsewhere. And yes, just like the reporter I had a disabled configuration property:

    CONFIG_ADXL362=n
    Once I enabled it, the build was OK. Now I have "error: 2" in the serial terminal somewhere from the ext_sensor code but that is another story.
    Once again thanks for the resource - these are hard to find.
    Regards
Children
Related