Undefined reference to `__device_dts_ord_139'

Hello,

I know this is a documented error but I'm still struggling to fully understand and fix this.

Context:

I'm trying to make my custom display driver working again on my project after a Zephyr (+LVGL) upgrade to 2.9.2. 

The error: 

Loading Zephyr default modules (Zephyr base).
-- Application: /Quantum
-- CMake version: 3.21.0
-- Found Python3: /opt/nordic/ncs/toolchains/b8efef2ad5/bin/python (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter 
-- Cache files will be written to: /Users/ferez/Library/Caches/zephyr
-- Zephyr version: 3.7.99 (/opt/nordic/ncs/v2.9.2/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf52840_quantum_v2, qualifiers: nrf52840
-- Found host-tools: zephyr 0.17.0 (/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.17.0 (/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk)
-- Found Dtc: /opt/nordic/ncs/toolchains/b8efef2ad5/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6") 
-- Found BOARD.dts: /Quantum/boards/KiwiElectronics/nrf52840_quantum_v2/nrf52840_quantum_v2.dts
-- Found devicetree overlay: boards/KiwiElectronics/nrf52840_quantum_v2/nrf52840_quantum_v2_SSD1333.overlay
'label' is marked as deprecated in 'properties:' in /opt/nordic/ncs/v2.9.2/zephyr/dts/bindings/mtd/nordic,qspi-nor.yaml for node /soc/qspi@40029000/mx25r6435f@0.
'label' is marked as deprecated in 'properties:' in /Quantum/dts/bindings/display/solomon,ssd1333.yaml for node /soc/spi@4002f000/ssd1333@0.
-- Generated zephyr.dts: /Quantum/build/Quantum/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /Quantum/build/Quantum/zephyr/include/generated/zephyr/devicetree_generated.h
-- Including generated dts.cmake file: /Quantum/build/Quantum/zephyr/dts.cmake

warning: NORDIC_QSPI_NOR (defined at /opt/nordic/ncs/v2.9.2/nrf/Kconfig.nrf:97,
drivers/flash/Kconfig.nordic_qspi_nor:4) was assigned the value 'y' but got the value 'n'. See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_NORDIC_QSPI_NOR and/or look up
NORDIC_QSPI_NOR in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too.

Parsing /Quantum/Kconfig
Loaded configuration '/Quantum/boards/KiwiElectronics/nrf52840_quantum_v2/nrf52840_quantum_v2_defconfig'
Merged configuration '/Quantum/prj.conf'
Merged configuration '/Quantum/build/Quantum/zephyr/.config.sysbuild'
Configuration saved to '/Quantum/build/Quantum/zephyr/.config'
Kconfig header saved to '/Quantum/build/Quantum/zephyr/include/generated/zephyr/autoconf.h'
-- Found GnuLd: /opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38") 
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- Setting build type to 'MinSizeRel' as none was specified.
-- Using ccache: /opt/nordic/ncs/toolchains/b8efef2ad5/bin/ccache
CMake Warning at /opt/nordic/ncs/v2.9.2/zephyr/CMakeLists.txt:952 (message):
  No SOURCES given to Zephyr library: drivers__display

  Excluding target from build.


CMake Warning at /opt/nordic/ncs/v2.9.2/zephyr/CMakeLists.txt:952 (message):
  No SOURCES given to Zephyr library: drivers__power_domain

  Excluding target from build.


CMake Warning at /opt/nordic/ncs/v2.9.2/zephyr/CMakeLists.txt:2164 (message):
  

        The CMake build type was set to 'MinSizeRel', but the optimization flag was set to '-Og'.
        This may be intentional and the warning can be turned off by setting the CMake variable 'NO_BUILD_TYPE_WARNING'


-- Configuring done
-- Generating done
-- Build files have been written to: /Quantum/build/Quantum
-- Configuring done
-- Generating done
-- Build files have been written to: /Quantum/build
-- west build: building application

[...]

FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /Quantum/build/Quantum/zephyr/zephyr_pre0.map 
: && ccache /opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -Os -DNDEBUG -gdwarf-4 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  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/Quantum/build/Quantum/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/libarch__arm__core.a  zephyr/arch/arch/arm/core/cortex_m/libarch__arm__core__cortex_m.a  zephyr/arch/arch/arm/core/mpu/libarch__arm__core__mpu.a  zephyr/lib/libc/newlib/liblib__libc__newlib.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/soc/soc/nrf52840/libsoc__nordic.a  zephyr/drivers/adc/libdrivers__adc.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/spi/libdrivers__spi.a  zephyr/drivers/timer/libdrivers__timer.a  modules/nrf/drivers/hw_cc3xx/lib..__nrf__drivers__hw_cc3xx.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  modules/lvgl/libmodules__lvgl.a  modules/segger/libmodules__segger.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L/Quantum/build/Quantum/zephyr  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfpu=fpv4-sp-d16  -mfloat-abi=hard  -mfp16-format=ieee  -fuse-ld=bfd  -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  -L"/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi"/lib/thumb/v7e-m+fp/hard  -u_printf_float  -specs=nano.specs  /opt/nordic/ncs/v2.9.2/nrfxlib/crypto/nrf_cc310_platform/lib/cortex-m4/hard-float/no-interrupts/libnrf_cc310_platform_0.9.19.a  -lc -L"/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m+fp/hard" -lm -lc -lgcc -lc && cd /Quantum/build/Quantum/zephyr && /opt/nordic/ncs/toolchains/b8efef2ad5/Cellar/cmake/3.21.0/bin/cmake -E true
/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: app/libapp.a(view.c.obj): in function `init_lvgl':
/Quantum/src/view/view.c:543: undefined reference to `__device_dts_ord_139'
/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/lvgl/libmodules__lvgl.a(lvgl.c.obj): in function `lvgl_init':
/opt/nordic/ncs/v2.9.2/zephyr/modules/lvgl/lvgl.c:244: undefined reference to `__device_dts_ord_139'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FAILED: _sysbuild/sysbuild/images/Quantum-prefix/src/Quantum-stamp/Quantum-build /Quantum/build/_sysbuild/sysbuild/images/Quantum-prefix/src/Quantum-stamp/Quantum-build 
cd /Quantum/build/Quantum && /opt/nordic/ncs/toolchains/b8efef2ad5/Cellar/cmake/3.21.0/bin/cmake --build .
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/b8efef2ad5/bin/cmake --build /Quantum/build

What I've already done:

I tried to sync-up my project structure to https://github.com/nrfconnect/ncs-example-application/tree/main

I followed and check point by point https://docs.zephyrproject.org/latest/build/dts/troubleshooting.html

The code :

You can find the sanitized project and build folder here

I seek your help because I'm on it for a while now and I've run out of ideas.

Edit: I added more content on the github's build folder content. 

 

Thanks !

Parents
  • After hours of fails and retries, I got rid of this error by loading my driver C file inside the 

    target_sources(app PRIVATE
    instead of loading its parent directoy with 

    add_subdirectory()

    in the root CMakeLists.txt file.

    Any idea why ? May it be somehow related to macro expansion order ? 

  • Hi,

    I think what happened might be that now the build is properly being integrated.

    i.e., by loading the driver C file directly inside the target_sources(....) you explicitly made sure that your driver's object file which is created, gets compiled into the app/libapp.a

    So this could be why your undefined reference vanished. Earlier, either you created a plain CMake lib, or maybe you did not mention any sources or there might have been some issue because of the library's scope (this is most likely, because if when CMake runs, the library is not the one that you require, say, drivers_dsplay, then this could result in error).

    -Priyanka

Reply
  • Hi,

    I think what happened might be that now the build is properly being integrated.

    i.e., by loading the driver C file directly inside the target_sources(....) you explicitly made sure that your driver's object file which is created, gets compiled into the app/libapp.a

    So this could be why your undefined reference vanished. Earlier, either you created a plain CMake lib, or maybe you did not mention any sources or there might have been some issue because of the library's scope (this is most likely, because if when CMake runs, the library is not the one that you require, say, drivers_dsplay, then this could result in error).

    -Priyanka

Children
No Data
Related