Skip to main content
Associate III
July 30, 2024
Question

mpu-mcu spi communication

  • July 30, 2024
  • 1 reply
  • 1926 views

Hi, @Erwan SZYMANSKI @KDJEM.1 @Andrew Neil @KDJEM.1 @mƎALLEm 

I am trying to establish SPI communication between my Nucleo-G431RB and STM32MP157F-DK2 boards. I am finding the documentation quite confusing. I attempted to use STM32CubeIDE, but it resulted in various issues, possibly due to using Ubuntu.

Could you help me set this up without using STM32CubeIDE or the HAL library? I have a distribution package for the STM32MP157F-DK2 and have patched the DTS file to enable SPI according to the STM32 wiki. Now, I need to add a custom application to my own created layer in the distribution package and write the driver. However, I am having trouble finding resources to accomplish this.

 

 

1 reply

nesnesAuthor
Associate III
July 30, 2024

Here are my patches. I built the image and flashed it to the mp1 board.

diff --git a/stm32mp15-pinctrl.dtsi.orig b/stm32mp15-pinctrl.dtsi
index 20b4f0d..bff8e08 100644
--- a/arch/arm/boot/dts/stm32mp15-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stm32mp15-pinctrl.dtsi
@@ -2028,14 +2028,15 @@
 	spi5_pins_a: spi5-0 {
 		pins1 {
 			pinmux = <STM32_PINMUX('F', 7, AF5)>, /* SPI5_SCK */
-				 <STM32_PINMUX('F', 9, AF5)>; /* SPI5_MOSI */
+					<STM32_PINMUX('F', 9, AF5)>; /* SPI5_MOSI */
 			bias-disable;
 			drive-push-pull;
 			slew-rate = <1>;
 		};
 
 		pins2 {
-			pinmux = <STM32_PINMUX('F', 8, AF5)>; /* SPI5_MISO */
+			pinmux = <STM32_PINMUX('F', 8, AF5)>, /* SPI5_MISO */
+					<STM32_PINMUX('F', 6, AF5)>; /* SPI5_NSS */
 			bias-disable;
 		};
 	};
@@ -2043,11 +2044,13 @@
 	spi5_sleep_pins_a: spi5-sleep-0 {
 		pins {
 			pinmux = <STM32_PINMUX('F', 7, ANALOG)>, /* SPI5_SCK */
-				 <STM32_PINMUX('F', 8, ANALOG)>, /* SPI5_MISO */
-				 <STM32_PINMUX('F', 9, ANALOG)>; /* SPI5_MOSI */
+					<STM32_PINMUX('F', 8, ANALOG)>, /* SPI5_MISO */
+					<STM32_PINMUX('F', 9, ANALOG)>, /* SPI5_MOSI */
+					<STM32_PINMUX('F', 6, ANALOG)>; /* SPI5_NSS */
 		};
 	};
 
+
 	stusb1600_pins_a: stusb1600-0 {
 		pins {
 			pinmux = <STM32_PINMUX('I', 11, GPIO)>;

 

diff --git a/stm32mp157f-dk2.dts.orig b/stm32mp157f-dk2.dts.spi
index 2462656..6ba6038 100644
--- a/arch/arm/boot/dts/stm32mp157f-dk2.dts
+++ b/arch/arm/boot/dts/stm32mp157f-dk2.dts
@@ -167,3 +167,19 @@
 		vddio-supply = <&v3v3>;
 	};
 };
+
+&spi5 {
+	pinctrl-names = "default", "sleep";
+	pinctrl-0 = <&spi5_pins_a>;
+	pinctrl-1 = <&spi5_sleep_pins_a>;
+	status = "okay";
+
+	#address-cells = <0>;
+	cs-gpios = <0>;
+	spi-slave;
+
+	slave {
+		compatible = "lwn,bk4";
+		spi-max-frequency = <10000000>;
+	};
+ };

 

nesnesAuthor
Associate III
July 31, 2024

@Erwan SZYMANSKI  , I am waiting for your response and help.