USB
1 USB Interface Overview
The GM-3568JHF development board is designed based on the Rockchip RK3568J chip and provides rich USB interfaces to support a variety of USB device connectivity and data transfer requirements.
1.1 USB Interface Configuration
| Interface Type | Quantity | Specification | Function Description |
|---|---|---|---|
| USB 3.0 OTG | 1 | Type-C | Supports host/device mode switching |
| USB 3.0 HOST | 1 | Type-A | Host mode, connects peripherals |
| USB 2.0 HOST | 2 | Type-A | Host mode, connects peripherals |
1.2 RK3568J USB Controller Features
1) USB 3.0 Controller:
- USB Standard: Compatible with USB 3.0/2.0/1.1 standards
- Transfer Rate: Up to 5Gbps for USB 3.0, up to 480Mbps for USB 2.0
- OTG Function: Supports automatic switching between Host and Device modes
- Power Management: Supports USB suspend and wake-up functions
- Hot Plug: Supports device hot-plug detection
2) USB 2.0 Controller:
- Multi-port Support: Supports multiple USB 2.0 ports
- EHCI Compatible: Compatible with EHCI (Enhanced Host Controller Interface)
- OHCI Compatible: Compatible with OHCI (Open Host Controller Interface)
- Device Support: Supports various USB devices, such as storage devices, input devices, audio devices, etc.
1.3 Supported USB Device Types
- Storage Devices: USB flash drive, portable hard drive, USB SSD
- Input Devices: USB mouse, keyboard, gamepad
- Audio Devices: USB speaker, USB microphone, USB sound card
- Network Devices: USB network adapter, USB Wi-Fi adapter
- Video Devices: USB camera, USB video capture card
- Other Devices: USB printer, USB serial converter, etc.
2 USB Interface Usage
1) Connecting USB Devices
Insert the USB device (such as a USB flash drive, mouse, keyboard, etc.) into the USB port of the development board. The system will automatically recognize the device and load the corresponding driver.
2) Viewing Connected USB Devices
Use the following command to view the currently connected USB devices:
root@linaro-alip:/# lsusb
Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 007 Device 002: ID 046d:c077 Logitech, Inc. Mouse
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubAs shown above, you can see that the mouse has been recognized
3) Mounting USB Storage Devices
If a USB storage device (such as a USB flash drive) is connected, you can mount it by following these steps:
View the device node:
root@linaro-alip:/# fdisk -l
...
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 122879966 122877919 58.6G c W95 FAT32 (LBA)Create a mount point and mount the device:
mkdir /mnt/usb
mount /dev/sda1 /mnt/usbView the mount result:
root@linaro-alip:/# df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sda1 59G 768K 59G 1% /mnt/usbUnmount the device:
umount /mnt/usb4) Using USB OTG Function
The USB 3.0 OTG interface of RK3568 supports device mode (such as USB flash drive mode) and host mode.
- Device Mode
Configure OTG to device mode:
echo peripheral > /sys/devices/platform/fe8a0000.usb2-phy/otg_modeConnect the development board to a PC, and the PC will recognize the development board as a USB device.
- Host Mode
Configure OTG to host mode:
echo host > /sys/devices/platform/fe8a0000.usb2-phy/otg_modeConnect a USB device to the OTG interface, and the development board will recognize the USB device.
5) USB Transfer Rate Test
- Identify the USB storage device:
Confirm the USB storage device via lsblk:
root@linaro-alip:/# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 1 58.6G 0 disk
mmcblk0 179:0 0 28.9G 0 disk
├─mmcblk0p1 179:1 0 4M 0 part
├─mmcblk0p2 179:2 0 4M 0 part
├─mmcblk0p3 179:3 0 64M 0 part
├─mmcblk0p4 179:4 0 128M 0 part
├─mmcblk0p5 179:5 0 32M 0 part
├─mmcblk0p6 179:6 0 6G 0 part /
├─mmcblk0p7 179:7 0 128M 0 part /oem
└─mmcblk0p8 179:8 0 22.5G 0 part /userdata
mmcblk0boot0 179:32 0 4M 1 disk
mmcblk0boot1 179:64 0 4M 1 disk
zram0 254:0 0 0B 0 diskAs shown above, the USB storage device plugged into ROCK 3B is /dev/sda
- Read test
root@linaro-alip:/# sudo dd if=/dev/sda of=/dev/null bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 3.34566 s, 31.3 MB/sThis command reads data from the USB device and writes it to /dev/null in order to test the read speed. Here the block size is specified as 1M and 100 blocks are read, so a total of 100 MB of data is read, with a read speed of 31.3 MB/s
- Write test
root@linaro-alip:/# sudo dd if=/dev/zero of=/dev/sda bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 6.96282 s, 15.1 MB/sHere the block size is specified as 1M and 100 blocks are written, so a total of 100 MB of data is written, with a write speed of 15.1 MB/s
3 USB OTG Function
3.1 OTG Mode Switching
The USB OTG (On-The-Go) interface supports dynamic switching between host and device modes:
- Host Mode In host mode, the development board acts as a USB host and can connect to various USB devices:
# 查看 OTG 当前模式
cat /sys/devices/platform/usb0/mode
# 切换到主机模式
echo "host" > /sys/devices/platform/usb0/mode- Device Mode In device mode, the development board acts as a USB device and can be connected to a PC or other host:
# 切换到设备模式
echo "peripheral" > /sys/devices/platform/usb0/mode
# 查看可用的 USB 功能
ls /sys/class/udc/3.2 USB Gadget Functions
The development board supports multiple USB Gadget functions:
1) Mass Storage Device
# 配置为 USB 存储设备
modprobe g_mass_storage file=/dev/mmcblk0p12) Network Device (Ethernet Gadget)
# 配置为 USB 网络设备
modprobe g_ether3) Serial Device (Serial Gadget)
# 配置为 USB 串口设备
modprobe g_serial4 Performance Optimization Suggestions
4.1 USB 3.0 Performance Optimization
- Use High-quality USB Cables: Ensure cables compliant with the USB 3.0 standard are used
- Avoid USB Hubs: Connect devices directly for optimal performance
- File System Selection: For large file transfers, exFAT or NTFS file systems are recommended
- Block Size Optimization: Use larger block sizes for data transfer
4.2 Power Management
# 禁用 USB 自动挂起(提高响应速度)
echo -1 > /sys/module/usbcore/parameters/autosuspend
# 查看 USB 设备电源状态
cat /sys/bus/usb/devices/*/power/control5 Common Troubleshooting
1) USB Device Cannot Be Recognized
Symptom: No system response after plugging in a USB device
Troubleshooting Steps:
# 检查 USB 控制器状态
lsusb -t
# 查看内核日志
dmesg | grep -i usb
# 检查 USB 端口电源
cat /sys/bus/usb/devices/*/power/level2) USB Transfer Speed Is Slow
Possible Causes:
- USB cable quality issues
- Performance limitations of the USB device itself
- File system fragmentation
Solutions:
# 检查 USB 设备速度
lsusb -v | grep -E "bcdUSB|MaxPower"
# 测试不同块大小的传输性能
dd if=/dev/zero of=/mnt/usb/test bs=1M count=100
dd if=/dev/zero of=/mnt/usb/test bs=4M count=253) USB OTG Mode Switching Failed
Troubleshooting Steps:
# 检查 OTG 控制器状态
cat /sys/devices/platform/usb0/state
# 重置 USB 控制器
echo "none" > /sys/devices/platform/usb0/mode
echo "host" > /sys/devices/platform/usb0/mode4) USB Device Power Consumption Too High
Symptom: The development board temperature rises after connecting a high-power USB device
Solutions:
# 启用 USB 设备自动挂起
echo "auto" > /sys/bus/usb/devices/*/power/control
# 设置挂起延时(毫秒)
echo 2000 > /sys/bus/usb/devices/*/power/autosuspend_delay_ms