WSL2 使用windows usb设备

1、Windows安装

如果出现报错
usbipd: error: The service is currently not running; a reboot should fix that.
需要重新安装一次。

winget install --interactive --exact dorssel.usbipd-win

2、WSL安装

sudo apt install linux-tools-generic hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/*-generic/usbip 20

3、附加usb设备

usbipd server
启动服务
usbipd wsl list
列出设备
BUSID VID:PID DEVICE STATE
2-1 1a86:7523 USB-SERIAL CH340 (COM17) Not attached
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

usbipd wsl attach -b --2-1

/dev/下多了一个ttyUSB0

usbipd wsl detach -b --2-1

注意只支持WSL2

posted @ 2023-04-04 17:07  zhaogaojian  阅读(418)  评论(0编辑  收藏  举报