This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Zephyr DT_N_INST_ symbols not defined in dtc output

Hello Nordic Devzone Community,

I am developing an out of tree driver for firmware running on an nRF9160.  I've made some progress and am getting closer to correctly implementing my driver code to connect with Zephyr Project 2.6.99 drivers API.  But I have some difficult to trace errors relating to two device related symbols that are not getting defined.  The two undefined symbols are DT_N_INST_0_kionix_kx132_BUS_P_label and DT_N_INST_0_kionix_kx132_P_label.

Excerpts from the longer build messages are:

In file included from /home/cpguest/embedded/z1-sandbox-2021-08-26/zephyr/include/arch/arm/aarch32/arch.h:20,
                 from /home/cpguest/embedded/z1-sandbox-2021-08-26/zephyr/include/arch/cpu.h:19,
                 from /home/cpguest/embedded/z1-sandbox-2021-08-26/zephyr/include/kernel_includes.h:33,
                 from /home/cpguest/embedded/z1-sandbox-2021-08-26/zephyr/include/kernel.h:17,
                 from /home/cpguest/embedded/z1-sandbox-2021-08-26/zephyr/include/init.h:11,
                 from /home/cpguest/embedded/z1-sandbox-2021-08-26/zephyr/include/device.h:29,
                 from /home/cpguest/embedded/z1-sandbox-2021-08-26/kionix-drivers/drivers/kionix/kx132-1211/kx132-1211.c:10:
/home/cpguest/embedded/z1-sandbox-2021-08-26/kionix-drivers/drivers/kionix/kx132-1211/kx132-1211.c: In function 'kx132_1211_init':
/home/cpguest/embedded/z1-sandbox-2021-08-26/zephyr/include/devicetree.h:301:40: error: 'DT_N_INST_0_kionix_kx132_BUS_P_label' undeclared (first use in this function); did you mean 'DT_N_INST_0_kionix_kx132_1211'?
  301 | #define DT_INST(inst, compat) UTIL_CAT(DT_N_INST, DT_DASH(inst, compat))
      |                                        ^~~~~~~~~

and similarly,

/home/cpguest/embedded/z1-sandbox-2021-08-26/kionix-drivers/drivers/kionix/kx132-1211/kx132-1211.c:156:20: note: (near initialization for 'kx132_api.channel_get')
In file included from /home/cpguest/embedded/z1-sandbox-2021-08-26/kionix-drivers/drivers/kionix/kx132-1211/kx132-1211.c:10:
/home/cpguest/embedded/z1-sandbox-2021-08-26/zephyr/include/devicetree.h:301:40: error: 'DT_N_INST_0_kionix_kx132_P_label' undeclared here (not in a function); did you mean 'DT_N_INST_0_kionix_kx132_1211'?
  301 | #define DT_INST(inst, compat) UTIL_CAT(DT_N_INST, DT_DASH(inst, compat))
      |                                        ^~~~~~~~~

I have this tiny "first foray" project hosted at Github at  github.com/.../kionix-driver-demo.  This project closely follows the file and directory structure of one Jared Wolff project "Air Quality Wing driver demo".  I'm using a west manifest file to manage my out-of-tree driver dependencies.  That part is working.

What is unclear from these error messages, aside from these needed symbols not being defined, is any advice from cmake, device tree compiler dtc or other build toolchain elements about where to review for likely corrections.  I have scrutinized my new device bindings file, and my board overlay file which connects the new sensor to the nRF9160 I2C bus instance number 1.  I don't see any errors in these device tree related files.

Can any Zephyr applications developers suggest specific places to look for sources of this build time error?  Are there errors in my overlay and bindings files?  Am I missing inclusion of needed Zephyr header files?

Thanks ahead of time for insights and help on this issue.

- Ted

Parents Reply
  • Good morning / good evening Håkon,

    Thank you for the fast response and specific help on my DT_DRV_COMPAT assignment stanza.  This symbol is the crux of this post's question, and the key mistake that was difficult for me to recognize.  I've applied your correction and moving on to next errors.

    The reference to a static function I also corrected.  That stems from working through two different example drivers for Zephyr based projects, one using an in-tree driver and another using an out-of-tree driver.  In particular I notice that the "lowest level" driver sources appear to have all their functions declared static.  Not sure why, not sure whether this helps to keep Zephyr RTOS memory footprint smaller than otherwise, or whether there is another reason for driver functions to be static.

    Thanks also for pointing out the non-share-able Git URL in my work's west.yml manifest file.  I've corrected that too.  It's my goal to be able to share this work of mine, and I would not have caught that issue without your or another person's help.

    Moving on to resolve next issues . . . again many thanks!

    - Ted

Children
  • Hi Ted,

      

    tedhavelka said:
    Thank you for the fast response and specific help on my DT_DRV_COMPAT assignment stanza.  This symbol is the crux of this post's question, and the key mistake that was difficult for me to recognize.  I've applied your correction and moving on to next errors.

    Not sure if you're a visual studio code user or not, but I found that this plugin has helped me resolve the "DTS -> C" (and generic device tree learning) scenario:

    https://marketplace.visualstudio.com/items?itemName=trond-snekvik.devicetree

    If you mark a section of dts and right-click on "copy c identifiers", it will copy the identifier to the clipboard.

    It also gives a overview of the device tree in other ways (see the screenshots)

     

    tedhavelka said:

    Thanks also for pointing out the non-share-able Git URL in my work's west.yml manifest file.  I've corrected that too.  It's my goal to be able to share this work of mine, and I would not have caught that issue without your or another person's help.

    Moving on to resolve next issues . . . again many thanks!

     Happy to help out, and I wish you happy development!

    Feel free to use devzone if you're stuck or have questions in the future!

     

    Kind regards,

    Håkon

Related