cancel
Showing results for 
Search instead for 
Did you mean: 

On STM32MP157C-DK2 board, how to config and enable SPI5 under u-boot and linux runtime?

HZhu.12
Associate II

With STM32MP157C-DK2, I like to exercise SPI5 hardware, to use this interface to do talk to FPGA and DSP chips. And I need to use SPI5 in both U-boot and Linux runtime, here I got some issues to enable the SPI5 device.

1, Within U-boot.

How to enable SPI5 device and config pin mux.

I already recompiled u-boot source code and add in command of sspi, but when issue sspi under uboot terminal, it return failure, apparently the default SPI bus not even configured and enabled at all.

ubi   - ubi commands

ubifsload- load file from an UBIFS filesystem

ubifsls - list files in a directory

ubifsmount- mount UBIFS volume

ubifsumount- unmount UBIFS volume

ums   - Use the UMS [USB Mass Storage]

usb   - USB sub-system

usbboot - boot from USB device

version - print monitor, compiler and linker version

TRIFECTA> sspi

Invalid bus 0 (err=-19)

TRIFECTA> help sspi

sspi - SPI utility command

Usage:

sspi [<bus>:]<cs>[.<mode>] <bit_len> <dout> - Send and receive bits

<bus>   - Identifies the SPI bus

<cs>   - Identifies the chip select

<mode>  - Identifies the SPI mode to use

<bit_len> - Number of bits to send (base 10)

<dout>  - Hexadecimal string that gets sent

TRIFECTA>

2, Within Linux runtime.

I looked at device under /dev/ directory, there is no device mapped as “spidev�? or anything associated with “spi�?,

ST OpenSTLinux - Weston - (A Yocto Project Based Distro) 2.6-openstlinux-4.19-thud-mp1-19-02-20 stm32mp1 ttySTM0

stm32mp1 login: root (automatic login)

root@stm32mp1:~#

root@stm32mp1:~# ls -la /dev/spi*

ls: cannot access '/dev/spi*': No such file or directory

root@stm32mp1:~# ls -la /dev/*spi*

ls: cannot access '/dev/*spi*': No such file or directory

root@stm32mp1:~#

I reverted device tree binary .dtb file to string .dts file, and looks like SPI5 has been declared with status of “disabled�?, what’s the procedure to config and use SPI5 in linux side, I already succeed on using SPI4 at M4 side, but I guess here by default SPI5 is reserved for M4 core also, is there a way to enable SPI5 dynamically in runtime on linux side? Or I have to modify .dts file? What I need to do, please specify.

spi@44009000 {

#address-cells = <0x1>;

#size-cells = <0x0>;

compatible = "st,stm32h7-spi";

reg = <0x44009000 0x400>;

interrupts = <0x0 0x55 0x4>;

clocks = <0x5 0x86>;

resets = <0x5 0x4c4a>;

dmas = <0x7 0x55 0x400 0x1 0x7 0x56 0x400 0x1>;

dma-names = "rx", "tx";

power-domains = <0x12>;

status = "disabled";

pinctrl-names = "default", "sleep";

pinctrl-0 = <0x3c>;

pinctrl-1 = <0x3d>;

};

Yours: Hai

8 REPLIES 8
PatrickF
ST Employee

Hello,

SPI5 is not reserved for neither M4 or Linux.

status = "disabled" sound normal in one part of the DT, but you should have status = "okay" elsewhere.

Have you declared the SPI5 pins muxing ? Did you used CubeMX to get tjhis part of the DT related to SPI5 ?

You should also have DECPROT(STM32MP1_ETZPC_SPI5_ID, DECPROT_NS_RW, DECPROT_UNLOCK) in &etzpc section .

Did you edit your DT with help from https://wiki.st.com/stm32mpu/index.php/SPI_device_tree_configuration ?

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
HZhu.12
Associate II

​Hi, PatrickF:

Thank you for your help, I haven't touch device tree for Linux yet, I guess I have to do that modification to see /dev/spidev5 been populated under Linux, and do you have any instruction on how to enable SPI5 on u-boot? or the same instruction works for u-boot as well.

Yours: Hai

I'm not expert, but as far as I know, uBoot uses device tree as well, but I'm not sure there is native support of SPI with uBoot without additional changes.

Note: Please consider using trusted boot (TF-A + uBoot) as this will be the only officially supported boot sequence in future.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
HZhu.12
Associate II

​Thank you very much for suggestion of using trusted boot, because I am just beginning to debugging on basic boot, because when I build with "basic_defconfig", I saw both spl and uboot image generated, but with "trusted_defconfig", I found only uboot image generated, would not find anything imply "TF-A", would you help me where is TF-A image generated by uboot?

PatrickF
ST Employee

https://wiki.st.com/stm32mpu/index.php/STM32MP15_TF-A

and

https://wiki.st.com/stm32mpu/index.php/STM32MP1_Developer_Package_-_TF-A

could help you

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hello. I was trying to enable spi5 in stm32mp1 board but I get

spi_stm32 44009000.spi: clk rate = 0

[  74.133466] spi_stm32: probe of 44009000.spi failed with error -22

It indeed shows in clk_summary that spi5_k clock is 0. I found some information that this clock must be enabled in tf-a dts and I found that SPI5 is disabled there in rcc so I removed the line but it didn't help. Can you guide through this somehow ?

Did you use CubeMX to generate Device Tree with SPI5 enabled ? This could help to found out missing settings (e..g in rcc node you should not have CLK_SPI45_DISABLED).

Did you look at https://wiki.st.com/stm32mpu/wiki/STM32MP15_clock_tree

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Actually all of a sudden it started working although at first it didn't (or maybe dtb has not been rebuilt). I've made a patch like this for tf but to be honest it is more like "let's see what happens" and I don't actually know why it started working after first failure. Is there any comprehensive knowledge base base about trusted firmware and its settings in dts ? There is sth on the pages but is more like a glimpse of knowledge. I wonder why spi5_k clock in kernel returned 0 instead of sth more descriptive. Are there any examples of what to do when certain problems happens in the kernel regarding tf ? Every link, document or whatever on the matter would be appreciated.

---

 fdts/stm32mp157a-icorest-mx.dts | 8 ++++----

 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fdts/stm32mp157a-icorest-mx.dts b/fdts/stm32mp157a-icorest-mx.dts

index 9410038..c7d452e 100644

--- a/fdts/stm32mp157a-icorest-mx.dts

+++ b/fdts/stm32mp157a-icorest-mx.dts

@@ -217,10 +217,6 @@ clocks {

  CLK_DSI_DSIPLL

  CLK_STGEN_HSI

  CLK_USBPHY_HSE

- CLK_SPI2S1_DISABLED

- CLK_SPI2S23_DISABLED

- CLK_SPI45_DISABLED

- CLK_SPI6_DISABLED

  CLK_I2C46_PCLK5

  CLK_SDMMC3_HCLK2

  CLK_USBO_USBPHY

@@ -228,6 +224,10 @@ clocks {

  CLK_CEC_DISABLED

  CLK_I2C12_PCLK1

  CLK_I2C35_DISABLED

+ CLK_SPI2S1_PLL4P

+ CLK_SPI2S23_PLL4P

+ CLK_SPI45_PCLK2

+ CLK_SPI6_PCLK5

  CLK_UART1_HSI

  CLK_UART24_HSE

  CLK_UART35_PCLK1

-- 

2.11.0