Skip to main content
Visitor II
August 29, 2019
Solved

Enable SPI4 on Linux Side of STM32MP157C-DK2

  • August 29, 2019
  • 2 replies
  • 1589 views

I would like to access a SPI Device (Ethercat Shield) over the Arduino Headers (SPI4). What do i have to do to get the /dev/spidev... device file in Linux ?

Sorry, but i'm still confused what is enabled, what do i have to enable in DTS files and when i have to rebuild the kernel (that works :) )

Thanks Daniel

    This topic has been closed for replies.
    Best answer by AntonioST

    You can use this DT fragment to enable spidev on spi4

    &spi4 {
    	pinctrl-names = "default", "sleep";
    	pinctrl-0 = <&spi4_pins_a>;
    	pinctrl-1 = <&spi4_sleep_pins_a>;
    	status = "okay";
    	cs-gpios = <&gpioe 11 0>;
     
    	spidev@0{
    		compatible = "spidev";
    		reg = <0>;
    		spi-max-frequency = <4000000>;
    		#address-cells = <1>;
    		#size-cells = <0>;
    	};
    };

    2 replies

    AntonioSTAnswer
    ST Employee
    August 30, 2019

    You can use this DT fragment to enable spidev on spi4

    &spi4 {
    	pinctrl-names = "default", "sleep";
    	pinctrl-0 = <&spi4_pins_a>;
    	pinctrl-1 = <&spi4_sleep_pins_a>;
    	status = "okay";
    	cs-gpios = <&gpioe 11 0>;
     
    	spidev@0{
    		compatible = "spidev";
    		reg = <0>;
    		spi-max-frequency = <4000000>;
    		#address-cells = <1>;
    		#size-cells = <0>;
    	};
    };

    Visitor II
    September 29, 2024

    Hi Antonio,

     

    I am currently reviewing one of the Linux kernel files (included in the latest Linux 6.1 source provided with OpenSTLinux SDK), called stm32mp1-op~stm32mp-r2-r0/linux-6.1.82/arch/arm/boot/dts/stm32mp15-pinctrl.dtsi.

    It seems that the definitions are outdated. There is definitely no "spi4_sleep_pins_a," so the example shown here several times causes the Linux kernel compilation error.

    Since I confirmed that my board, through UBOOT, boots files dependent on stm32mp157c-dk2, I added a section with SPI4 at the end of stm32mp157c-dk2.dtb to run an example from the page "How to use SPI from Linux userland with spidev". Unfortunately, during kernel compilation, I get the following error:

     

    arch/arm/boot/dts/stm32mp151.dtsi:1397.23-1410.6: ERROR (phandle_references): /soc/etzpc@5c007000/spi@44005000: Reference to non-existent node or label "spi4_sleep_pins_a"

     

     

    I am not sure if the statement "On the STM32MP157X-DKX discovery board, MOSI and MISO signals are accessible via the D12 and D11 pins" is still valid with respect to the definitions contained in the DTSI file.

     

    Could you provide corrections or guidance on how to run the SPI loopback example using the latest version of OpenSTLinux and the Linux kernel 6.1.88?

     

    DBuerAuthor
    Visitor II
    August 30, 2019

    Thanks a lot