The STMicroelectronics STM32MP25 has five UART and four USART interfaces that can be used for serial communication with devices either directly or through level adapters. A UART (Universal Asynchronous Receiver Transmitter) supports only asynchronous mode, while a USART (Universal Synchronous Asynchronous Receiver Transmitter) supports both synchronous and asynchronous modes. You can also use the RTS and CTS hardware flow-control lines.
On the ConnectCore MP25:
-
USART1 is connected to the Bluetooth chip (on modules with Bluetooth).
-
The remaining UARTs and USARTs are available for peripheral use, multiplexed with other functionality.
On the ConnectCore MP25 Development Kit:
-
UART5 is available on the expansion connector (4-wires, TTL level). This port is shared with the XBee interface.
-
USART6 is available on the expansion connector (4-wires, TTL level).
-
UART7 is available on the MikroBus connector (2-wires, TTL level).
Kernel configuration
You can manage the UART support through the kernel configuration options:
-
STM32 serial port support (
CONFIG_SERIAL_STM32
) -
Console on STM32 serial port (
CONFIG_SERIAL_STM32_CONSOLE
)
Kernel driver
File | Description |
---|---|
STM UART driver |
Device tree bindings and customization
The STM32MP25 UART interface device tree binding is documented at Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
RS-485 support
RS-485 is a standard defining the electrical characteristics of drivers and receivers in balanced digital multipoint systems. RS-485 only specifies electrical characteristics of the generator and the receiver; it does not specify or recommend a communications protocol.
The STM32MP25 serial driver includes support for the RS-485 standard.
No specific kernel configuration is necessary to support RS-485 over the serial interface.
The device tree bindings are documented at Documentation/devicetree/bindings/serial/rs485.yaml
.
RS-485 half-duplex needs the RX and TX lines for data communication and the RTS line to control the RS-485 transceiver to either drive output or receive input from outside the chip.
To enable RS-485 mode on a UART port, apply the following changes to the device tree node:
-
Add property
linux,rs485-enabled-at-boot-time
. -
Optionally add property
rs485-rts-active-low
to define RTS line polarity as ACTIVE LOW. Default polarity is ACTIVE HIGH. -
Optionally add property
rs485-rts-delay-ns = <a b>
to define:-
a: Delay in nanoseconds between RTS line assertion and start of transmission.
-
b: Delay in nanoseconds between end of transmission and RTS line de-assertion.
-
The RTS assert/de-assert delay depends on the baudrate and the oversampling setting per the following formula: \$RTS_(DELAY)(ns) = ("<value>" * 1000000000) / ("<baudrate>" * "<samples>")\$ where:
For example, at 9600 bauds with oversampling, the maximum RTS delay is approximately 203 µs. |
Example: Configure RS-485 port on ConnectCore MP25 Development Kit
By default, the USART6 on the ConnectCore MP25 Development Kit device tree is configured in RS-485 mode.
/* RS485 */
&USART6 {
linux,rs485-enabled-at-boot-time;
pinctrl-names = "default", "idle", "sleep";
pinctrl-0 = <&usart6_pins_a>;
pinctrl-1 = <&usart6_idle_pins_a>;
pinctrl-2 = <&usart6_sleep_pins_a>;
uart-has-rtscts;
status = "okay";
};
UART user space usage
The STM32MP25 UART bus driver exposes device data through the sysfs at /sys/class/tty/ttySTMn/
, where n is the port index, starting at zero.
UART device interface
You can access STM32MP25 UART devices from user space through the device node /dev/ttySTMn
, where n is the port index, starting at zero.
For information about using the serial port from user space, see the Serial Programming Guide for POSIX Operating Systems.