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.

  • Hi

    Do you build your project for this "shockburst probe" board?

    I'd be interested to see the generated devicetree in your build directory (build/zephyr/zephyr.dts), I think it could help a lot in figuring out what's going wrong, as this is definitely related to your devicetree setup.

    See this case where someone had a similar issue caused by missing devicetree definitions:

    https://devzone.nordicsemi.com/f/nordic-q-a/85485/how-to-use-nrf-led-matrix-sample-and-library-from-zephyr-with-nrf-connect-sdk-1-9-1-and-ses-for-use-in-an-app-on-micro-bit-v2

    -Einar

Reply Children
No Data
Related