Problem with Out of Tree Driver Build

I have been banging my head against this wall for a long time now. I am trying to add support for the NAU7802 sensor based on this repository: https://github.com/TinNotTim/nau7802_loadcell_zephyr_driver/blob/main/Kconfig

I am using the latest 2.7.0 nRF Connect release building for the xiao_ble_sense board. I cannot roll back to 2.6.1 as there is a bug with the LSM6DSL sensor implementation. 

I CANNOT get it to build for the life of me. I am getting a multitude of errors:

1. On a pristine build I always get an error with trying to include the `offsets.h` file. The error is documented in this ticket, but it is not my main focus right now as it goes away after a rebuild. 

In file included from /opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/app_memory/app_memdomain.h:9,
                 from /opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/rtio/rtio.h:31,
                 from /opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/drivers/sensor.h:28,
                 from /Users/ericpietrowicz/firmware/nau7802-test-delete-me/drivers/sensor/nau7802/nau7802.h:13,
                 from /Users/ericpietrowicz/firmware/nau7802-test-delete-me/drivers/sensor/nau7802/nau7802_trigger.c:7:
/opt/nordic/ncs/v2.6.1/zephyr/include/zephyr/linker/linker-defs.h:26:10: fatal error: offsets.h: No such file or directory
   26 | #include <offsets.h>
      |          ^~~~~~~~~~~
compilation terminated.

2. After the first build, I am getting a mess of device tree errors that I can't easily parse.

note: in expansion of macro 'DT_INST_FOREACH_STATUS_OKAY'
  596 | DT_INST_FOREACH_STATUS_OKAY(CREATE_NAU7802_INST)

Does anyone have any ideas? I've attached a minimal version of the failing project here. I suspect it might be something with my Kconfigs (below) but I really have no idea as I just have so many linting errors all over the project.

menu "Zephyr"
source "Kconfig.zephyr"
endmenu

rsource "drivers/Kconfig"

nau7802-test-delete-me.zip

Parents
  • Hello,

    From the logs you shared, the specific error is an undefined reference to __device_dts_ord_110, which typically means that the linker can't find a symbol that should be defined in the device tree or its associated source files. I recommend following the Zephyr guide on troubleshooting the device tree and checking if any of the steps mentioned will resolve the issue. Please let me know the update.

    Kind regards,

    Abhijith

  • I was able to figure this out but only by digging deep into the Zephyr Discord. I was missing a `Zephyr` folder in my `drivers` subdirectory with the following `module.yaml`:

    name: NAU7802_LOADCELL
    build:
      cmake: .
      kconfig: Kconfig
      settings:
        dts_root: .

    I then had to update my CMakeLists.txt to the following (note the list(APPEND...) line):

    cmake_minimum_required(VERSION 3.20.0)
    
    list(APPEND ZEPHYR_EXTRA_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/drivers")
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    
    project(nau7802-test-delete-me)
    
    target_sources(app PRIVATE src/main.c)
    

    I created a stand alone Github repository with the example that now compiles.

Reply
  • I was able to figure this out but only by digging deep into the Zephyr Discord. I was missing a `Zephyr` folder in my `drivers` subdirectory with the following `module.yaml`:

    name: NAU7802_LOADCELL
    build:
      cmake: .
      kconfig: Kconfig
      settings:
        dts_root: .

    I then had to update my CMakeLists.txt to the following (note the list(APPEND...) line):

    cmake_minimum_required(VERSION 3.20.0)
    
    list(APPEND ZEPHYR_EXTRA_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/drivers")
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    
    project(nau7802-test-delete-me)
    
    target_sources(app PRIVATE src/main.c)
    

    I created a stand alone Github repository with the example that now compiles.

Children
No Data
Related