2024-05-08 14:33:42 +08:00
|
|
|
|
# RK3568 USB3 OTG 说明
|
|
|
|
|
|
|
|
|
|
RK3568 USB3 OTG 可以作为 A 类型(主机)或 B 类型(外设)设备使用。USB3 有两个地址,0xfe8a0000 作为 External Connector 使用,实际上为 USB PHY,0xfcc00000 作为 USB Dual Role Device 使用。
|
|
|
|
|
|
|
|
|
|
USB3 OTG 使用 170 脚 USB3_OTG0_ID 来判断自己工作在 A 模式还是 B 模式,该引脚为高电平时为 B 模式,为低电平时为 A 模式。
|
|
|
|
|
|
|
|
|
|
用于连接主机的 USB 接口(Type A)为 4 线(D+、D-、VBUS 和 GND),因此 USB3_OTG0_ID 悬空,RK3568 工作在 B 模式。
|
|
|
|
|
|
|
|
|
|
```mermaid
|
|
|
|
|
flowchart LR
|
|
|
|
|
subgraph OTG
|
|
|
|
|
OTG_Gnd
|
|
|
|
|
OTG_ID
|
|
|
|
|
OTG_D+
|
|
|
|
|
OTG_D-
|
|
|
|
|
OTG_VCC
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
subgraph USB
|
|
|
|
|
USB_Gnd
|
|
|
|
|
USB_D+
|
|
|
|
|
USB_D-
|
|
|
|
|
USB_VCC
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
OTG_Gnd --- USB_Gnd
|
|
|
|
|
OTG_D+ --- USB_D+
|
|
|
|
|
OTG_D- --- USB_D-
|
|
|
|
|
OTG_VCC --- USB_VCC
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
USB OTG 扩展 HUB 的线束中 CC1 或 CC2 下拉接地,导致与其相连的 USB3_OTG0_ID 也被下拉,此时 RK3568 进入 A 模式。
|
|
|
|
|
|
|
|
|
|
```mermaid
|
|
|
|
|
flowchart LR
|
|
|
|
|
subgraph OTG
|
|
|
|
|
OTG_Gnd
|
|
|
|
|
OTG_ID
|
|
|
|
|
OTG_D+
|
|
|
|
|
OTG_D-
|
|
|
|
|
OTG_VCC
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
subgraph USB
|
|
|
|
|
USB_Gnd
|
|
|
|
|
USB_D+
|
|
|
|
|
USB_D-
|
|
|
|
|
USB_VCC
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
OTG_Gnd --- USB_Gnd
|
|
|
|
|
OTG_D+ --- USB_D+
|
|
|
|
|
OTG_D- --- USB_D-
|
|
|
|
|
OTG_VCC --- USB_VCC
|
|
|
|
|
OTG_ID --- USB_Gnd
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
使用软件可以强制 USB3 OTG 工作在 A、B 或 OTG 模式,方法如下:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
#Force host mode 主机
|
|
|
|
|
echo host > /sys/devices/platform/fe8a0000.usb2-phy/otg_mode
|
|
|
|
|
|
|
|
|
|
#Force device mode 从机
|
|
|
|
|
echo peripheral > /sys/devices/platform/fe8a0000.usb2-phy/otg_mode
|
|
|
|
|
|
|
|
|
|
#Force otg mode 根据硬件识别自动切换
|
|
|
|
|
echo otg > /sys/devices/platform/fe8a0000.usb2-phy/otg_mode
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
当 USB3 OTG 工作在 B 模式时可以模拟多种外设:
|
|
|
|
|
|
|
|
|
|
- usb_adb_en - ADB 调试
|
|
|
|
|
- usb_rndis_en - RNDIS USB模拟以太网
|
|
|
|
|
- usb_acm_en - ACM USB虚拟串口
|
|
|
|
|
- usb_ums_en - UMS 虚拟存储设备
|
|
|
|
|
- usb_uac1_en - UAC 虚拟声卡
|
|
|
|
|
- usb_uac2_en - UAC 虚拟声卡
|
|
|
|
|
|
|
|
|
|
这些模式的切换可以通过修改 /tmp/.usb_config 使其临时生效或修改 /etc/init.d/.usb_config 进行持久化。
|
|
|
|
|
|
|
|
|
|
修改后需要执行:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
/usr/bin/usbdevice restart
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
使其生效。
|
|
|
|
|
|
|
|
|
|
## ADB 调试
|
|
|
|
|
|
|
|
|
|
.usb_config 文件如下:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
usb_adb_en
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## RNDIS USB模拟以太网
|
|
|
|
|
|
|
|
|
|
.usb_config 文件如下:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
usb_rndis_en
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## ACM USB虚拟串口
|
|
|
|
|
|
|
|
|
|
.usb_config 文件如下:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
usb_acm_en
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## USB Mass Storage(UMS)Device 虚拟存储设备
|
|
|
|
|
|
|
|
|
|
.usb_config 文件如下:
|
|
|
|
|
|
|
|
|
|
```bash
|
2024-05-08 14:35:05 +08:00
|
|
|
|
# For VBUS_ALWAYS_ON usb otg is not support ums
|
|
|
|
|
# Since the block to ums is always occupated by USB due to no disconneted state
|
2024-05-08 14:33:42 +08:00
|
|
|
|
usb_ums_en
|
|
|
|
|
# 配置挂载的镜像文件地址
|
|
|
|
|
ums_block=/ums_shared.img
|
|
|
|
|
# 设置镜像文件大小,单位为MB
|
|
|
|
|
ums_block_size=8
|
|
|
|
|
# 设置文件系统格式为fat
|
|
|
|
|
ums_block_type=fat
|
|
|
|
|
# 设置断开UMS后自动挂载到/mnt/ums目录
|
|
|
|
|
# ums_block_auto_mount=on
|
2024-05-08 14:35:05 +08:00
|
|
|
|
# 读写权限控制
|
|
|
|
|
# UMS_RO=0
|
2024-05-08 14:33:42 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
***注:实测开启 ums_block_auto_mount 后主机无法挂载虚拟存储设备,似乎跟硬件电路有关。***
|
|
|
|
|
|
|
|
|
|
## UAC 虚拟声卡
|
|
|
|
|
|
|
|
|
|
UAC 分为 UAC1 和 UAC2,UAC2 和 UAC1 有以下区别: UAC2 比 UAC1 具有更高的带宽(各平台实现略有不同,以实测为准) Windows7 及部分 Windows10 系统默认不支持 UAC2,需要手动安装驱动,但都支持 UAC1。
|
|
|
|
|
|
|
|
|
|
.usb_config 文件如下:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
usb_uac1_en
|
|
|
|
|
# 或
|
|
|
|
|
# usb_uac2_en
|
|
|
|
|
```
|