Serial Port Communication
1. Serial Port Pins
Serial port pin mapping (taking M5-R1 as an example):
| Serial | Pin | Function |
|---|---|---|
| TXD | 8 | Transmit signal line |
| RXD | 10 | Receive signal line |
Corresponds to UART3 on the 40-pin header of the board.

2. Checking the Serial Port Device
Check whether the serial port device has been created.
# Run this command to list the serial devices
ls /dev/ttyS*As shown, ttyS3 is UART3 and ttyS8 is UART8 (this port is occupied by the Bluetooth module).

3. Serial Communication Test
Using M5-R1 as an example, the serial port is tested by connecting to a PC through a USB-to-serial adapter.
3.1 Connecting the Serial Port
Connect the TX and RX of the USB-to-serial adapter to UART6_RX and UART6_TX on the 40-pin header, respectively.
The USB-to-TTL serial adapter is shown below:

- TXD -- RXD
- RXD -- TXD
- GND -- GND
3.2 Querying Serial Parameters and Changing the Baud Rate
Use the stty tool to query serial parameters.
# Run the following command on the board terminal
root@rk3588-buildroot:/# stty -F /dev/ttyS6
speed 9600 baud; line = 0;
-brkint -imaxbel
root@rk3588-buildroot:/#Use the stty tool to change serial parameters.
# Set the communication rate; ispeed is the input rate and ospeed is the output rate
root@rk3588-buildroot:/# stty -F /dev/ttyS6 ispeed 115200 ospeed 115200
root@rk3588-buildroot:/# stty -F /dev/ttyS6
speed 115200 baud; line = 0;
-brkint -imaxbel
root@rk3588-buildroot:/#Warning
The baud rate must be reconfigured after every boot; rebooting resets the baud rate to 9600 by default.
3.3 Communicating with a PC
After configuring the serial debug assistant on the PC, use the following commands on the board to test sending data over the serial port:
# Run the following commands on the board terminal
# Use the echo command to write the strings "Hello!" and "Linux6_1!" to the terminal device file
echo Hello! > /dev/ttyS6
echo "Linux6_1" > /dev/ttyS6
# The serial debug assistant on the PC receives the contentTo test receiving data, use the microcom tool:
# Run the following commands on the board terminal
# Use the microcom command to read from the terminal device file; the -s option sets the baud rate
microcom -s 115200 /dev/ttyS6
# microcom now waits
# Send a string from the serial debug assistant
# The board terminal prints the received content