This is useful for embedded work in devcontainers.
see: https://docs.microsoft.com/en-us/windows/wsl/connect-usb
-
install usbipd-win on Windows host
-
install usbip client tools in any WSL distro (prefered the default distro, but any distro should work, since all distros share the same kernel and thus the same devices)
- Ubuntu: follow the standard installation process linked above
- docker-desktop:
apk update
apk upgrade
- update version numbers in
/etc/apk/repositories
to latest (e.g. "3.9" -> "3.16") apk update --allow-untrusted
apk upgrade --available --allow-untrusted && sync
apk add alpine-keys --allow-untrusted
apk add linux-tools-usbip hwdata-usb hwids-usb usbutils
-
attach device to WSL (if the usbip client tools are not installed in the default distro, use option
usbipd -d <distro>
)
- start docker container from windows host, use
--device=
option to pass device from WSL to container:docker run -it --rm --device="/dev/bus/usb/<busid>/<devid>" <some image>
- the
busis:devid
in WSL is not the same as on the host machine, use lsusb to get the id
- the
- Use
"runArgs": ["--device=/dev/bus/usb/<busid>/<devid>"]
to pass device to container on devcontainer start