SPI2 definition is not found for STM32L476 device tree. How to add?


Yannis Damigos
 

Hi,

### How to add?

I may need to add the spi2 definition for STM32L476.

Where should I add the definition?
You don't need to add it. It exists in dts/arm/st/l4/stm32l471.dtsi

A. stm32l4.dtsi
B. nucleo_l476rg.dts> C. <BOARD>.overlay file located in the project directory

I just wonder why there is a definition for SPI2 for the supported board web page, but it is not actually supported by the device tree.
To enable it just add the following in nucleo_l476rg.dts or an overlay file:

&spi2 {
status = "okay";
};

Yannis


@yasokada
 
Edited

My environment:
Ubuntu 18.04 LTS
STM32L476 Nucleo_64 (hereafter STM32L476)
STM32F769 Discovery Kit (hereafter STM32F769)
Zephyr 2.1.0-rc1

### SPI2 for STM32L476 

https://docs.zephyrproject.org/latest/boards/arm/nucleo_l476rg/doc/index.html

In the above page, there is the definition of SPI2 (and SPI3).
However, when I west build the project with the SPI_2 set, I have the following errors.

```
zephyr/include/generated/generated_dts_board_fixups.h:199:27: error: 'DT_ST_STM32_SPI_FIFO_40003800_IRQ_0_PRIORITY' undeclared (first use in this function); did you mean 'DT_ST_STM32_SPI_FIFO_40013000_IRQ_0_PRIORITY'?
 #define DT_SPI_2_IRQ_PRI  DT_ST_STM32_SPI_FIFO_40003800_IRQ_0_PRIORITY
```

I found that the above is caused because there is no "spi2" definition in the stm32l4.dtsi.
On the other hand, there is "spi2" definition in stm32f7.dtsi, which is shown below. 

```
spi2: spi@40003800 {
compatible = "st,stm32-spi";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x40003800 0x400>;
clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00004000>;
interrupts = <36 5>;
status = "disabled";
label = "SPI_2";
};
```

### How to add?

I may need to add the spi2 definition for STM32L476.

Where should I add the definition?

A. stm32l4.dtsi
B. nucleo_l476rg.dts
C. <BOARD>.overlay file located in the project directory

I just wonder why there is a definition for SPI2 for the supported board web page, but it is not actually supported by the device tree.