I'm learning how to write a new device driver for Zephyr 3 using NCS version 2.6.0.
I have watched the ZDS summit video and looked through the shared git repo.
I have created an overlay, CMakeLists.txt files, Kconfig chain, bindings and adjusted prj.conf and main.c
I started with the simple hello world sample.
I have this source code now:
#define MYSENSOR_DEVICE_NODE DT_NODELABEL(mysensor) #if DT_NODE_EXISTS(MYSENSOR_DEVICE_NODE) #if DT_NODE_HAS_STATUS(MYSENSOR_DEVICE_NODE, okay) static const struct device *fpsensor = DEVICE_DT_GET(MYSENSOR_DEVICE_NODE); #else #error "mysensor status is not okay, thus disabled in devicetree" #endif #else #error "mysensor node could not be found in devicetree" #endif int main(void) { if (!device_is_ready(fpsensor)) { LOG_ERR("unable to get the device ready"); return -ENODEV; } else { LOG_INF("initialized successfully"); } LOG_INF("starting while loop"); while(true) { LOG_INF("Hello World from RTT! %s", CONFIG_BOARD); k_msleep(1000); } return 0; }
I have used the macros to confirm my sensor can be found and has status okay. Otherwise it will print the error.
I also checked the generated ./build/zephyr/zephyr.dts to check if my sensor is present and has status okay.
I also checked the generated ./build/zephyr/.config to check if my sensor is enabled (with y).
I always do pristine build, but still the compiler complains with:
src/main.c:40: undefined reference to `__device_dts_ord_125'
What could be wrong?