jaredwolff Hello Jared. I have tried the change you suggest, and am not quite out of the woods. I can now see from the compile time errors how you were directed to that specific line in main.c, the line:
dev_accelerometer = DEVICE_DT_GET(DT_NODELABEL(needed_device_tree_node_label_here);
I effected your change, and commented out an invalid function call, removing one warning. I am still getting a similar failure for what looks like an incomplete device tree symbol. Tail end of build messages here:
.
.
[187/194] Linking C executable zephyr/zephyr_prebuilt.elf
[194/194] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 41596 B 48 KB 84.63%
SRAM: 22944 B 256 KB 8.75%
IDT_LIST: 0 GB 2 KB 0.00%
[30/177] Building C object CMakeFiles/app.dir/src/main.c.obj
FAILED: CMakeFiles/app.dir/src/main.c.obj
ccache /opt/zephyr-sdk-0.12.4/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DBUILD_VERSION=v2.6.0-rc1-ncs1 -DKERNEL -DNRF9160_XXAA -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-driver-demo/build/zephyr/include/generated -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/soc/arm/nordic_nrf/nrf91 -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/nrf/include -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-drivers/drivers -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-drivers/drivers/kionix/kx132-1211 -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/modules/hal/cmsis/CMSIS/Core/Include -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/modules/hal/nordic/nrfx -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/modules/hal/nordic/nrfx/drivers/include -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/modules/hal/nordic/nrfx/mdk -I/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/modules/hal_nordic/nrfx/. -isystem /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/lib/libc/minimal/include -isystem /opt/zephyr-sdk-0.12.4/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.2.0/include -isystem /opt/zephyr-sdk-0.12.4/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.2.0/include-fixed -isystem /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/nrfxlib/crypto/nrf_cc310_platform/include -Os -imacros /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-driver-demo/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-driver-demo=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/ted/projects/zephyr-based/z4-sandbox-kionix-work=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles/app.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-driver-demo/src/main.c
In file included from /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/toolchain/gcc.h:69,
from /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/toolchain.h:43,
from /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/kernel_includes.h:19,
from /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/kernel.h:17,
from /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/zephyr.h:18,
from /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-driver-demo/src/main.c:7:
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-driver-demo/src/main.c: In function 'main':
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/device.h:80:39: error: '__device_dts_ord_DT_N_NODELABEL_DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_kx132_1211_1f_ORD' undeclared (first use in this function); did you mean 'DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_S_kx132_1211_1f_ORD'?
80 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
| ^~~~~~~~~
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/toolchain/common.h:124:26: note: in definition of macro '_DO_CONCAT'
124 | #define _DO_CONCAT(x, y) x ## y
| ^
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/device.h:80:31: note: in expansion of macro '_CONCAT'
80 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
| ^~~~~~~
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/device.h:257:37: note: in expansion of macro 'DEVICE_NAME_GET'
257 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_NAME(node_id))
| ^~~~~~~~~~~~~~~
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/device.h:271:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
271 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
| ^~~~~~~~~~~~~~~~~~
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-driver-demo/src/main.c:95:25: note: in expansion of macro 'DEVICE_DT_GET'
95 | dev_accelerometer = DEVICE_DT_GET(DT_NODELABEL(KX132_1211)); // (kionix_sensor));
| ^~~~~~~~~~~~~
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/device.h:80:39: note: each undeclared identifier is reported only once for each function it appears in
80 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
| ^~~~~~~~~
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/toolchain/common.h:124:26: note: in definition of macro '_DO_CONCAT'
124 | #define _DO_CONCAT(x, y) x ## y
| ^
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/device.h:80:31: note: in expansion of macro '_CONCAT'
80 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
| ^~~~~~~
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/device.h:257:37: note: in expansion of macro 'DEVICE_NAME_GET'
257 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_NAME(node_id))
| ^~~~~~~~~~~~~~~
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/zephyr/include/device.h:271:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
271 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
| ^~~~~~~~~~~~~~~~~~
/home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-driver-demo/src/main.c:95:25: note: in expansion of macro 'DEVICE_DT_GET'
95 | dev_accelerometer = DEVICE_DT_GET(DT_NODELABEL(KX132_1211)); // (kionix_sensor));
| ^~~~~~~~~~~~~
[34/177] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/bitarray.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/ted/projects/zephyr-based/z4-sandbox-kionix-work/kionix-driver-demo/build
ted@localhost:~/projects/zephyr-based/z4-sandbox-kionix-work/kionix-driver-demo$
Haven’t yet got my head wrapped around Device Tree and Zephyr macros system, but I notice there is a tracing of macros, and macro expansions. The build error “traces” of these pre-processor build steps seem to be repeated: there is the undefined symbol, and then a series of six macro definitions beginning with the “deepest” macro. These six expansions then repeat before the next error is listed, or compilation terminates altogether.
Is there a more specific Zephyr documentation I can review to understand DEVICE_DT_GET macro better? I am mis-providing something which DEVICE_DT_GET needs to process. I will watch Marti Bolivar’s Zephyr and Device Tree video again. I recall him describe DEVICE_DT_GET as a newer feature in Zephyr. This macro only became available in Zephyr 2.5.0.
A summary of how device tree overlay files, I think specifically device tree nodes and their key-value pairs map to Zephyr macros would be really helpful. The minus character in a couple of my first node labels turned out to be illegal in the eventually generated C code. (Only trying to spell out a part name as it appears in datasheets and app notes) Would be good to know which device tree node key-value pairs must have values whose spelling and naming convention strictly honors C variable and macro naming conventions.