Skip to content

UART

The Rockchip platform UART is based on the 16550A serial port standard. The expansion pin UART information is as follows:

Mainboard SOC Platform Expansion Pins
K1 RK3568 Rockchip UART X4
K1B RK3568 Rockchip UART X2
K3 RK3562 Rockchip UART X3
K7 RK3576 Rockchip UART X5
K7C RK3576 Rockchip UART X4
K8 RK3588 Rockchip UART X5

The Allwinner platform UART is compatible with 16550 UARTs. The expansion pin UART information is as follows:

Mainboard SOC Platform Expansion Pins
K2B H618 Allwinner UART X2
K2C H618 Allwinner UART X2
K4B T113 Allwinner UART X3
K5C A133 Allwinner UART X1
Term Description
UART Universal Asynchronous Receiver/Transmitter
Console Console, the TTY device used for outputting debug information in the Linux kernel
TTY TeleType/TeleTypewriters, originally referring to teletypewriters, now generally refers to terminal devices connected to computer serial ports. TTY devices also include virtual consoles, serial ports, and pseudo-terminal devices.
/dev/ttyS Ordinary serial port device name
/dev/ttySA Allwinner platform serial port name
/dev/ttyUSB USB to serial port device

Hardware Connection

UART communication requires a minimum of 3 wires to operate (full-duplex communication):

  • TXD (Transmit Data): Data transmission end. The device sends data out through this line.
  • RXD (Receive Data): Data reception end. The device receives external data through this line.
  • GND (Ground): Ground wire, used to ensure a common voltage reference level between the two devices (common ground).

The UART between two devices requires cross-connecting RX and TX, directly connecting GND, and optionally directly connecting VCC.

uart_connect

DTS Configuration

Taking enabling UART device 0 as an example, add the following node in the dts:

&uart0 {
    status = "okay";
}

Driver Path

Rockchip platform UART uses the 8250 serial driver:

drivers/tty/serial/8250/8250_core.c
drivers/tty/serial/8250/8250_dw.c
drivers/tty/serial/8250/8250_dma.c
drivers/tty/serial/8250/8250_port.c
drivers/tty/serial/8250/8250_early.c

Allwinner platform UART uses a dedicated serial driver:

longan/kernel/linux-4.9/drivers/tty/serial/sunxi-uart.c
longan/kernel/linux-4.9/drivers/tty/serial/serial_core.c

stty Test

Configure UART device 5, set input/output baud rate to 115200, 8 data bits:

stty -F /dev/ttyS5 ispeed 115200 ospeed 115200 cs8

Send data "kickpi" to UART device 5:

echo "kickpi" > /dev/ttyS5

Capture data received by UART device 5:

cat /dev/ttyS5

Hardware Usage Example

Using the K7 mainboard as an example, this section explains how to connect the UART pins on the mainboard's expansion pins.

1. Check the mainboard expansion pin diagram and its corresponding physical location.

Note

The diagram shows that the K7 is equipped with five UART channels and one DEBUG UART. UART8 is located at pin 17 and pin 19.
DEBUG UART is only used for DEBUG debugging and not for other functions.

image-20251110162807174

2. Check the expansion pin voltage diagram to determine that the power domain for UART8 is 1.8V.

image-20251110162913710

3. Connect devices with the same power domain.

Warning

For UART connection, the TX and RX power domains must be consistent!

4. The UART8 power domain is 1.8V. Use the UART8 ports of two mainboards for connection: cross-connect RX and TX, and directly connect GND.

image-20251110164209245

RS485 Conversion Module

RS485 communication uses the chip's UART. This chapter introduces the wiring for the UART-to-RS485 module (it is recommended to purchase this module from KICKPI official sources).

Wiring Method

The RS485 module VCC can be powered with 3.3V/5V.

Warning

The RS485 module can only be used with UART ports at 3.3V logic levels.

Note

The connection method for the 4PIN end to the development board UART port is as follows (corresponding top to bottom):
Motherboard: RX TX GND VCC
Module: RXD TXD GND VCC
The connection method for the 3PIN end to the RS485 device is as follows (corresponding top to bottom):
Module: A GND B
RS485 Device: A GND B

image-20250324143115205

RS232 Conversion Module

RS232 communication uses the chip's UART. This chapter introduces the wiring for the UART-to-RS232 module (it is recommended to purchase this module from KICKPI official sources).

Wiring Method

The RS232 module VCC can be powered with 3.3V/5V.

Warning

The RS232 module can only be used with UART ports at 3.3V logic levels.

Note

The connection method for the 4PIN end to the development board UART port is as follows (corresponding top to bottom):
Motherboard: TX RX GND VCC
Module: RXD TXD GND VCC
The connection method for the 3PIN end to the RS232 device is as follows (corresponding top to bottom):
Module: RXD GND TXD
RS232 Device: TXD GND RXD

image-20250324142614631