Open main menu

DAVE Developer's Wiki β

Changes

DESK-MP1-L/Peripherals/UARTs

3,009 bytes added, 13:23, 28 July 2023
Created page with "==Peripheral UART == === Device tree configuration === Here below an example of device tree configuration used on standard DAVE's kit for the ETRA SOM: From the kernel <..."
==Peripheral UART ==

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

From the kernel <code>stm32mp157a-dcsb5000dd1r.dts</code> device tree:
<pre>
&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 */
};
};
...
...
};
</pre>

===Accessing the peripheral===
====Linux messages at boot time====

<pre class="workstation-terminal">
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
</pre>

==== Usage with stty ====
'''N.B.''' UART mapping respect to <code>ttymxcX</code> 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 <code>ttySTM1</code> device:

<pre class="workstation-terminal">
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
</pre>

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

For detailed information, please refer to the Serial Programming HOWTO at [http://tldp.org/HOWTO/Serial-Programming-HOWTO/index.html Serial-Programming-HOWTO]
dave_user
226
edits