DESK-MP1-L/Peripherals/UARTs

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2023/08/02 DESK-MP1-L-1.0.0 release


Peripheral UARTs[edit | edit source]

Device tree configuration[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for the ETRA SOM:

From the kernel stm32mp157a-dcsb5000dd1r.dts device tree:

&uart4{
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&uart4_pins_mx>;
	pinctrl-1 = <&uart4_sleep_pins_mx>;
	status = "okay";

	/* USER CODE BEGIN uart4 */
	/delete-property/dmas;
	/delete-property/dma-names;
	/* USER CODE END uart4 */
};
...
...
&pinctrl {
...
...
	uart4_pins_mx: uart4_mx-0 {
		pins1 {
			pinmux = <STM32_PINMUX('B', 2, AF8)>; /* UART4_RX */
			bias-disable;
		};
		pins2 {
			pinmux = <STM32_PINMUX('G', 11, AF6)>; /* UART4_TX */
			bias-disable;
			drive-push-pull;
			slew-rate = <0>;
		};
	};

	uart4_sleep_pins_mx: uart4_sleep_mx-0 {
		pins {
			pinmux = <STM32_PINMUX('B', 2, ANALOG)>, /* UART4_RX */
					 <STM32_PINMUX('G', 11, ANALOG)>; /* UART4_TX */
		};
	};
...
...
};

Accessing the peripheral[edit | edit source]

Linux messages at boot time[edit | edit source]

root@desk-mp1:~# dmesg | grep serial
[    0.559130] stm32-usart 4000f000.serial: interrupt mode for rx (no dma)
[    0.559170] stm32-usart 4000f000.serial: interrupt mode for tx (no dma)
[    0.559210] 4000f000.serial: ttySTM1 at MMIO 0x4000f000 (irq = 49, base_baud = 4000000) is a stm32-usart
[    0.561377] stm32-usart 40010000.serial: interrupt mode for rx (no dma)
[    0.561413] stm32-usart 40010000.serial: interrupt mode for tx (no dma)
[    0.561450] 40010000.serial: ttySTM0 at MMIO 0x40010000 (irq = 50, base_baud = 4000000) is a stm32-usart
[    1.861292] stm32-usart 40018000.serial: interrupt mode for rx (no dma)
[    1.866587] stm32-usart 40018000.serial: interrupt mode for tx (no dma)
[    1.873293] 40018000.serial: ttySTM3 at MMIO 0x40018000 (irq = 51, base_baud = 4000000) is a stm32-usart
[    1.884932] stm32-usart 40019000.serial: interrupt mode for rx (no dma)
[    1.890313] stm32-usart 40019000.serial: interrupt mode for tx (no dma)
[    1.896815] 40019000.serial: ttySTM2 at MMIO 0x40019000 (irq = 52, base_baud = 4000000) is a stm32-usart

Usage with stty[edit | edit source]

N.B. UART mapping respect to ttymxcX is the following one:

uart4 <-> serial0 <-> ttySTM0
usart3 <-> serial1 <-> ttySTM1
uart8 <-> serial2 <-> ttySTM2
uart7 <-> serial3 <-> ttySTM3

For example, using a loopback HW connection (RX short circuited to TX on UART232 port) it is possible to test the send and receive data using the ttySTM1 device:

root@desk-mp1:~# stty -F /dev/ttySTM1 115200 -echo
root@desk-mp1:~# cat /dev/ttySTM1 &
root@desk-mp1:~# echo "Test loopback" > /dev/ttySTM1
root@desk-mp1:~# Test loopback

Additional information[edit | edit source]

Serial ports can be used through the standard serial programming API.

For detailed information, please refer to the Serial Programming HOWTO at Serial-Programming-HOWTO