USB devices in WSL

USB devices in WSL

Context

I have had in the past at least two solid use cases for accessing USB devices in WSL - Yubikey and ESP32 development. Unless you are using a custom kernel, WSL2 does not support USB natively. Fortunately there is now a tool called usbipd-win that enables access to USB devices in WSL. It available at github.com/dorssel/usbipd-win . Installation is straightforward.

Usage

List available devices:

usbipd list

Before you can use the device, you need to bind it. Bus ID can be found from the list above. Binding requires admin privileges and it’s persistent across reboots.

usbipd bind --busid=<BUSID>

Once bound, device can be attached to make it available in WSL. Attaching and detaching does not require admin privileges. It uses default WSL distribution to attach USB device but it will work with all WSL 2 distributions as well. Attaching is not persistent across reboots.

Attach:

usbipd attach --wsl --busid <busid>

List:

usbipd list

Detach:

usbipd detach --wsl --busid <busid>

Instructions are also available at https://learn.microsoft.com/en-us/windows/wsl/connect-usb .

Related Posts

Notes for the Future Self

Notes for the Future Self

I am an engineer at heart and love to tinker—sometimes out of necessity, but mostly driven by curiosity.

Read More