cancel
Showing results for 
Search instead for 
Did you mean: 

How can i enable SPI5 on STM32MP157-DK1

MÇerçi
Associate III

Hi,

Im working with STM32MP157A-DK1 board. Im working on the linux side, need to write C/C++ code for saving data into a SD card. I need to use SPI to get data from RF transceiver. I built linux and kernel as in this link:

https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157x-DK2/Develop_on_Arm%C2%AE_Cortex%C2%AE-A7/Modify,_rebuild_and_reload_the_Linux%C2%AE_kernel

Then i looked for articles on SPI, these ones especially :

https://wiki.st.com/stm32mpu/wiki/SPI_overview#Kernel_configuration

https://wiki.st.com/stm32mpu/wiki/How_to_use_SPI_from_Linux_userland_with_spidev#pnl-glhvfb87ri

https://wiki.st.com/stm32mpu/wiki/SPI_device_tree_configuration#How_to_configure_the_DT_using_STM32CubeMX

https://wiki.st.com/stm32mpu/wiki/How_to_build_Linux_kernel_user_space_tools

https://wiki.st.com/stm32mpu/wiki/How_to_cross-compile_with_the_Developer_Package

And to be fair these are really good materials but i cant manage to be able to run spidev_test example.

i did rebuilt kernel , modules and tools ( also used make menuconfig and looked at SPI settings to make sure spi is enabled) , On the board i can see spi driver in this directory "/sys/bus/spi//drivers/" but the" devices/" directory is empty and can't see anything,

EDIT:

I did manage to activate SPI device i was editing the wrong .dts file, after editing stm32mp15x-dkxx.dtsi file i was able to see /spi0.0 device.

but i have another question now.

The GPIO pins for the MISO,MOSI and NSS how do i select them for SPI5 ?

3 REPLIES 3
MÇerçi
Associate III

I did manage to activate SPI device i was editing the wrong .dts file, after editing stm32mp15x-dkxx.dtsi file i was able to see /spi0.0 device.

but i have another question now.

The GPIO pins for the MISO,MOSI and NSS how do i select them for SPI5 ?

Hi @Mustafa Çerçi​ ,

Nice to read you are progressing.

FYI .dtsi file not supposed to be modify.

Proper WoW is to override the node property in your custom board dts.

Olivier

Olivier GALLIEN
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.

@Community member​  thank you also thank you for fast reply.

but i have a another question in the dtsi i wrote spi5 segment like this:

&spi5 {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&spi5_pins_a>;
	pinctrl-1 = <&spi5_sleep_pins_a>;
	cs-gpios = <&gpioz 3 0>;
	status = "okay";
	
	/* USER CODE BEGIN spi5 */
	
	spidev@0{
	        compatible = "spidev";	
	        reg = <0>;  /* CS #0 */
	        spi-max-frequency = <1800000>;
	    };
};

my question is the gpios. this line "cs-gpios = <&gpioz 3 0>;" appears wrong to me because in the example these are for spi4 i guess but i need to use spi5 in wiki i found this:

https://wiki.st.com/stm32mpu/wiki/STM32MP157x-DKx_-_hardware_description#GPIO_expansion_connector

0693W000006Fxr3QAC.pngwhich pins should write in to "cs-gpios = <&gpioz 3 0>;" this function can figure it out; my guess is "cs-gpios= <&gpiof 6 0>" but im not sure