WSL 2: Connect USB devices
HTML-код
- Опубликовано: 21 авг 2024
- WSL 2 now supports connecting USB devices on Windows 11 thanks to contributions to a 3rd party open-source project.
Learn more about what scenarios this enables, how to set things up, see some demos, and hear from Nelson Daniel Troncoso Aldas, the intern that made it happen!
This episode will cover:
[T00:00] Ben McMorran, Software Engineer for WSL, introduces us to recent contributions to a 3rd party open-source project that enables USB devices to be connected to WSL
[T00:25] Why would I want to use USB devices with WSL?
[T01:02] Demo: Set up WSL 2 on Windows 11 to support attaching USB devices and using the usbid wsl command
[T05:54] How does this work? Meet our intern, Nelson!
[T09:37] Where can I learn more?
Learn more:
- Get Windows 11: www.microsoft....
- Get started with attaching USB devices to WSL in the USBIPD-WIN repo on GitHub: aka.ms/wsl-usbip
- Build your own kernel for this to work on Windows 10: github.com/dor...
- WSL documentation: docs.microsoft...
- Azure IoT Device Development: docs.microsoft...
- WSL product repo on GitHub: github.com/Mic...
- Windows Command Line Blog: devblogs.micro...
- More Tabs vs Spaces episodes: • Tabs vs Spaces (Code o...
This is great! I just connected to an RP2040 board from WSL 🙌
Fantastic! Great job all around!
Nice work Nelson!
Hello, I'm trying to use the serial port from WSL2. I connected my USB to TTL converter and see it in the COM1 from device manager.
I attached the device like Ben explained in the video and inside of WSL2 I can see it, doing 'lsusb':
Bus 001 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
But I can't see the mapping: /dev/ttyUSB0.
I' am using WIN11, WSL2 and ubuntu20.04.6 LTS
Did someone have the same issue and could you give me some help?
Does webcam device work in this case? I connected a USB webcam to my computer. While the webcam shows up in "lsusb" after following the procedure, there is no "/dev/Video0" in wsl.
Great! One question, how do I mount it? I run lsblk and I cannot see it.
The command usbipd wsl list doesn't work anymore, as the "wsl" subcommand can't be found anymore. The syntax has changed to something else and the error displayed on CMD/PowerShell as an administrator link me to the same article that still uses the old syntax :/
There is a workaround that was shared on the Github project page! You have to first bind the device with Admin rights, and than you can attach it the same way, but with an addtional subcommand "--wsl". I can't link it here though, as comments with links get automatically deleted.
I still use windows 10 instead of the recommended windows 11. Can my wsl2 still connect to usb? And how? For many developers,out of IT internal policy, no freedom to upgrade OS as we would like.
Nothing in this guide work...
Greate Work, BUT it will not work with a USB Stick (Linux ext3 Format) i attach the stick to wsl , see (dmesg) the stick under wsl , but no device will be created :( PLEASE Fix this BUG !
The USB device shows up when I run lsusb but I don't see anything under dev (i.e. dev/video, dev/ttyusb0). What would I have to do to be able to access it under dev? In my case, the device is a USB Webcam.
Any update on the issue I am having a similar problem
I'm curious for how many people this update makes life easier?
many
The intern reading every sentence from a script :)))
It takes a while to build confidence being on video. I still struggle with it sometimes too. We found Nelson to be quite amazing. This was also recorded right at the tail end of his internship, so we were very thankful he made time to fit it in.
interesting. Maybe someday I will hop back to Windows 11. For now I'm happy using Fedora and running Windows on a VM when needed.
Give it a try some time and let us know what you think!
Thank you so much. It worked for me.
What makes WSL2 and usbipd-win_1.0.0 not compatible with Windows 10?
I'm interested in running SocketCAN under WSL2 with Peak's USB-Can hardware.
Thank's 😎👍
unfortunately, it did not help to connect xbox controller to wsl2, seems that wsl2 does not have joydev module. Don't know how to fix that problem ☹
anyone been able to connect a GPT formatted SD card via WSL2? I've got as a far as mounting my SD and can see the below output when running lsusb:
Bus 001 Device 003: ID 0bda:0306 Realtek Semiconductor Corp. USB3.0 Card Reader
any ideas as to how I mount my gpt partition?
:( Didn't work for me. I have the following
1. Windows 11 build 22000.376,
2. wsl2 (5.10.60.1-microsoft-standard-WSL2)
3. Ubuntu 20.04 LTS running on WSL2
4. usbipd-win_1.3.0
Following exact process, after being asked for sudo passwd and entering it...... I get an error.
usbip: error: tcp connect
usbipd: error: Failed to attach device with ID '1-6'.
Hmm... seems like you've got all the necessary components. Take a look at the "Connect USB devices" page of the WSL documentation. If that doesn't address your problem, then use the link at the bottom of that page to file an issue on the product page and one of the developers may be able to help. Thanks! Hope you can get this worked out.
Is it just me who's wondering now after attaching my usb to linux how do I mount the usb drive so that I can actually access it?🤔
What I have tried :
on windows powershell (executing using admin)
1. "usbipd bind --busid=5-3"
then on distro terminal
2. sudo apt install linux-tools-virtual hwdata
3. sudo update-alternatives --install /usr/local/bin/usbip usbip `ls /usr/lib/linux-tools/*/usbip | tail -n1` 20
again on windows powershell
4. "usbipd wsl attach -b 5-3"
Now it works for me.
@@sougatobagchi7454 how can I do this for arch?
Hi guys, I want to mount USB from wsl to windows. Is there any way to do this. @Ben
So, uh... what device did you actually connect? That would be nice to know. (Edit: OK, I'm stupid. It's that ST-LINK thing.)
I'm trying to get a drawing tablet to work on WSL 2, but any Linux-side applications just perceive it as a mouse. When I attach it with USBIP, it stops doing anything at all. Lsusb shows the device connected, but libinput list-devices turns up blank. So it seems like the only way to fix this is on the Windows side, but I can't find any information at all about how inputs are sent from Windows to Wayland, which leaves my hands tied. So that's fun.
Tried to Connect iPhone but it says access denied
Do i need to install drivers for a embedded device in wsl too...??
My usb device is showing in wsl window when I used lsusb command but not in lsblk
I can't use Lendger Nano using this method... WSL2 sees the device:
> Bus 001 Device 003: ID 2c97:1015 Ledger Nano S
But when I try to interact with it I get:
> Error: no device found
Everything is up to date... How to fix it?
Thanks! I connected my yubikey
I mean. Why we need to do this? Why microsoft doesn't provide builtin support for this?
I have problem with android devices (need to pass it to docker container)
I see device in lsusb in wsl, but "adb devices" show me no devices
What's problem with it?
usbipd repository is down I can't access
Really ? we are complicating this way too much for us devs and users. Why not bake this in rather than having to jump through hoops just to getting USB devices recognized in WSL.
I am facing an error
PS C:\Windows\System32> usbipd wsl attach -b 1-6
usbip: error: tcp connect
usbipd: error: Failed to attach device with ID '1-6'.
please help
I just installed Win11 but the default wsl kernel is 5.10.16, how can I install the required kernel version 5.10.60.1 ? Do I need to use the Win11 insiders build ?
First run in a powershell `wsl --update`
And then `wsl --shutdown`
Maybe you have to call `sudo apt update` into your distro after that.
wsl - -update
thanks
so with this can i share my usb device to another PC in same local network ?
perfect.
I still can’t enable my USB WiFi card after attaching it to WSL2 through the USBIP protocol. Is that because the WSL kernel lack USB WiFi card support?
Try downloading the driver of the specific wifi card chipset to your WSL2
Bonjour, j’essaye de faire reconnaître une carte réseau wifi sous WSL avec Windows 10 et Kali
Quando Microsoft ci da la possibilità di scaricare la App Android su Windows11?
you should really use wsl2 in the video description as it seems to require wsl2 and not wsl
Good point - updated. Thanks!
Thanks for this video ! helped a lot. i have wsl TCP / UDP related question .. i want to run a udp listener on the wsl and send data to it from another host, but it doesn't work, not with windows host ip and not with wsl internal guest ip .. any help ? .. thanks !!
Sorry youre having trouble with this. I'll see if Ben has any recommendations, but I'd also recommend posting your question as an issue in the usbipd-win repo: github.com/dorssel/usbipd-win/issues Support is based on that opensource project and I think the folks there would likely have the best insight to share.
Can we get this in windows 10?
I just added a link to the USBIP project repo that explains how to build your own kernel so that this will work in Windows 10 in the show description notes (it seems to not want to let me add a link in the comments here).
I follow all steps, having Windows Powershell run as Admin, WSL and event Ubuntu run as Admin, but still fail to attach:
usbipd wsl attach -b 1-1
usbipd : /bin/sh: sudo: not found
At line:1 char:1
+ usbipd wsl attach -b 1-1
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (/bin/sh: sudo: not found:String) [], RemoteEx
ception
+ FullyQualifiedErrorId : NativeCommandError
usbipd: error: Failed to attach device with ID '1-1'.
win 11 pro , OS build 22000.376
Could you have a look?
This isn't something that can be addressed in the RUclips comments, but take a look at the "Connect USB devices" page of the WSL documentation. If that doesn't address your problem, then use the link at the bottom of that page to file an issue on the product page and one of the developers may be able to help. Thanks! Hope you can get this worked out.
Will Nvlink be the next update?
If I want to attach a device I'm getting this error message:
$ usbipd wsl attach -b 2-2
```
usbip: error: Attach Request for 2-2 failed - Request Completed Successfully
usbipd: error: Failed to attach device with ID '2-2'.
```
With `uname -a` I'm getting this result:
```
Linux Enes-PC 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
```
Someone knows what I'm doing wrong?
Try quotation marks around the id. "2-2". That worked for me after getting the same error
@@henrikkjolhede6413 sudo: usbip: command not found
usbipd: error: Failed to attach device with ID '2-2'.
i am getting this error
@@arpitnayak5676 If I remember correctly, you need to update the kernel. The update tool is available from Microsoft.
me too
Does this work on windows 10?
I just added a link to the USBIP project repo that explains how to build your own kernel so that this will work in Windows 10 in the show description notes (it seems to not want to let me add a link in the comments here).
I tried to attach my SD card but got error:
WARNING: usbip not found for kernel 5.10.74.3-microsoft
You may need to install the following packages for this specific kernel:
linux-tools-5.10.74.3-microsoft-standard-WSL2
linux-cloud-tools-5.10.74.3-microsoft-standard-WSL2
You may also want to install one of the following packages to keep up to date:
linux-tools-standard-WSL2
linux-cloud-tools-standard-WSL2
usbipd: error: Failed to attach device with ID '1-7'.
and when I try to install those packages then I get error:
E: Unable to locate package linux-tools-5.10.74.3-microsoft-standard-WSL2
E: Couldn't find any package by glob 'linux-tools-5.10.74.3-microsoft-standard-WSL2'
any idea how to solve that?
I've got the same problem, but my kernel version is 5.10.60.1. Git repository says that kernels of version 5.10.60.1 and above (including yours) should support this feature. I don't know why it doesn't work.
I found a solution. Open description of this video and follow a link next to "Build your own kernel for this to work on Windows 10:". Only follow the steps to build libusbip there (do not follow any other steps because you have got a right version of kernel)
Agree with Kostia's solution in the previous comment. If you continue to have trouble, you can also file an issue on the USBIPD-WIN repo that is linked in the description of the show.
@@kostiapereguda Which steps do you start in? I'm a little confused about which portion of the steps I'm supposed to start at if my kernel version is correct
@@Nomad-qm3zf clone the repo, checkout the needed tag and move to the step “Build USBIP tools”
windows 11.... pfffff.....
THX BUT IF YOU WORK ON MICROSOFT TELL YOUR CHEFS TO BRING IT WINDOWS OFFICIALLY !!!
Great video but I don't like music when question arrives please change that music 🎵🙂
The Amish gave up the old ways??