2023-10-21
windows wsl2 connect to host usb
參照這篇 https://learn.microsoft.com/en-us/windows/wsl/connect-usb
-
Install USBIPD-WIN
- PS:
usbipd wsl attach --busid <busid>
to bind USB to wsl
PS C:\WINDOWS\system32> usbipd list Connected: BUSID VID:PID DEVICE STATE 1-1 1c4f:0034 USB Input Device Not shared 1-2 18d1:4ee2 Nexus 5, Android Composite ADB Interface Not shared 1-7 8087:0a2b Intel(R) Wireless Bluetooth(R) Not shared 1-8 04f2:b604 Integrated Camera Not shared 1-9 06cb:009a Synaptics WBDI - SGX Not shared 1-15 0bda:0316 Realtek USB 3.0 Card Reader Not shared
PS C:\WINDOWS\system32> wsl --list Windows Subsystem for Linux Distributions: Ubuntu-22.04 (Default) Ubuntu
PS C:\WINDOWS\system32> usbipd wsl attach --busid 1-2 usbipd: info: Using default WSL distribution 'Ubuntu-22.04'; specify the '--distribution' option to select a different one.
PS C:\WINDOWS\system32> usbipd wsl list BUSID VID:PID DEVICE STATE 1-1 1c4f:0034 USB Input Device Not attached 1-2 18d1:4ee0 Android Bootloader Interface Attached - WSL 1-7 8087:0a2b Intel(R) Wireless Bluetooth(R) Not attached 1-8 04f2:b604 Integrated Camera Not attached 1-9 06cb:009a Synaptics WBDI - SGX Not attached 1-15 0bda:0316 Realtek USB 3.0 Card Reader Not attached
- wsl:
usbip port
to find the USB port
# usbip port Imported USB devices ==================== Port 00: <Port in Use> at High Speed(480Mbps) Google Inc. : Nexus/Pixel Device (fastboot) (18d1:4ee0) 1-1 -> usbip://172.28.96.1:3240/1-2 -> remote bus/dev 001/002
- PS:
Q&A
usbip: error: Attach Request for 1-2 failed - Device busy (exported)
不要先 fastboot flash recovery recovery.img
不然會卡住