除usbipd之外,还有一个usbip仓库可以参考usbip-win,但是相对麻烦一些
winget install usbipd
usbipd --help
usbipd list
usbipd bind --busid=
> usbip list --remote=<HOST>
> usbip list -r 172.16.5.111 (例子)
Exportable USB devices
======================
- 172.16.5.111
1-9: Fuzhou Rockchip Electronics Company : unknown product (2207:0006)
: USB\VID_2207&PID_0006\5&17411534&0&9
: (Defined at Interface level) (00/00/00)
: 0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/42/01)
> sudo usbip attach --remote= --busid=
报错
libusbip: error: udev_device_new_from_subsystem_sysname failed
usbip: error: open vhci_driver
检查 vhci_hcd 模块: 确保 vhci_hcd
模块已加载
lsmod | grep vhci_hcd
sudo modprobe vhci_hcd
windows上运行
wsl --update
wsl2内运行
sudo apt install linux-tools-virtual hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip `ls /usr/lib/linux-tools/*/usbip | tail -n1` 20
注意:下面的代码是运行在windows上,而不是wsl2上
usbipd wsl --help
usbipd wsl list
usbipd wsl attach --busid=
usbipd wsl attach --busid 1-9
报错:
usbipd: info: Using default WSL distribution 'Ubuntu-20.04'; specify the '--distribution' option to select a different one.
usbip: error: Attach Request for 1-9 failed - Device busy (exported)
usbipd: error: Failed to attach device with busid '1-9'.
adb kill-server
usbipd wsl detach --busid 1-9
wsl2中运行,可发现设备
lsusb
要注意的是必须使用sudo命令才能显示出设备
> adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
> adb kill-server
> sudo adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
5950907f device
> adb devices
List of devices attached
5950907f device