The STMicroelectronics STM32MP15 has four 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 MP15:

  • 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 MP15 Development Kit:

  • UART3 is available on the expansion connector (4-wires, TTL level) with RTS/CTS lines multiplexed with CAN2 port. This port is shared with the XBee interface.

  • UART4 is available on the console connector (2-wires, TTL level).

  • UART7 is available on the MicroBus 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

drivers/tty/serial/stm32-usart.c

STM UART driver

Device tree bindings and customization

The STM32MP15 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 STM32MP15 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 as per the following formula:

\$RTS_(DELAY)(ns) = ("<value>" * 1000000000) / ("<baudrate>" * "<samples>")\$

where:

  • <value> can be a value between 1 (min) and 32 (max)

  • <baudrate> is the baudrate in bps

  • <samples> can be 8 or 16 (default) depending on oversampling configuration

For example, at 9600 bauds with oversampling, the maximum RTS delay is approximately 203 µs.

Example: Configure RS-485 port on ConnectCore MP15 Development Kit

By default, the UART7 on the ConnectCore MP15 Development Kit device tree is configured in RS-485 mode.

ConnectCore MP15 Development Kit device tree
/* RS485 */
&UART7 {
	linux,rs485-enabled-at-boot-time;
	pinctrl-names = "default","sleep";
	pinctrl-0 = <&ccmp15_uart7_pins_a &ccmp15_uart7_rtscts_pin_a>;
	pinctrl-1 = <&ccmp15_uart7_sleep_pins_a>;
	uart-has-rtscts;
	status = "okay";
};

UART user space usage

The STM32MP15 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 STM32MP15 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.