How to debug undefined reference to __device_dts_ord_XX errors?

Hi!

Currently, I'm trying to create a new board. I have a source code for the Thingy52 board and the code just compiles. With my own board I get __device_dts_ord_10 linker errors. And I don't know, why. I have no idea how to debug such errors since the errors are completely useless.

It says, the error is in some line

if (btn_prs) {

where btn_prs is just a boolean variable and why the linker error should be there? It doesn't make sense.

However, I somewhat found out where the problematic code segments are. They are as follows:

static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios);
static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios);
If I remove some parts like this
static const struct gpio_dt_spec led
the code compiles.
And now I don't see where the problem with this is. Why it works with the Thingy52 board but not with mine? The led0 alias is defined and the led also like this
aliases {
led0 = &led0;
sw0 = &button0;
};

leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
label = "Red LED";
};
};

buttons {
compatible = "gpio-keys";
button0: button_0 {
gpios = <&gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Button";
};
};
 
Maybe, you can help me or give me a hint where to search for such errors.
In another project I cannot upgrade the NRF Connect SDK since such errors appear with newer versions. There is nothing documented!
Parents
  • Maybe, it  is the easiest way to share the repository.

    https://github.com/oMtQB4/nrf52-shockburst-3d-touch-probe

    There are two projects in the project. Currently, I'm only trying to get the ESB_ptx working. Furthermore, there is the board in the repository.

    The current error message is as follows (the lines have changed due to changes in the code.

    [3/13] Linking C executable zephyr/zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map xxx/build/zephyr/zephyr_pre0.map
    : && ccache /opt/nordic/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc 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 -Wl,-T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=xxx/ESB_ptx/build/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/posix/liblib__posix.a zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a zephyr/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/timer/libdrivers__timer.a modules/nrf/lib/fatal_error/lib..__nrf__lib__fatali_error.a modules/nrf/subsys/esb/lib..__nrf__subsys__esb.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/nordic/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/thumb/v7e-m/nofp" -Lxxx/ESB_ptx/build/zephyr -lgcc zephyr/arch/common/libisr_tables.a -no-pie -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 && cd xxx/ESB_ptx/build/zephyr && /opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -E echo
    /opt/nordic/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.bfd: app/libapp.a(main.c.obj): in function `button_pressed_cb':
    xxx/ESB_ptx/src/main.c:170: undefined reference to `__device_dts_ord_10'
    /opt/nordic/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.bfd: app/libapp.a(main.c.obj): in function `main':
    xxx/ESB_ptx/src/main.c:245: undefined reference to `__device_dts_ord_10'
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/v2.0.0/bin/cmake --build xxx/ESB_ptx/build

    Currently, NRF Connect SDK 2.0.0 is used.

  • Here is the zephyr.dts of the build directory

    /dts-v1/;
    
    / {
    	#address-cells = < 0x1 >;
    	#size-cells = < 0x1 >;
    	model = "ShockBurst_Probe";
    	compatible = "jan,shockburst-probe";
    	chosen {
    		zephyr,entropy = &rng;
    		zephyr,flash-controller = &flash_controller;
    		zephyr,sram = &sram0;
    		zephyr,flash = &flash0;
    		zephyr,code-partition = &slot0_partition;
    	};
    	aliases {
    		led0 = &led0;
    		sw0 = &button0;
    	};
    	soc {
    		#address-cells = < 0x1 >;
    		#size-cells = < 0x1 >;
    		compatible = "nordic,nRF52810-QFAA", "nordic,nRF52810", "nordic,nRF52", "simple-bus";
    		interrupt-parent = < &nvic >;
    		ranges;
    		nvic: interrupt-controller@e000e100 {
    			#address-cells = < 0x1 >;
    			compatible = "arm,v7m-nvic";
    			reg = < 0xe000e100 0xc00 >;
    			interrupt-controller;
    			#interrupt-cells = < 0x2 >;
    			arm,num-irq-priority-bits = < 0x3 >;
    			phandle = < 0x1 >;
    		};
    		systick: timer@e000e010 {
    			compatible = "arm,armv7m-systick";
    			reg = < 0xe000e010 0x10 >;
    			status = "disabled";
    		};
    		ficr: ficr@10000000 {
    			compatible = "nordic,nrf-ficr";
    			reg = < 0x10000000 0x1000 >;
    			status = "okay";
    		};
    		uicr: uicr@10001000 {
    			compatible = "nordic,nrf-uicr";
    			reg = < 0x10001000 0x1000 >;
    			status = "okay";
    		};
    		sram0: memory@20000000 {
    			compatible = "mmio-sram";
    			reg = < 0x20000000 0x6000 >;
    		};
    		clock: clock@40000000 {
    			compatible = "nordic,nrf-clock";
    			reg = < 0x40000000 0x1000 >;
    			interrupts = < 0x0 0x1 >;
    			status = "okay";
    			label = "CLOCK";
    		};
    		power: power@40000000 {
    			compatible = "nordic,nrf-power";
    			reg = < 0x40000000 0x1000 >;
    			interrupts = < 0x0 0x1 >;
    			status = "okay";
    		};
    		bprot: bprot@40000000 {
    			compatible = "nordic,nrf-bprot";
    			reg = < 0x40000000 0x1000 >;
    			status = "okay";
    		};
    		radio: radio@40001000 {
    			compatible = "nordic,nrf-radio";
    			reg = < 0x40001000 0x1000 >;
    			interrupts = < 0x1 0x1 >;
    			status = "okay";
    			ble-2mbps-supported;
    		};
    		uart0: uart@40002000 {
    			compatible = "nordic,nrf-uarte";
    			reg = < 0x40002000 0x1000 >;
    			interrupts = < 0x2 0x1 >;
    			status = "disabled";
    			label = "UART_0";
    		};
    		i2c0: i2c@40003000 {
    			compatible = "nordic,nrf-twim";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x0 >;
    			reg = < 0x40003000 0x1000 >;
    			clock-frequency = < 0x186a0 >;
    			interrupts = < 0x3 0x1 >;
    			status = "disabled";
    			label = "I2C_0";
    		};
    		spi0: spi@40004000 {
    			compatible = "nordic,nrf-spim";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x0 >;
    			reg = < 0x40004000 0x1000 >;
    			interrupts = < 0x4 0x1 >;
    			status = "disabled";
    			label = "SPI_0";
    		};
    		gpiote: gpiote@40006000 {
    			compatible = "nordic,nrf-gpiote";
    			reg = < 0x40006000 0x1000 >;
    			interrupts = < 0x6 0x5 >;
    			status = "okay";
    			label = "GPIOTE_0";
    		};
    		adc: adc@40007000 {
    			compatible = "nordic,nrf-saadc";
    			reg = < 0x40007000 0x1000 >;
    			interrupts = < 0x7 0x1 >;
    			status = "disabled";
    			label = "ADC_0";
    			#io-channel-cells = < 0x1 >;
    		};
    		timer0: timer@40008000 {
    			compatible = "nordic,nrf-timer";
    			status = "okay";
    			reg = < 0x40008000 0x1000 >;
    			cc-num = < 0x4 >;
    			interrupts = < 0x8 0x1 >;
    			prescaler = < 0x0 >;
    			label = "TIMER_0";
    		};
    		timer1: timer@40009000 {
    			compatible = "nordic,nrf-timer";
    			status = "okay";
    			reg = < 0x40009000 0x1000 >;
    			cc-num = < 0x4 >;
    			interrupts = < 0x9 0x1 >;
    			prescaler = < 0x0 >;
    			label = "TIMER_1";
    		};
    		timer2: timer@4000a000 {
    			compatible = "nordic,nrf-timer";
    			status = "okay";
    			reg = < 0x4000a000 0x1000 >;
    			cc-num = < 0x4 >;
    			interrupts = < 0xa 0x1 >;
    			prescaler = < 0x0 >;
    			label = "TIMER_2";
    			phandle = < 0x2 >;
    		};
    		rtc0: rtc@4000b000 {
    			compatible = "nordic,nrf-rtc";
    			reg = < 0x4000b000 0x1000 >;
    			cc-num = < 0x3 >;
    			interrupts = < 0xb 0x1 >;
    			status = "okay";
    			clock-frequency = < 0x8000 >;
    			prescaler = < 0x1 >;
    			label = "RTC_0";
    		};
    		temp: temp@4000c000 {
    			compatible = "nordic,nrf-temp";
    			reg = < 0x4000c000 0x1000 >;
    			interrupts = < 0xc 0x1 >;
    			status = "okay";
    			label = "TEMP_0";
    		};
    		rng: random@4000d000 {
    			compatible = "nordic,nrf-rng";
    			reg = < 0x4000d000 0x1000 >;
    			interrupts = < 0xd 0x1 >;
    			status = "okay";
    			label = "RNG";
    		};
    		ecb: ecb@4000e000 {
    			compatible = "nordic,nrf-ecb";
    			reg = < 0x4000e000 0x1000 >;
    			interrupts = < 0xe 0x1 >;
    			status = "okay";
    			label = "ECB";
    		};
    		ccm: ccm@4000f000 {
    			compatible = "nordic,nrf-ccm";
    			reg = < 0x4000f000 0x1000 >;
    			interrupts = < 0xf 0x1 >;
    			length-field-length-8-bits;
    			status = "okay";
    		};
    		wdt: wdt0: watchdog@40010000 {
    			compatible = "nordic,nrf-wdt";
    			reg = < 0x40010000 0x1000 >;
    			interrupts = < 0x10 0x1 >;
    			status = "okay";
    			label = "WDT";
    		};
    		rtc1: rtc@40011000 {
    			compatible = "nordic,nrf-rtc";
    			reg = < 0x40011000 0x1000 >;
    			cc-num = < 0x4 >;
    			interrupts = < 0x11 0x1 >;
    			status = "okay";
    			clock-frequency = < 0x8000 >;
    			prescaler = < 0x1 >;
    			label = "RTC_1";
    		};
    		qdec: qdec0: qdec@40012000 {
    			compatible = "nordic,nrf-qdec";
    			reg = < 0x40012000 0x1000 >;
    			interrupts = < 0x12 0x1 >;
    			status = "disabled";
    			label = "QDEC";
    		};
    		comp: comparator@40013000 {
    			compatible = "nordic,nrf-comp";
    			reg = < 0x40013000 0x1000 >;
    			interrupts = < 0x13 0x1 >;
    			status = "disabled";
    			#io-channel-cells = < 0x1 >;
    		};
    		egu0: swi0: egu@40014000 {
    			compatible = "nordic,nrf-egu", "nordic,nrf-swi";
    			reg = < 0x40014000 0x1000 >;
    			interrupts = < 0x14 0x1 >;
    			status = "okay";
    		};
    		egu1: swi1: egu@40015000 {
    			compatible = "nordic,nrf-egu", "nordic,nrf-swi";
    			reg = < 0x40015000 0x1000 >;
    			interrupts = < 0x15 0x1 >;
    			status = "okay";
    		};
    		swi2: swi@40016000 {
    			compatible = "nordic,nrf-swi";
    			reg = < 0x40016000 0x1000 >;
    			interrupts = < 0x16 0x1 >;
    			status = "okay";
    		};
    		swi3: swi@40017000 {
    			compatible = "nordic,nrf-swi";
    			reg = < 0x40017000 0x1000 >;
    			interrupts = < 0x17 0x1 >;
    			status = "okay";
    		};
    		swi4: swi@40018000 {
    			compatible = "nordic,nrf-swi";
    			reg = < 0x40018000 0x1000 >;
    			interrupts = < 0x18 0x1 >;
    			status = "okay";
    		};
    		swi5: swi@40019000 {
    			compatible = "nordic,nrf-swi";
    			reg = < 0x40019000 0x1000 >;
    			interrupts = < 0x19 0x1 >;
    			status = "okay";
    		};
    		pwm0: pwm@4001c000 {
    			compatible = "nordic,nrf-pwm";
    			reg = < 0x4001c000 0x1000 >;
    			interrupts = < 0x1c 0x1 >;
    			status = "disabled";
    			label = "PWM_0";
    			#pwm-cells = < 0x3 >;
    		};
    		pdm0: pdm@4001d000 {
    			compatible = "nordic,nrf-pdm";
    			reg = < 0x4001d000 0x1000 >;
    			interrupts = < 0x1d 0x1 >;
    			status = "disabled";
    			label = "PDM_0";
    		};
    		flash_controller: flash-controller@4001e000 {
    			compatible = "nordic,nrf52-flash-controller";
    			reg = < 0x4001e000 0x1000 >;
    			partial-erase;
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x1 >;
    			label = "NRF_FLASH_DRV_NAME";
    			flash0: flash@0 {
    				compatible = "soc-nv-flash";
    				label = "NRF_FLASH";
    				erase-block-size = < 0x1000 >;
    				write-block-size = < 0x4 >;
    				reg = < 0x0 0x30000 >;
    				partitions {
    					compatible = "fixed-partitions";
    					#address-cells = < 0x1 >;
    					#size-cells = < 0x1 >;
    					boot_partition: partition@0 {
    						label = "mcuboot";
    						reg = < 0x0 0xc000 >;
    					};
    					slot0_partition: partition@c000 {
    						label = "image-0";
    						reg = < 0xc000 0xa000 >;
    					};
    					slot1_partition: partition@16000 {
    						label = "image-1";
    						reg = < 0x16000 0xa000 >;
    					};
    					scratch_partition: partition@20000 {
    						label = "image-scratch";
    						reg = < 0x20000 0xa000 >;
    					};
    					storage_partition: partition@2a000 {
    						label = "storage";
    						reg = < 0x2a000 0x6000 >;
    					};
    				};
    			};
    		};
    		ppi: ppi@4001f000 {
    			compatible = "nordic,nrf-ppi";
    			reg = < 0x4001f000 0x1000 >;
    			status = "okay";
    		};
    		gpio0: gpio@50000000 {
    			compatible = "nordic,nrf-gpio";
    			gpio-controller;
    			reg = < 0x50000000 0x1000 >;
    			#gpio-cells = < 0x2 >;
    			label = "GPIO_0";
    			status = "okay";
    			port = < 0x0 >;
    			phandle = < 0x3 >;
    		};
    	};
    	pinctrl: pin-controller {
    		compatible = "nordic,nrf-pinctrl";
    	};
    	rng_hci: entropy_bt_hci {
    		compatible = "zephyr,bt-hci-entropy";
    		label = "bt_hci_entropy";
    		status = "okay";
    	};
    	cpus {
    		#address-cells = < 0x1 >;
    		#size-cells = < 0x0 >;
    		cpu@0 {
    			device_type = "cpu";
    			compatible = "arm,cortex-m4";
    			reg = < 0x0 >;
    			swo-ref-frequency = < 0x1e84800 >;
    		};
    	};
    	sw_pwm: sw-pwm {
    		compatible = "nordic,nrf-sw-pwm";
    		status = "disabled";
    		label = "SW_PWM";
    		generator = < &timer2 >;
    		clock-prescaler = < 0x0 >;
    		#pwm-cells = < 0x3 >;
    	};
    	leds {
    		compatible = "gpio-leds";
    		led0: led_0 {
    			gpios = < &gpio0 0x7 0x1 >;
    			label = "Status LED";
    		};
    	};
    	buttons {
    		compatible = "gpio-keys";
    		button0: button_0 {
    			gpios = < &gpio0 0xb 0x11 >;
    			label = "Button";
    		};
    	};
    };
    

  • Hi

    I can't immediately see anything wrong with this devicetree.

    Are you still having this issue? have you made any progress?

    Did the thread with the similar issue give you any leads?

    -Einar

Reply Children
No Data
Related