This document will introduce how to use the UART serial ports of RK3588 from user space.
Hardware: yy3588 development board Firmware: yy3588_ubuntu22.04_linux6.1_release_v1.1_dsi0.img
The RK3588 chip provides multiple UART serial port controllers for serial communication.
/dev/ttyS<n> in Linux systemsn is the serial port number, such as ttyS0, ttyS1, ttyS6, etc.UART serial communication requires the following parameters to be configured:
| Parameter Name | Description | Common Values |
|---|---|---|
| Baud Rate | Data transmission rate | 9600, 115200, 230400, etc. |
| Data Bits | Number of bits per data frame | 7 bits (cs7), 8 bits (cs8) |
| Parity | Error detection mechanism | None (-parenb), Even (parenb -parodd), Odd (parenb parodd) |
| Stop Bits | Data frame end marker | 1 bit (-cstopb), 2 bits (cstopb) |
| Flow Control | Data flow control mechanism | None (-crtscts), Hardware (crtscts), Software (ixon ixoff) |
Configurations are usually represented in shorthand, such as:
The actually available serial ports on the YY3588 development board can be viewed by executing the ls /dev/ttyS* command, for example:
ls /dev/ttyS*
Output result:
root@YY3588:/# ls /dev/ttyS*
/dev/ttyS1 /dev/ttyS6 /dev/ttyS7 /dev/ttyS9
Here are the details of the actually available serial ports on the yy3588 development board:
| Device Node | Description | Default Configuration |
|---|---|---|
| /dev/ttyS1 | UART1 Serial Port | 9600-8N1 |
| /dev/ttyS6 | UART6 Serial Port | 9600-8N1 |
| /dev/ttyS7 | UART7 Serial Port | 9600-8N1 |
| /dev/ttyS9 | UART9 Serial Port | 9600-8N1 |
For testing convenience, UART-related operations have been written as scripts.
| Script Name | Function Description |
|---|---|
get.sh |
Get serial port configuration information |
set.sh |
Set serial port configuration parameters |
send.sh |
Send data to serial port |
receive-service.sh |
Manage background receiving service (start/stop/query status) |
receive-watch.sh |
Real-time monitoring of serial port data in foreground (press Ctrl+C to stop) |
config.txt |
Serial port configuration preset file |
tests.sh |
Automated testing of all UART functions |
This document uses short-circuiting the TX and RX pins of UART6 to test UART functionality. For communication with a PC or other devices, refer to the hardware and ensure correct connections: RX-TX, TX-RX, GND-GND. Configuration aspects (baud rate, data bits, parity, stop bits, flow control) need to be modified according to actual conditions.
Connect the development board to PC, open PC's Command Prompt or PowerShell, then use ADB commands to upload scripts to the development board. The path D:\package\scripts\01UART\adb is the script directory on PC and needs to be replaced with your actual path. /home/youyeetoo/adb is the adb directory on the development board and needs to be modified according to actual conditions:
adb devices # Check device connection
adb push D:\package\scripts\01UART\adb /home/youyeetoo # Upload
adb shell # Enter development board shell
cd /home/youyeetoo/adb # Switch to upload directory
chmod a+x *.sh # Add execute permissions to all scripts
Example output:
PS C:\Users\youyeetoo> adb devices
List of devices attached
52d4c5b82df38192 device
PS C:\Users\youyeetoo> adb push D:\package\scripts\01UART\adb /home/youyeetoo
D:\package\scripts\01UART\adb\: 8 files pushed, 0 skipped. 1.9 MB/s (19984 bytes in 0.010s)
PS C:\Users\youyeetoo> adb shell
root@YY3588:/# cd /home/youyeetoo/adb/
root@YY3588:/home/youyeetoo/adb# chmod a+x *.sh
root@YY3588:/home/youyeetoo/adb#
Scripts uploaded via ADB are only visible in ADB. When using scripts in Ubuntu system, you need to use other upload methods such as USB drive or network upload. Linux-specific scripts are in the package/scripts/01UART/linux directory. After uploading the scripts, grant execute permissions following the previous process. If you encounter permission issues, use sudo to execute.
Note: Unlike the ADB environment, when executing UART scripts in Linux system, the scripts have integrated sudo permission management (similar to GPIO scripts), so you don't need to manually add the sudo prefix when executing. For example, just execute ./get.sh 6, and the script will automatically handle permission issues.
All script executions below are performed in the ADB /home/youyeetoo/adb directory. All scripts will print usage instructions when run without any parameters. For example, the get.sh script, when executed directly without parameters ./get.sh, will output:
root@YY3588:/home/youyeetoo/adb# ./get.sh
Usage: ./get.sh <uart_number|all>
Example: ./get.sh 1 (for /dev/ttyS1)
Example: ./get.sh all (for all available UARTs)
Available UARTs: 1 6 7 9
root@YY3588:/home/youyeetoo/adb# ./get.sh 6
UART Configuration for /dev/ttyS6
============================================
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
============================================
Device: /dev/ttyS6
Get all serial port configurations:
./get.sh all
Output omitted
config.txt file. You can also manually add more configurations. Example of configuring UART6 with default configuration:./set.sh 6 default
root@YY3588:/home/youyeetoo/adb# ./set.sh 6 default
Configuring /dev/ttyS6 with 'default'
Parameters: 115200 cs8 -parenb -cstopb -crtscts raw -echo
-----------------------------------
Configuration applied successfully!
-----------------------------------
Current configuration:
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
Common configuration names:
| Configuration Name | Parameter Description | Usage Scenario |
|---|---|---|
| default | 115200-8N1 | Default configuration, most common |
| 9600-8N1 | 9600 baud rate, 8 data bits, no parity, 1 stop bit | Low-speed communication |
| 115200-8N1 | 115200 baud rate, 8 data bits, no parity, 1 stop bit | Standard high-speed communication |
| 9600-8E1 | 9600 baud rate, 8 data bits, even parity, 1 stop bit | Communication requiring even parity |
| origin | System initial configuration (9600-8N1) | Restore default state |
For complete configuration list, please check the config.txt file.
./send.sh 6 "Hello World" # Send "Hello World"
root@YY3588:/home/youyeetoo/adb# ./send.sh 6 "Hello UART"
Sending data to /dev/ttyS6
Data: Hello UART
-----------------------------------
Data sent successfully!
Bytes: 10
UART receiving provides the following two receiving methods. The two methods cannot be used simultaneously as they conflict. Whichever is executed first takes effect. To switch to another method, you need to stop the current one first: receive-service.sh uses ./receive-service.sh 6 stop command to pause, receive-watch.sh uses Ctrl+C to pause. Received data will be saved to the data.txt file in the current script directory.
4.1 Background Service Mode (receive-service.sh)
Used to manage background receiving service, supporting start, stop, and status query operations.
Start receiving service:
root@YY3588:/home/youyeetoo/adb# ./receive-service.sh 6 start
Starting to receive data from /dev/ttyS6
-----------------------------------
Receiving process started (PID: 3559)
PID saved to /tmp/uart_receive_ttyS6.pid
Received data is being logged to: /home/youyeetoo/adb/data.txt
View real-time output with: tail -f /home/youyeetoo/adb/data.txt
Query service status:
root@YY3588:/home/youyeetoo/adb# ./receive-service.sh 6 status
Receiving process is running on /dev/ttyS6
PID: 3559
Command: sh -c while true; do timeout 0.1 cat /dev/ttyS6 ...
Stop receiving service:
root@YY3588:/home/youyeetoo/adb# ./receive-service.sh 6 stop
Stopping receiving process on /dev/ttyS6 (PID: 3559)
Receiving process stopped
Received data log: /home/youyeetoo/adb/data.txt
To view: cat /home/youyeetoo/adb/data.txt
To clear: rm /home/youyeetoo/adb/data.txt
How it works:
4.2 Foreground Watch Mode (receive-watch.sh)
Used for real-time monitoring of serial port data, data is displayed directly in the terminal.
Start monitoring:
root@YY3588:/home/youyeetoo/adb# ./receive-watch.sh 6
=====================================
UART6 Watch Mode
=====================================
Device: /dev/ttyS6
Press Ctrl+C to stop
-------------------------------------
[2026-09-17_14:23:15] [UART6] Hello UART
[2026-09-17_14:23:18] [UART6] Test Message
How it works:
receive-watch.sh script. Below is testing the functionality of ttyS6:./tests.sh 6
Output omitted
Test content includes:
| Test Item | Test Content | Verification Point |
|---|---|---|
| Test 1 | Serial port device existence check | Whether /dev/ttyS6 exists |
| Test 2 | Serial port read/write permission check | Whether it has read/write permissions |
| Test 3 | Get initial configuration | get.sh script function verification |
| Test 4 | Set default configuration | set.sh set 115200-8N1 configuration |
| Test 5 | Verify configuration takes effect | Confirm baud rate and configuration parameters are correct |
| Test 6 | Test different baud rates | Set 9600 baud rate |
| Test 7 | Verify 9600 configuration | Confirm configuration switch success |
| Test 8 | Start receiving service | receive-service.sh start function |
| Test 9 | Verify service status | Confirm service is running |
| Test 10 | Send test data | send.sh send function verification |
| Test 11 | Verify data reception | Confirm data.txt exists and content is correct |
| Test 12 | Multiple message test | Send 3 consecutive messages and verify |
| Test 13 | Stop receiving service | Service stop function verification |
| Test 14 | Verify service stopped | Confirm service completely stopped |
| Test 15 | Clean test data | Delete data.txt file |
| Test 16 | Restore original configuration | Restore to system initial configuration |
Test features:
receive-watch.sh testing (requires two terminals, manual testing)Test output example:
================================
TEST REPORT
================================
UART Number: ttyS6
Test Time: 2026-09-18 17:40:54
-----------------------------------
Total Tests: 16
Passed: 16
Failed: 0
-----------------------------------
Result: ALL TESTS PASSED ✓
================================
The configuration file contains multiple predefined serial port configurations, in the format:
configuration_name=stty parameters
9600-8N1=9600 cs8 -parenb -cstopb -crtscts -echo
19200-8N1=19200 cs8 -parenb -cstopb -crtscts -echo
38400-8N1=38400 cs8 -parenb -cstopb -crtscts -echo
57600-8N1=57600 cs8 -parenb -cstopb -crtscts -echo
115200-8N1=115200 cs8 -parenb -cstopb -crtscts -echo
230400-8N1=230400 cs8 -parenb -cstopb -crtscts -echo
# Even parity
9600-8E1=9600 cs8 parenb -parodd -cstopb -crtscts -echo
115200-8E1=115200 cs8 parenb -parodd -cstopb -crtscts -echo
# Odd parity
9600-8O1=9600 cs8 parenb parodd -cstopb -crtscts -echo
115200-8O1=115200 cs8 parenb parodd -cstopb -crtscts -echo
# 7 data bits
9600-7N1=9600 cs7 -parenb -cstopb -crtscts -echo
115200-7N1=115200 cs7 -parenb -cstopb -crtscts -echo
# 2 stop bits
9600-8N2=9600 cs8 -parenb cstopb -crtscts -echo
115200-8N2=115200 cs8 -parenb cstopb -crtscts -echo
# Hardware flow control
115200-8N1-hw=115200 cs8 -parenb -cstopb crtscts -echo
# Software flow control
115200-8N1-sw=115200 cs8 -parenb -cstopb -crtscts ixon ixoff -echo
# Raw mode
115200-raw=115200 cs8 -parenb -cstopb -crtscts raw -echo
# Default configuration (most common)
default=115200 cs8 -parenb -cstopb -crtscts -echo
# Original system configuration
origin=9600 cs8 -parenb -cstopb -crtscts -echo
# 1. Set serial port to 115200 baud rate
./set.sh 6 default
# 2. Start receiving service
./receive-service.sh 6 start
# 3. Send data from another terminal or PC tool
./send.sh 6 "Test Message"
# 4. View received data
tail -f data.txt
# 5. Stop receiving service
./receive-service.sh 6 stop
# 1. Configure serial port
./set.sh 6 115200-8N1
# 2. Start real-time monitoring (foreground display)
./receive-watch.sh 6
# Send data from another terminal
./send.sh 6 "Real-time Test"
# Press Ctrl+C to exit monitoring
# 1. Configure serial port
./set.sh 6 115200-8N1
# 2. Start receiving service (monitor in background)
./receive-service.sh 6 start
# 3. Send data
./send.sh 6 "Loopback Test"
# 4. View received data
cat data.txt
# 5. Send again
./send.sh 6 "Second Test"
# 6. Cleanup
./receive-service.sh 6 stop
# Sending end (development board)
./set.sh 6 9600-8N1
./send.sh 6 "Low Speed"
# Receiving end (PC or another device)
# Need to configure to same 9600-8N1
# Run automated test
./tests.sh 6
# Test will verify all functions and output detailed report
Problem: Permission denied
Solution:
# Method 1: Use root privileges
sudo ./get.sh 6
# Method 2: Add current user to dialout group
sudo usermod -aG dialout $USER
# Log out and log back in for it to take effect
Problem: /dev/ttyS6 does not exist
Solution:
# View all available serial ports
./get.sh all
# Or view manually
ls /dev/ttyS*
Possible causes:
./receive-service.sh 6 status to checkPossible causes:
Solution: Ensure both sides have exactly matching configurations, check hardware connection quality.