Rockchip UART (Universal Asynchronous Receiver/Transmitter) is based on the 16550A serial port standard. The kernel uses the 8250 serial port universal driver, so it can support standard serial port programming under Linux.
There are three general serial ports on the board and one debugging serial port. It is recommended not to use the debugging serial port for other purposes.
The serial numbers of these three universal serial ports are 5, 7, and 9 respectively, and the corresponding device nodes under Linux are /dev/ttyS5 /dev/ttyS7 /dev/ttyS9. The following uses ttyS9 as an example to introduce its usage. Other serial ports are similar.
Next, perform a transceiver test by short-circuiting TX and RX of ttyS4 on the hardware. The wiring is as follows
The nodes of "/dev/ttyS*" require root permissions to operate. Using the command line or programs compiled in C language to operate the serial port requires root permissions. If you are using ssh or using LX terminal, first execute the following command to obtain root permissions.
sudo su
View serial port information
stty -F /dev/ttyS4
Set the serial port baud rate to 115200
stty -F /dev/ttyS4 speed 115200
Set eight data bits of serial port, no parity, one stop bit, no echo
stty -F /dev/ttyS4 cs8 -parenb -cstopb -echo
Short-circuit the TXRX of the serial port, and then perform a transceiver test
Receive data in the background and send data in the foreground
cat /dev/ttyS4 &
echo -e "12345\n" > /dev/ttyS4
The execution results are as follows. You can see that the data received is the data sent.