&pinctrl { spi_master1_default: spi_master1_default { group1 { psels = , , ; }; }; spi_master1_sleep: spi_master1_sleep { group1 { psels = , , ; low-power-enable; }; }; spi_master0_default: spi_master0_default { group1 { psels = , , ; }; }; spi_master0_sleep: spi_master0_sleep { group1 { psels = , , ; low-power-enable; }; }; }; &gpio0 { status = "okay"; }; &gpio1 { status = "okay"; }; &spi4 { compatible = "nordic,nrf-spim"; status = "okay"; pinctrl-0 = <&spi_master1_default>; pinctrl-1 = <&spi_master1_sleep>; pinctrl-names = "default", "sleep"; /*cs-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>, <&gpio1 10 GPIO_ACTIVE_LOW>; reg_spi_master1: spi-dev-a@0 { reg = <0>; compatible = "spi-device"; }; reg_spi_master2: spi-dev-a@1 { reg = <1>; compatible = "spi-device"; };*/ }; &spi0{ compatible = "nordic,nrf-spim"; status = "okay"; pinctrl-0 = <&spi0_default>; pinctrl-1 = <&spi0_sleep>; pinctrl-names = "default", "sleep"; /*cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>, <&gpio0 19 GPIO_ACTIVE_LOW>; reg_spi0_master1: spi-dev-a@0 { reg = <0>; }; reg_spi0_master2: spi-dev-b@1 { reg = <1>; };*/ }; When configuring like above in overlay In main #define SPI1_MASTER DT_NODELABEL(spi4) #define SPI0_MASTER DT_NODELABEL(spi0) #define SPI0_MASTER_CS_GPIO DT_NODELABEL(gpio0) #define SPI1_MASTER_CS_GPIO DT_NODELABEL(gpio1) const struct device *spi_dev; const struct device *gpio_dev; struct spi_config spi_cfg={ .operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB | SPI_MODE_CPOL | SPI_MODE_CPHA, .frequency = 4000000, .slave = 0, }; void Init(uint8_t slave) { spi_dev = DEVICE_DT_GET(SPI0_MASTER); gpio_dev = DEVICE_DT_GET(SPI0_MASTER_CS_GPIO); spi_cfg.cs.gpio.port=gpio_dev; spi_cfg.cs.gpio.pin = 11; spi_cfg.cs.gpio.dt_flags = GPIO_ACTIVE_HIGH; } Giving error only for SPI0_MASTER. when all are SPI1_MASTER, it is building error: '__device_dts_ord_105' undeclared (first use in this function); did you mean '__device_dts_ord_15'? 92 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id) | ^~~~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/toolchain/common.h:137:26: note: in definition of macro '_DO_CONCAT' 137 | #define _DO_CONCAT(x, y) x ## y | ^ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:92:33: note: in expansion of macro '_CONCAT' 92 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id) | ^~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:229:37: note: in expansion of macro 'DEVICE_NAME_GET' 229 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id)) | ^~~~~~~~~~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:246:34: note: in expansion of macro 'DEVICE_DT_NAME_GET' 246 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id)) | ^~~~~~~~~~~~~~~~~~ C:/Users/nrf_Projects/ad_spi/src/main.c:40:19: note: in expansion of macro 'DEVICE_DT_GET' 40 | spi_dev = DEVICE_DT_GET(SPI0_MASTER); | ^~~~~~~~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:92:41: note: each undeclared identifier is reported only once for each function it appears in 92 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id) | ^~~~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/toolchain/common.h:137:26: note: in definition of macro '_DO_CONCAT' 137 | #define _DO_CONCAT(x, y) x ## y | ^ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:92:33: note: in expansion of macro '_CONCAT' 92 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id) | ^~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:229:37: note: in expansion of macro 'DEVICE_NAME_GET' 229 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id)) | ^~~~~~~~~~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:246:34: note: in expansion of macro 'DEVICE_DT_NAME_GET' 246 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id)) | ^~~~~~~~~~~~~~~~~~ C:/Users/nrf_Projects/ad_spi/src/main.c:40:19: note: in expansion of macro 'DEVICE_DT_GET' 40 | spi_dev = DEVICE_DT_GET(SPI0_MASTER); /* In overlay file spi1_master:&spi4 { compatible = "nordic,nrf-spim"; status = "okay"; pinctrl-0 = <&spi_master1_default>; pinctrl-1 = <&spi_master1_sleep>; pinctrl-names = "default", "sleep"; cs-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>, <&gpio1 10 GPIO_ACTIVE_LOW>; reg_spi_master1: spi-dev-a@0 { reg = <0>; compatible = "spi-device"; }; reg_spi_master2: spi-dev-a@1 { reg = <1>; compatible = "spi-device"; }; }; In main #define SPI1_MASTER DT_NODELABEL(spi1_master) spi_dev = DEVICE_DT_GET(SPI1_MASTER); Giving below error error: '__device_dts_ord_DT_N_NODELABEL_spi1_master_ORD' undeclared (first use in this function) 92 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id) | ^~~~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/toolchain/common.h:137:26: note: in definition of macro '_DO_CONCAT' 137 | #define _DO_CONCAT(x, y) x ## y | ^ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:92:33: note: in expansion of macro '_CONCAT' 92 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id) | ^~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:229:37: note: in expansion of macro 'DEVICE_NAME_GET' 229 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id)) | ^~~~~~~~~~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:246:34: note: in expansion of macro 'DEVICE_DT_NAME_GET' 246 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id)) | ^~~~~~~~~~~~~~~~~~ C:/Users/nrf_Projects/spi/src/main.c:40:19: note: in expansion of macro 'DEVICE_DT_GET' 40 | spi_dev = DEVICE_DT_GET(SPI1_MASTER); | ^~~~~~~~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:92:41: note: each undeclared identifier is reported only once for each function it appears in 92 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id) | ^~~~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/toolchain/common.h:137:26: note: in definition of macro '_DO_CONCAT' 137 | #define _DO_CONCAT(x, y) x ## y | ^ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:92:33: note: in expansion of macro '_CONCAT' 92 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id) | ^~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:229:37: note: in expansion of macro 'DEVICE_NAME_GET' 229 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id)) | ^~~~~~~~~~~~~~~ C:/ncs/v2.8.0/zephyr/include/zephyr/device.h:246:34: note: in expansion of macro 'DEVICE_DT_NAME_GET' 246 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id)) | ^~~~~~~~~~~~~~~~~~ C:/Users/nrf_Projects/spi/src/main.c:40:19: note: in expansion of macro 'DEVICE_DT_GET' 40 | spi_dev = DEVICE_DT_GET(SPI1_MASTER); | ^~~~~~~~~~~~~ */