Re: DTS own node DT_N_S_ undeclared

Kumar Gala

On Mar 5, 2021, at 11:26 AM, Piotr Barszczewski <piotr@...> wrote:


Thank you for your response. My code is very similar to with the change that I’ve refactored it to accept different instances instead of supporting single #define VBATT DT_PATH(vbatt) . It’s practically 1:1 with what I needed so it seemed more reasonable to approach this way.

Regarding #define VBATT_LIPO DT_NODELABEL(vbatt_lipo) and #define VBATT_LIPO DT_PATH(vbatt, vbatt0) I’ve tried this but the result is that in the end

/* Existence and alternate IDs: */
#define DT_N_S_vbatt_S_vbatt0_EXISTS 1
#define DT_N_INST_0_voltage_divider DT_N_S_vbatt_S_vbatt0
#define DT_N_NODELABEL_vbatt_lipo DT_N_S_vbatt_S_vbatt0

Always points to non-existing DT_N_S_vbatt_S_vbatt0. It’s not clear to me where it should it be defined if not from DTS.

Best regards
So you are seeing correct behavior. The are several ways to get a NODE reference (DT_PATH and DT_NODELABEL) are 2 of them. They should expand to DT_N_S_vbatt_S_vbatt0. (This is meant to be concatenated with other identifies to resolve to an actual define in the generated header - via the macros on devicetree.h). It will not resolve to a meaningful value that can be compiled by itself.

It has to be used in connection with another macro in devicetree.h to get some data from the dts node.

For example if you wanted the "output-ohms” for vbatt0 you’d do something like:

int out_ohms = DT_PROP(VBATT_LIPO, output_ohms);

That would resolve to:

int out_ohms = 3300000;

- k

Join to automatically receive all group messages.