Serial Port
1 Serial Port Interface Overview
The GM-3568JHF development board is designed based on the Rockchip RK3568J chip and provides rich serial port interfaces, supporting a variety of serial communication protocols and application scenarios. The serial port is one of the most commonly used communication interfaces in embedded systems, widely applied in device debugging, data transmission, industrial control, and other fields.
1.1 Serial Port Interface Configuration
There are a total of 6 serial ports coming out of RK3568J on the development board:
| Serial Port Type | Quantity | Interface Form | Electrical Standard | Application Scenario |
|---|---|---|---|---|
| RS232 | 1 | DB9 connector | RS232 level | Industrial device communication |
| RS485 | 2 | Terminal interface | RS485 differential | Industrial bus communication |
| TTL | 2 | Pin header interface | 3.3V TTL | Debugging, sensor communication |
| TypeC Debug | 1 | Type-C interface | USB to TTL | System debugging |
1.2 Serial Port Electrical Standards Introduction
RS232 Standard
- Voltage Range: ±3V to ±15V
- Logic Level: Positive voltage indicates logic 0, negative voltage indicates logic 1
- Transmission Distance: Up to 15 meters (9600bps)
- Connection Method: Single-ended signal transmission
- Anti-interference: General anti-interference ability
RS485 Standard
- Voltage Range: ±1.5V to ±6V
- Logic Level: Differential signal transmission
- Transmission Distance: Up to 1200 meters (9600bps)
- Connection Method: Two-wire differential transmission (A+, 😎
- Anti-interference: Strong anti-interference ability, suitable for industrial environments
TTL Standard
Voltage Range: 0V to 3.3V
Logic Level: High level 3.3V, low level 0V
Transmission Distance: Generally less than 3 meters
Connection Method: Single-ended signal transmission
Application: Mainly used for board-level communication and debugging
RS232: 1
RS485: 2
TTL: 2 (one of which is on the 40PIN interface; this serial port can be connected to a Raspberry Pi expansion board for RS485 use)

- TypeC (Debug): 1 (this interface is a USB-to-TTL interface, which can be used directly after connecting TypeC)

2 Connecting the Serial Port
Different interfaces have different connection methods. Below are the wiring methods for the different serial ports:
2.1 TTL
Taking the USB-to-TTL tool as an example:

- TXD -- RXD
- RXD -- TXD
- GND -- GND
2.2 RS232
Taking the USB-to-232 tool as an example:
Because it is a standard 232 interface, you can connect directly

2.3 RS485
Taking the USB-to-485 tool as an example:
USB-to-485 A -> Development board A
USB-to-485 B -> Development board B
As shown in the figure:


2.4 Serial Communication Test
We use the TTL serial port on the board for the experiment; the corresponding device file is /dev/ttyS4. By directly reading and writing the tty device file, you can control the device to receive or send data through the serial port. Below we use the board together with a serial debugging assistant under Windows.
Tips
The RS485 serial port has automatic direction switching added at the driver layer, so communication is the same as with a normal serial port
Query Serial Port Parameters and Modify the Baud Rate
Use the stty tool to query serial port parameters
# 在开发板的终端执行如下命令
root@linaro-alip:/# stty -F /dev/ttyS4
speed 9600 baud; line = 0;
-brkint -imaxbelUse the stty tool to modify serial port parameters
# 设置通讯速率,其中 ispeed 为输入速率,ospeed 为输出速率
root@linaro-alip:/# stty -F /dev/ttyS4 ispeed 115200 ospeed 115200
root@linaro-alip:/# stty -F /dev/ttyS4
speed 115200 baud; line = 0;
-brkint -imaxbelCommunicating with the PC
After configuring the serial debugging assistant on the PC, use the following commands on the board to test serial data transmission:
1) Sending data:
# 在板卡上的终端执行如下指令
# 使用 echo 命令向终端设备文件写入字符串 "Hello!"
echo Hello! > /dev/ttyS4The serial debugging assistant on the PC will receive the content

2) Receiving data:
To test receiving data, you can use the microcom tool:
# 在板卡上的终端执行如下指令
# 使用 microcom 命令读取终端设备文件,-s 参数可以设置波特率
busybox microcom -s 115200 /dev/ttyS4
Hello World! #PC 发送过来的数据
# microcom 命令会等待
# 使用串口调试助手发送字符串
# 板卡的终端会输出接收到的内容3 Troubleshooting
3.1 Serial Port Device Cannot Be Opened
Symptom: "Permission denied" is reported, or the device does not exist
Solution:
# 检查设备节点是否存在
ls -l /dev/ttyS*
# 检查设备权限
sudo chmod 666 /dev/ttyS4
# 将用户添加到 dialout 组
sudo usermod -a -G dialout $USER3.2 Data Transmission Errors
Possible Causes:
- Baud rate mismatch
- Incorrect data bits, stop bits, or parity bits configuration
- Hardware connection issues
Troubleshooting Steps:
# 检查串口配置
stty -F /dev/ttyS4 -a
# 设置正确的串口参数
stty -F /dev/ttyS4 115200 cs8 -cstopb -parenb3.3 RS485 Communication Issues
Notes:
- Ensure the A and B lines are connected correctly
- Check the termination resistor configuration
- Verify the ground wire connection
# RS485 测试命令
echo "test" > /dev/ttyS1 # 发送到 RS485 端口 1
cat /dev/ttyS2 # 从 RS485 端口 2 接收3.4 Serial Port Conflict
Solution:
# 查看串口使用情况
lsof /dev/ttyS*
# 终止占用串口的进程
sudo fuser -k /dev/ttyS4