Enabling uart on stm32mpu-dk2 using Ubuntu

Hello Robert,
Greetings !!

I have followed the instructions to run the ubuntu on stm32mpu-dk2 board , and it works fine.
I want to enable the uart in it so that I can interface external serial device to it.

I followed this instructions :
and after re-building(tools/rebuild.sh) the device tree and flashing
( Copy Kernel Device Tree Binaries

user@localhost:~$ sudo mkdir -p /media/rootfs/boot/dtbs/${kernel_version}/
sudo tar xfv ./armv7-lpae-multiplatform/deploy/${kernel_version}-dtbs.tar.gz -C /media/rootfs/boot/dtbs/${kernel_version}/)

on the sd card , I can see ttySTM1 up.But i am not able to do cat on /dev/ttySTM1( not getting any data)
I suspect the below logs which is somehow preventing the uart configuration.

[    1.955250] stm32-usart 4000f000.serial: IRQ index 1 not found
[    1.956534] stm32-usart 40010000.serial: IRQ index 1 not found
[    1.980712] stm32mp157-pinctrl soc:pin-controller@50002000: pin PI10 already requested by 4000f000.serial; cannot claim for 5a001000.display-controller
[    1.992969] stm32mp157-pinctrl soc:pin-controller@50002000: pin-138 (5a001000.display-controller) status -22
[    2.002963] stm32mp157-pinctrl soc:pin-controller@50002000: could not request pin 138 (PI10) from group PI10  on device soc:pin-controller@50002000
[    2.016140] stm32-display 5a001000.display-controller: Error applying setting, reverse things back
[    2.065532] stm32_rtc 5c004000.rtc: IRQ index 1 not found
[   28.071953] edt_ft5x06 0-0038: touchscreen probe failed

This seems to be some issue in the display driver.I have removed the LCD panel already and operating operating on minicom.

Can you please tell whats wrong here and how to avoid this conflict?

fyi : cat /dev/ttyS1 works fine on raspberry PI(on Raspberry PI ttyS1 is formed)

Br,
Rp

You have pins tied to both the LCD and Serial, this will make neither work… Remove the pinmux defines from the lcd section and make sure they are only in the serial node…

Regards,

Thanks @RobertCNelson
I commented out the PI10 ( LCD-HSYNC) pin and now there is no such error.

But strangely when I try to do cat /dev/ttySTM1 , no data comes out , unliek in raspberry PI where I can see the data being read

I get this on mpu board (see the rows and columns):

stty -a -F /dev/ttySTM1
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc

while on Raspberry PI
I get non zero rows and columns :slight_smile:

speed 9600 baud; rows 24; columns 80; line = 0; intr = AC; quit = ^ ; erase = ^?; kill => (ignore the special charcaters, I google translated the image due to lack of internet)

Also I noticed on RPI it shows tty device where as on stm32mpu it shows a dialout device

ls -l /dev/ttySTM1
crw-rw---- 1 root **dialout** 244, 1 Apr  1 17:24 /dev/ttySTM1

Could this be the reason? how to fix this?

‘dialout’ is the standard permission for serial tty interfaces, make sure your default user has access. (it should on my images…)

Double check your pinmux’ing, to make sure the pins are in the correct mode.

Regards,

for usart configuration looks fine
Getting the below logs :

dmesg | grep serial*
[ 1.954536] stm32-usart 4000f000.serial: IRQ index 1 not found
[ 1.954641] 4000f000.serial: ttySTM1 at MMIO 0x4000f000 (irq = 21, base_baud = 4000000) is a stm32-usart
[ 1.955323] stm32-usart 4000f000.serial: rx dma alloc failed
[ 1.955337] stm32-usart 4000f000.serial: interrupt mode used for rx (no dma)
[ 1.955348] stm32-usart 4000f000.serial: tx dma alloc failed
[ 1.955358] stm32-usart 4000f000.serial: interrupt mode used for tx (no dma)
[ 1.955823] stm32-usart 40010000.serial: IRQ index 1 not found
[ 1.955897] 40010000.serial: ttySTM0 at MMIO 0x40010000 (irq = 22, base_baud = 4000000) is a stm32-usart
[ 1.966974] stm32-usart 40010000.serial: rx dma alloc failed
[ 1.966987] stm32-usart 40010000.serial: interrupt mode used for rx (no dma)
[ 1.966998] stm32-usart 40010000.serial: tx dma alloc failed
[ 1.967008] stm32-usart 40010000.serial: interrupt mode used for tx (no dma)
[ 5.592421] systemd[1]: Created slice system-serial\x2dgetty.slice.

I am not sure if the bold log is the issue This was coming even without any modification

for dial out
i ran this command :

sudo adduser $USER dialout

but still no data on cat /dev/ttySTM1

Status returns okay:

root@arm:/home/ubuntu# ls /sys/devices/platform/soc/4000f000.serial/tty/
ttySTM1
root@arm:/home/ubuntu# cat /proc/device-tree/soc/serial@40010000/status
okayroot@arm:/home/ubuntu#

Regards,
Rp

Hi @raulp , can you please share your device tree changes and which pins on this board you are utilizing. I’ll test it here locally…

Regards,

added.

stm32mp157c-dk2.dts (2.6 KB) stm32mp15-pinctrl.dtsi (36.2 KB)

I am using VDD(pin 1),GND(pin 6),TX(Pin 8) and RX(Pin 10) on 40 pin header

Thanks,
Rp

Hello @RobertCNelson any chance to look into this?
Regards,
Rp

Make sure you aren’t driving power into VDD (pin 1)…

We might be missing something, i’ve been testing this patch:

diff --git a/arch/arm/boot/dts/stm32mp157c-dk2.dts b/arch/arm/boot/dts/stm32mp157c-dk2.dts
index 045636555ddd..829fd164992e 100644
--- a/arch/arm/boot/dts/stm32mp157c-dk2.dts
+++ b/arch/arm/boot/dts/stm32mp157c-dk2.dts
@@ -29,65 +29,6 @@ chosen {
 	};
 };
 
-&dsi {
-	status = "okay";
-	phy-dsi-supply = <&reg18>;
-
-	ports {
-		port@0 {
-			reg = <0>;
-			dsi_in: endpoint {
-				remote-endpoint = <&ltdc_ep1_out>;
-			};
-		};
-
-		port@1 {
-			reg = <1>;
-			dsi_out: endpoint {
-				remote-endpoint = <&panel_in>;
-			};
-		};
-	};
-
-	panel@0 {
-		compatible = "orisetech,otm8009a";
-		reg = <0>;
-		reset-gpios = <&gpioe 4 GPIO_ACTIVE_LOW>;
-		power-supply = <&v3v3>;
-		status = "okay";
-
-		port {
-			panel_in: endpoint {
-				remote-endpoint = <&dsi_out>;
-			};
-		};
-	};
-};
-
-&i2c1 {
-	touchscreen@38 {
-		compatible = "focaltech,ft6236";
-		reg = <0x38>;
-		interrupts = <2 2>;
-		interrupt-parent = <&gpiof>;
-		interrupt-controller;
-		touchscreen-size-x = <480>;
-		touchscreen-size-y = <800>;
-		status = "okay";
-	};
-};
-
-&ltdc {
-	status = "okay";
-
-	port {
-		ltdc_ep1_out: endpoint@1 {
-			reg = <1>;
-			remote-endpoint = <&dsi_in>;
-		};
-	};
-};
-
 &usart2 {
 	pinctrl-names = "default", "sleep", "idle";
 	pinctrl-0 = <&usart2_pins_c>;
@@ -95,3 +36,10 @@ &usart2 {
 	pinctrl-2 = <&usart2_idle_pins_c>;
 	status = "disabled";
 };
+
+&usart3 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&usart3_pins_a>;
+	status = "okay";
+	symlink = "stm32mp1/usart3";
+};

Which is built against 5.10.x:

git clone -b v5.10.x https://github.com/RobertCNelson/armv7-lpae-multiplatform.git
debian@arm:~$ dmesg | grep pin
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 129536
[    0.058827] pinctrl core: initialized pinctrl subsystem
[    0.128452] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOA bank added
[    0.129220] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOB bank added
[    0.129916] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOC bank added
[    0.130612] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOD bank added
[    0.131434] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOE bank added
[    0.132172] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOF bank added
[    0.132859] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOG bank added
[    0.133561] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOH bank added
[    0.134235] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOI bank added
[    0.134632] stm32mp157-pinctrl soc:pin-controller@50002000: Pinctrl STM32 initialized
[    0.136696] stm32mp157-pinctrl soc:pin-controller-z@54004000: GPIOZ bank added
[    0.136749] stm32mp157-pinctrl soc:pin-controller-z@54004000: Pinctrl STM32 initialized
debian@arm:~$ dmesg | grep serial
[    2.094423] 4000f000.serial: ttySTM1 at MMIO 0x4000f000 (irq = 31, base_baud = 4000000) is a stm32-usart
[    2.095293] stm32-usart 4000f000.serial: rx dma alloc failed
[    2.095321] stm32-usart 4000f000.serial: interrupt mode used for rx (no dma)
[    2.095343] stm32-usart 4000f000.serial: tx dma alloc failed
[    2.095360] stm32-usart 4000f000.serial: interrupt mode used for tx (no dma)
[    2.096686] 40010000.serial: ttySTM0 at MMIO 0x40010000 (irq = 32, base_baud = 4000000) is a stm32-usart
[    3.163826] stm32-usart 40010000.serial: rx dma alloc failed
[    3.168565] stm32-usart 40010000.serial: interrupt mode used for rx (no dma)
[    3.175622] stm32-usart 40010000.serial: tx dma alloc failed
[    3.181261] stm32-usart 40010000.serial: interrupt mode used for tx (no dma)
[    6.705226] systemd[1]: Created slice system-serial\x2dgetty.slice.

I’ll keep testing…

pinmux

Regards,

stm32mp15-pinctrl.dtsi (36.7 KB) stm32mp157c-dk2.dts (5.0 KB)
Hello @RobertCNelson ,
Thanks for the detailed feedback.

I modified and used the attached device tree configuration(very dirty :wink: ) , I have some success in reading the data , but it came only once , then it never. I am not sure if it is a fluke.
please have a look.(cat /dev/ttySTMx ) x = 1 , is able to read data continuously

below are my logs :

[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 113536
[ 0.220867] pinctrl core: initialized pinctrl subsystem
[ 1.695559] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOA bank added
[ 1.696024] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOB bank added
[ 1.696396] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOC bank added
[ 1.696760] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOD bank added
[ 1.697114] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOE bank added
[ 1.697458] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOF bank added
[ 1.697793] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOG bank added
[ 1.698149] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOH bank added
[ 1.698518] stm32mp157-pinctrl soc:pin-controller@50002000: GPIOI bank added
[ 1.698804] stm32mp157-pinctrl soc:pin-controller@50002000: Pinctrl STM32 initialized
[ 1.699748] stm32mp157-pinctrl soc:pin-controller-z@54004000: GPIOZ bank added
[ 1.699779] stm32mp157-pinctrl soc:pin-controller-z@54004000: Pinctrl STM32 initialized
[ 3.673539] asoc-audio-graph-card sound: cs42l51-hifi <-> 4400b004.audio-controller mapping ok
[ 3.681631] asoc-audio-graph-card sound: cs42l51-hifi <-> 4400b024.audio-controller mapping ok
[ 3.689624] asoc-audio-graph-card sound: i2s-hifi <-> 4000b000.audio-controller mapping ok

root@stm32mp1:~#
root@stm32mp1:~# dmesg | grep serial
[ 1.703053] 4000e000.serial: ttySTM3 at MMIO 0x4000e000 (irq = 53, base_baud = 4000000) is a stm32-usart
[ 1.703373] serial serial0: tty port ttySTM3 registered
[ 1.705057] 4000f000.serial: ttySTM1 at MMIO 0x4000f000 (irq = 54, base_baud = 4000000) is a stm32-usart
[ 1.707133] stm32-usart 40010000.serial: interrupt mode for rx (no dma)
[ 1.707158] stm32-usart 40010000.serial: interrupt mode for tx (no dma)
[ 1.707194] 40010000.serial: ttySTM0 at MMIO 0x40010000 (irq = 55, base_baud = 4000000) is a stm32-usart
[ 7.427900] systemd[1]: Created slice system-serial\x2dgetty.slice.

root@stm32mp1:~# cat /proc/device-tree/soc/serial@4000f000/status
okayroot@stm32mp1:~#

cat /proc/interrupts | grep serial
53: 173 0 stm32-exti-h-direct 27 Level 4000e000.serial
55: 1360 0 stm32-exti-h-direct 30 Level 40010000.serial

root@stm32mp1:~# cat /proc/tty/driver/stm32-usart
serinfo:1.0 driver revision:
0: uart:stm32-usart mmio:0x40010000 irq:55 tx:12643 rx:198 RTS|CTS|DTR|DSR|CD
1: uart:stm32-usart mmio:0x4000F000 irq:54 tx:0 rx:0 CTS|DSR|CD
3: uart:stm32-usart mmio:0x4000E000 irq:53 tx:14798 rx:1428 RTS|CTS|DTR|DSR|CD

root@stm32mp1:~# ls /proc/device-tree/soc/serial@4000f000/
clocks interrupts-extended pinctrl-1 reg wakeup-source
compatible name pinctrl-2 status
dma-names phandle pinctrl-names symlink
dmas pinctrl-0 power-domains uart-has-rtscts

root@stm32mp1:~# ls -d /proc/device-tree/soc/serial@*
/proc/device-tree/soc/serial@4000e000 /proc/device-tree/soc/serial@40018000
/proc/device-tree/soc/serial@4000f000 /proc/device-tree/soc/serial@40019000
/proc/device-tree/soc/serial@40010000 /proc/device-tree/soc/serial@44003000
/proc/device-tree/soc/serial@40011000 /proc/device-tree/soc/serial@5c000000

Thanks and Regards,Rp

Hello @RobertCNelson ,
Did you make any success in this?
Br,
Rp

Hi @raulp , still no success, I’ve also patched u-boot… We must be missing a clock/etc somewhere…

Regards,

1 Like

finally able to do it …

&usart3 {
pinctrl-names = “default”, “sleep”, “idle”;
pinctrl-0 = <&usart3_pins_c>;
pinctrl-1 = <&usart3_sleep_pins_c>;
pinctrl-2 = <&usart3_idle_pins_c>;
uart-has-rtscts;
status = “disabled”;
};

al the time i was using *_pins_a

Thanks for all the support !!

1 Like

Awesome, glad that one worked, i thought i had also tried that combination!