wsl2 arch linux访问ch340串口和usb设备
- 安装usb转网络软件usbipd
- 共享usb到网络
- wsl2安装usbip
- 挂载USB设备
- 卸载USB设备
安装usb转网络软件usbipd
在powershell执行下面命令安装
winget install --interactive --exact dorssel.usbipd-win
共享usb到网络
#查看USB设备
usbipd listPS C:\Windows\system32> usbipd list
Connected:
BUSID VID:PID DEVICE STATE
1-6 04f3:289b USB 输入设备 Not shared
1-8 5986:2130 Integrated Camera Not shared
1-9 06cb:00bd Synaptics UWP WBDI Not shared
1-10 8087:0aaa 英特尔(R) 无线 Bluetooth(R) Not shared
3-4 0b95:1790 ASIX USB to Gigabit Ethernet Family Adapter Not shared
4-1 1a86:7523 USB-SERIAL CH340 (COM3) Shared
4-3 0403:6015 USB Serial Converter Not sharedPersisted:
GUID DEVICE#共享usb设备
usbipd bind --busid <busid>
usbipd bind --busid 4-1
wsl2安装usbip
sudo pacman -S linux-tools
sudo pacman -S pciutils usbutils
sudo pacman -S usbip
挂载USB设备
sudo usbip attach -r <windows_ip> -b <busid>
sudo usbip attach -r 172.29.0.1 -b 4-1#挂载成功
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 1a86:7523 QinHeng Electronics CH340 serial converter
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hubls /dev/ttyUSB*
/dev/ttyUSB0#使用minicom验证
sudo minicom -D /dev/ttyUSB0 -b 115200 -H -w
卸载USB设备
sudo usbip port
Imported USB devices
====================
Port 00: <Port in Use> at Full Speed(12Mbps)QinHeng Electronics : CH340 serial converter (1a86:7523)1-1 -> usbip://172.29.0.1:3240/4-1-> remote bus/dev 004/001sudo usbip detach -p <port number>
sudo usbip detach -p 0
usbip: info: Port 0 is now detached!