Skip to main content
Visitor II
October 23, 2019
Question

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

  • October 23, 2019
  • 4 replies
  • 3613 views

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

    This topic has been closed for replies.

    4 replies

    Technical Moderator
    October 24, 2019

    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 ?

    HZhu.12Author
    Visitor II
    October 24, 2019

    ​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

    Technical Moderator
    October 25, 2019

    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.

    HZhu.12Author
    Visitor II
    October 25, 2019

    ​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?

    Technical Moderator
    October 25, 2019
    Visitor II
    March 4, 2021

    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 ?

    Technical Moderator
    March 4, 2021

    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.