01 USB
1 USB Interface Overview
GM-3568JHF development board is designed based on Rockchip RK3568J chip, providing rich USB interfaces to support various USB device connections and data transmission needs.
1.1 USB Interface Configuration
| Interface Type | Quantity | Specification | Description |
|---|---|---|---|
| USB 3.0 OTG | 1 | Type-C | Supports Host/Device mode switching |
| USB 3.0 HOST | 1 | Type-A | Host mode, connecting peripherals |
| USB 2.0 HOST | 2 | Type-A | Host mode, connecting peripherals |
1.2 RK3568J USB Controller Features
1) USB 3.0 Controller:
- USB Standard: Compatible with USB 3.0/2.0/1.1 standards
- Transmission 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 resume 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, mobile hard disk, USB SSD
- Input Devices: USB mouse, keyboard, game controller
- Audio Devices: USB speaker, USB microphone, USB sound card
- Network Devices: USB network card, 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 interface 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, 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 follow these steps to mount it:
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 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 Transmission Rate Test
- Determine 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 inserted 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 will read data from the USB device and write it to /dev/null to test the read speed. Here, the write block size is specified as 1M, and 100 blocks are read, so a total of 100 MB of data is read, and the read speed is 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 write block size is specified as 1M, and 100 blocks are written, so a total of 100 MB of data is written, and the write speed is 15.1 MB/s.
3 USB OTG Function
3.1 OTG Mode Switching
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 various USB devices:
# Check OTG current mode
cat /sys/devices/platform/usb0/mode
# Switch to host mode
echo "host" > /sys/devices/platform/usb0/mode- Device Mode In device mode, the development board acts as a USB device and can connect to a PC or other hosts:
# Switch to device mode
echo "peripheral" > /sys/devices/platform/usb0/mode
# Check available USB functions
ls /sys/class/udc/3.2 USB Gadget Function
The development board supports various USB Gadget functions:
1) Mass Storage Device
# Configure as USB storage device
modprobe g_mass_storage file=/dev/mmcblk0p12) Network Device (Ethernet Gadget)
# Configure as USB network device
modprobe g_ether3) Serial Device (Serial Gadget)
# Configure as USB serial device
modprobe g_serial4 Performance Optimization Suggestions
4.1 USB 3.0 Performance Optimization
- Use high-quality USB cables: Ensure using cables compliant with USB 3.0 standards.
- Avoid USB Hubs: Connect devices directly for best performance.
- File system selection: For large file transfers, it is recommended to use exFAT or NTFS file systems.
- Block size optimization: Use larger block sizes for data transmission.
4.2 Power Management
# Disable USB auto-suspend (improve response speed)
echo -1 > /sys/module/usbcore/parameters/autosuspend
# Check USB device power status
cat /sys/bus/usb/devices/*/power/control5 Troubleshooting
1) USB Device Not Recognized
Symptom: System does not respond after inserting USB device.
Troubleshooting Steps:
# Check USB controller status
lsusb -t
# Check kernel logs
dmesg | grep -i usb
# Check USB port power
cat /sys/bus/usb/devices/*/power/level2) Slow USB Transmission Speed
Possible Causes:
- USB cable quality issue
- USB device performance limitation
- File system fragmentation
Solution:
# Check USB device speed
lsusb -v | grep -E "bcdUSB|MaxPower"
# Test transmission performance with different block sizes
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:
# Check OTG controller status
cat /sys/devices/platform/usb0/state
# Reset USB controller
echo "none" > /sys/devices/platform/usb0/mode
echo "host" > /sys/devices/platform/usb0/mode4) USB Device Power Consumption Too High
Symptom: Development board temperature rises after connecting high-power USB device.
Solution:
# Enable USB device auto-suspend
echo "auto" > /sys/bus/usb/devices/*/power/control
# Set suspend delay (ms)
echo 2000 > /sys/bus/usb/devices/*/power/autosuspend_delay_ms