USB
1 USB Interface Overview
The MB-E30P development board is designed based on the Rockchip RK3568J chip and provides rich USB interfaces, supporting various USB device connections and data transfer needs.
1.1 USB Interface Configuration
| Interface Type | Quantity | Specification | Function Description |
|---|---|---|---|
| USB 3.0 OTG | 1 | Type-C | Supports host/device mode switching |
| USB 2.0 HOST | 1 | 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: USB 3.0 up to 5Gbps, USB 2.0 up to 480Mbps
- OTG Function: Supports automatic switching between Host and Device modes
- Power Management: Supports USB suspend and wake functions
- Hot Plug: Supports device hot-plug detection
2) USB 2.0 Controller:
- 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 drives, mobile hard drives, USB SSDs
- Input Devices: USB mouse, keyboard, gamepad
- Audio Devices: USB speakers, 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 a USB Device
Plug the USB device (such as a USB flash drive, mouse, keyboard, etc.) into the development board's USB interface. The system will automatically identify the device and load the corresponding driver.
2) Viewing Connected USB Devices
Use the following command to view 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 (Mouse) has been recognized.
3) Mounting a USB Storage Device
If a USB storage device (such as a USB flash drive) is connected, you can mount it with the following steps:
View device nodes:
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 mount results:
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 RK3568's USB 3.0 OTG interface 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; 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; 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 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, for a total of 100 M of data 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 the use of cables that comply with the USB 3.0 standard
- Avoid USB Hubs: Connect devices directly for optimal performance
- File System Choice: 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: The system does not respond after a USB device is plugged in
Troubleshooting Steps:
# 检查 USB 控制器状态
lsusb -t
# 查看内核日志
dmesg | grep -i usb
# 检查 USB 端口电源
cat /sys/bus/usb/devices/*/power/level2) Slow USB Transfer Speed
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 Failure
Troubleshooting Steps:
# 检查 OTG 控制器状态
cat /sys/devices/platform/usb0/state
# 重置 USB 控制器
echo "none" > /sys/devices/platform/usb0/mode
echo "host" > /sys/devices/platform/usb0/mode4) Excessive USB Device Power Consumption
Symptom: The development board's 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