Hello !
I'm trying to adapt the code from the master-slave SPI example (https://github.com/too1/ncs-spi-master-slave-example) for my nRF54L15 development kit.
The master part runs smoothly, but when it comes to the slave, I get a linking error on build (undefined reference to `__device_dts_ord_72' ).
When I look in build/zephyr/include/generated.devicetree_generated.h, I have Node 72 = /soc/peripheral@50000000/spi@c8000
When I look in build/zephyr/zephyr.dts, I have :
spi22: spi_slave: spi@c8000 { compatible = "nordic,nrf-spis"; #address-cells = < 0x1 >; #size-cells = < 0x0 >; reg = < 0xc8000 0x1000 >; interrupts = < 0xc8 0x1 >; max-frequency = < 0x7a1200 >; easydma-maxcnt-bits = < 0x10 >; status = "okay"; pinctrl-0 = < &spi_slave_default >; pinctrl-1 = < &spi_slave_sleep >; pinctrl-names = "default", "sleep"; cs-gpios = < &gpio1 0x0 0x1 >; def-char = < 0x0 >; };
My .overlay file look like this :
//Disable everything that could collide, test only &spi20 { status = "disabled"; }; &spi21 { status = "disabled"; }; &spi30 { status = "disabled"; }; &i2c20 { status = "disabled"; }; &i2c21 { status = "disabled"; }; &i2c22 { status = "disabled"; }; &i2c30 { status = "disabled"; }; &uart30 { status = "disabled"; }; &uart22 { status = "disabled"; }; &spi22{ status = "okay"; }; &pinctrl { spi_slave_default: spi_slave_default { group1 { psels = <NRF_PSEL(SPIS_MOSI, 1, 2)>, <NRF_PSEL(SPIS_SCK, 1, 1)>, <NRF_PSEL(SPIS_MISO, 1, 3)>; }; }; spi_slave_sleep: spi_slave_sleep { group1 { psels = <NRF_PSEL(SPIS_MOSI, 1, 2)>, <NRF_PSEL(SPIS_SCK, 1, 1)>, <NRF_PSEL(SPIS_MISO, 1, 3)>; low-power-enable; }; }; }; spi_slave: &spi22 { compatible = "nordic,nrf-spis"; status = "okay"; max-frequency = <DT_FREQ_M(8)>; pinctrl-0 = <&spi_slave_default>; pinctrl-1 = <&spi_slave_sleep>; pinctrl-names = "default", "sleep"; cs-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>; def-char = <0>; };
In my .conf file, I have enabled CONFIG_SPI and CONFIG_SPI_SLAVE.
the simplified main.c looks like this :
#include <zephyr/kernel.h> #include <zephyr/device.h> #include <zephyr/devicetree.h> #include <zephyr/drivers/gpio.h> #include <zephyr/drivers/spi.h> #include <zephyr/logging/log.h> #define SPI_SLAVE DT_NODELABEL(spi_slave) const struct device *my_spi_slave; static void spi_slave_init(void) { my_spi_slave = DEVICE_DT_GET(SPI_SLAVE); if(!device_is_ready(my_spi_slave)){ LOG_ERR("SPI master device not ready!"); } } ... int main(void){ spi_slave_init(); }
Whenever I call spi_slave_init(), I have the error on build.
I tried using :
#if !DT_NODE_EXISTS(DT_NODELABEL(spi_slave)) #error "Invalid Node Identifier !" #endif
But it builds correctly (without the spi_slave_init() line).
I also tried to build the same main.c with a nRF52 config by adapting the .overlay file, and it runs smoothly.
If anyone has a clue, I would appreciate this !
Have a good day,
Hugo