Reputation: 149
I understand me asking this question might seem really easy but for some reason I am unable to get my mind around how to correctly get a Device Tree Binding in Zephyr.
I have the following overlay code:
&uart0{
gps0 {
compatible="u-blox,m10";
uart-baudrate=<115200>;
status="okay";
label="gps0";
};
};
To my understanding gps0 is a node name so I can use that to reference in my C code which I have done as below:
#define GPS_NODE DT_NODELABEL(gps0)
int main(void)
{
int err = 0;
static const struct device *gnss_dev = DEVICE_DT_GET(GPS_NODE);
// Check if the GNSS device is ready
if (!device_is_ready(gnss_dev)) {
LOG_ERR("GNSS device not ready");
return -ENODEV;
}
Hove given this call to get the device tree binding I am getting the following error:
__device_dts_ord_DT_N_NODELABEL_gps0_ORD) indicates that the device node for gps0 is not being properly recognized or linked during the build.
Zephyr Documentation I understand this error "likely means there’s a Kconfig issue preventing the device driver from being built, resulting in a reference that does not exist."
I am not sure what this means exactly but I think it would mean that I am not including the needed config headers that define the device binding I need which in this example would be UART and the GNSS configs.
the below is my current config file:
CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_ASYNC_API=y
CONFIG_UART_WIDE_DATA=y\
CONFIG_GNSS=y
CONFIG_GNSS_U_BLOX_M10=y
CONFIG_GNSS_SATELLITES=y
CONFIG_GNSS_DUMP=y
Despite this change I am getting the same error. I feel like there is a fundamental misconception I have about getting the device tree bindings. Can anyone help me with identifying what I am doing wrong?
Upvotes: -1
Views: 63
Reputation: 149
I have found the issue lies in the devicetree overlay specifically how I have defined the gps device.
IN reality the correct definition is the below:
&uart0 {
status = "okay";
gps0: gps {
compatible = "u-blox,m10";
uart-baudrate = <115200>;
status = "okay";
};
};
The reason why you need to use gps0: gps instead of just gps0 as the child header because this structure designates gsp0 as the node label and gps as the sub node. Since I was using the DT_NODELABEL macro the main code will look for the nodelabel which is gps0 when defined as above.
I think the label propoerty is depreciated so as a result it is not used for node labeling which was my misconception.
Once you know the basic understanding of node labels above the belo example from the Zephyr docs makes more sense:
/ {
a-node {
subnode_nodelabel: a-sub-node {
foo = <3>;
};
};
};
I hope this saves you alot of time.
Upvotes: 0