Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DT_NODE_EXISTS() is true but DEVICE_DT_GET() expands to nothing #87335

Closed
5frank opened this issue Mar 19, 2025 · 4 comments
Closed

DT_NODE_EXISTS() is true but DEVICE_DT_GET() expands to nothing #87335

5frank opened this issue Mar 19, 2025 · 4 comments
Assignees
Labels
area: Devicetree bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@5frank
Copy link

5frank commented Mar 19, 2025

Describe the bug

If a device driver depends on FOO and FOO=n, then DT_NODE_EXISTS(foo_dev) is true but DEVICE_DT_GET(foo_dev) expands to nothing
(i.e compiler error undefined reference to __device_dts_ord_NN)

To Reproduce
See attached app. It uses the ws2812-gpio driver for ESP32 but the driver depends on a nordic SOC.

reproduce_app.zip

Environment (please complete the following information):

  • OS: Linux/Debian
  • CMake version: 3.22.3
  • toolchain: zephyr 0.16.0
  • zephyr latest (SHA 20faa0e)
@5frank 5frank added the bug The issue is a bug, or the PR is fixing a bug label Mar 19, 2025
@5frank
Copy link
Author

5frank commented Mar 19, 2025

Perhaps I should add that there is a Kconfig warning on 'unsatisfied dependencies' but I still think it qualifies as bug as DT_NODE_EXISTS() is quite useful in code that runs on different boards.

@pdgendt
Copy link
Collaborator

pdgendt commented Mar 19, 2025

I think this is intended behavior, there's no limitation for DT_NODE_EXISTS to "know" about dependencies, it simply verifies the generated device tree. It's up to the user to set the status to "disabled" in this case.

The linker error undefined reference to __device_dts_ord_NN has been the subject of many discussions and could be improved upon.

@pdgendt
Copy link
Collaborator

pdgendt commented Mar 19, 2025

It is even stated in the troubleshooting documentation that Kconfig option need to be enabled.

@nashif nashif added the priority: low Low impact/importance bug label Mar 25, 2025
@mbolivar
Copy link
Contributor

This is not a bug. In addition to the docs that @pdgendt pointed you to, you can also watch my talk https://www.youtube.com/watch?v=w8GgP3h0M8M for an explanation of why you are seeing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

4 participants