Intro

Connecting USB devices to wsl2 1

Using USBIPD-WIN on WSL

https://learn.microsoft.com/en-us/windows/wsl/connect-usb

  • Install USBIPD
winget install --interactive --exact dorssel.usbipd-win
  • Open PowerShell in administrator mode and list USB devices connected to Windows
usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
1-9    13d3:56eb  USB2.0 HD UVC WebCam, USB2.0 IR UVC WebCam, Camera DFU De...  Not shared
1-14   8087:0026  Intel(R) Wireless Bluetooth(R)                                Not shared
3-1    093a:2533  USB Input Device                                              Not shared
3-2    20d6:2035  Xbox Gaming Device                                            Shared
3-3    1532:0016  USB Input Device                                              Not shared
3-4    1532:010d  USB Input Device                                              Not shared

Persisted:
GUID                                  DEVICE
  • Share the USB device using the bus ID
usbipd bind --busid 3-2 
  • Attach the USB device to WSL (a WSL command prompt must also be open open )
    • Note that as long as the USB device is attached to WSL, it cannot be used by Windows
usbipd attach --wsl --busid 3-2
  • Open Ubuntu/WSL and list the attached USB devices
usbipd: info: Using WSL distribution 'Ubuntu' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Using IP address 127.0.0.1 to reach the host.
  • Verify that the device is attached using usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
1-9    13d3:56eb  USB2.0 HD UVC WebCam, USB2.0 IR UVC WebCam, Camera DFU De...  Not shared
1-14   8087:0026  Intel(R) Wireless Bluetooth(R)                                Not shared
4-1    093a:2533  USB Input Device                                              Not shared
4-2    20d6:2035  Xbox Gaming Device                                            Attached
4-3    046d:c08b  G502 HERO, USB Input Device, Virtual HID Framework (VHF) ...  Not shared
4-4    1532:010d  USB Input Device                                              Not shared
  • From the WSL prompt, verify that the device is listed
lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 20d6:2035 PowerA Xbox Series X Wired Controller Black
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  • Disconnect the device once you are done
usbipd detach --busid <busid>
  • Note: You will still likely need to recompile the Linux kernel to make the drivers available in WSL (See WSL Kernel)

Footnotes

  1. https://github.com/microsoft/WSL/issues/7747#issuecomment-2143500818