Re: Confusion with generated devicetree_unfixed.h file #devicetree

Kumar Gala <galak.kernel@...>

On Aug 4, 2022, at 12:28 PM, Dominic via <> wrote:

Hello All,

I am running into an issue when trying to reference a #define from the generated devicetree_unfixed.h file.

#define DT_N_S_gpio_keys_S_gpio_18_EXISTS 1
#define DT_N_ALIAS_mux_en DT_N_S_gpio_keys_S_gpio_18
#define DT_N_NODELABEL_mux_enable DT_N_S_gpio_keys_S_gpio_18

When I reference DT_N_ALIAS_mux_en in my application code, I am getting an error that DT_N_S_gpio_keys_S_gpio_18 is not defined. I have used grep to try to find instances of that string and only seen it shown in devicetree_unfixed.h and device_extern.h. Can someone point me in the right direction of what I may be missing or not understanding correctly when referencing devicetree_unfixed.h in application code?

In general the defines in devicetree_unfixed.h are not meant to be directly used. One should utilize the API/macros in devicetree.h.

So without having a snippet of how you are trying to use the alias mux_en. Its hard exactly to provide too much guidance/help. Can you also share the devicetree snippet for the alias & gpio-keys node you are referencing.

You should be doing something like:
DT_ALIAS(mux_en) /* will give you a node identifier, not useful by itself */

You can possibly do something like (not 100% sure that will work as I’m not sure what the alias looks like):
DT_GPIO_PIN(DT_ALIAS(mux_en), gpios)

- k

Join { to automatically receive all group messages.