Currently working on a nrf52dk_nrf52832 kit. I have a SPI flash that I am trying to use - I am using the nrf SDK ncs v1.9.1.
I know I can use any of the GPIO pins for SPI. I have tried all of the following to try to get access to my spi0 in the device tree file.
/* Option 1: by node label */ #define MY_SERIAL DT_NODELABEL(serial0) /* Option 2: by alias */ #define MY_SERIAL DT_ALIAS(my_serial) /* Option 3: by chosen node */ #define MY_SERIAL DT_CHOSEN(zephyr_console) /* Option 4: by path */ #define MY_SERIAL DT_PATH(soc, serial_40002000)
My .overlay file is being recognized and my changes are reflected in the zephyr.dts file. However, when I try to access the MY_SERIAL variable, in this case,
I am met with this error.
In file included from c:\Users\path\spiFlash.h:15,
from c:\Users\path\main.c:20:
../path/main.c: In function 'main': c:\Users\path\devicetree_unfixed.h:5189:36: error: 'DT_N_S_soc_S_spi_40003000' undeclared (first use in this function); did you mean 'DT_N_S_soc_S_spi_40003000_ORD'?
5189 | #define DT_N_ALIAS_MY_SERIAL DT_N_S_soc_S_spi_40003000
| ^~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\path\devicetree.h:3022:24: note: in expansion of macro 'DT_N_ALIAS_sp'
3022 | #define DT_CAT(a1, a2) a1 ## a2
| ^~
c:\Users\path\devicetree.h:213:25: note: in expansion of macro 'DT_CAT'
213 | #define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
| ^~~~~~
c:\Users\path\spiFlash.h:33:19: note: in expansion of macro 'DT_ALIAS'
33 | #define MY_SERIAL DT_ALIAS(MY_SERIAL)
| ^~~~~~~~
c:\Users\path\main.c:58:27: note: in expansion of macro 'MY_SERIAL'
58 | printk("DEVICENODE: %i", MY_SERIAL);
| ^~~~~~~~~
c:\Users\path\devicetree_unfixed.h:5189:36: note: each undeclared identifier is reported only once for each function it appears in
5189 | #define DT_N_ALIAS_MY_SERIAL DT_N_S_soc_S_spi_40003000
| ^~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\path\devicetree.h:3022:24: note: in expansion of macro 'DT_N_ALIAS_MY_SERIAL'
3022 | #define DT_CAT(a1, a2) a1 ## a2
| ^~
c:\Users\path\devicetree.h:213:25: note: in expansion of macro 'DT_CAT'
213 | #define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
| ^~~~~~
c:\Users\path\spiFlash.h:33:19: note: in expansion of macro 'DT_ALIAS'
33 | #define MY_SERIAL DT_ALIAS(MY_SERIAL)
| ^~~~~~~~
c:\Users\path\main.c:58:27: note: in expansion of macro 'MY_SERIAL'
58 | printk("DEVICENODE: %i", MY_SERIAL);
My overlay file is included in boards/ in my project. No matter what I try device tree doesn't seem to recognize my spi0 port regardless of how I try to reference it.
Any thoughts as to why this is?