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...

Комментарии • 81

  • @kellyhpdx
    @kellyhpdx 2 года назад +9

    This is great! I just connected to an RP2040 board from WSL 🙌

  • @henrikkjolhede6413
    @henrikkjolhede6413 2 года назад +2

    Fantastic! Great job all around!

  • @MatthewCallier
    @MatthewCallier 2 года назад +3

    Nice work Nelson!

  • @nicoromero6423
    @nicoromero6423 Год назад +8

    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?

  • @broccoli322
    @broccoli322 2 года назад +8

    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.

  • @xphis0528
    @xphis0528 2 года назад +8

    Great! One question, how do I mount it? I run lsblk and I cannot see it.

  • @ashar8192
    @ashar8192 7 месяцев назад +5

    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 :/

    • @ashar8192
      @ashar8192 7 месяцев назад +1

      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.

  • @Misterbee0407
    @Misterbee0407 2 года назад +4

    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.

  • @MrDamians82
    @MrDamians82 6 месяцев назад +6

    Nothing in this guide work...

  • @mikegibtesnicht4220
    @mikegibtesnicht4220 Год назад +4

    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 !

  • @adamryason5509
    @adamryason5509 Год назад +3

    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.

    • @zer0k4ge
      @zer0k4ge 6 месяцев назад +3

      Any update on the issue I am having a similar problem

  • @coolzcold
    @coolzcold 2 года назад +3

    I'm curious for how many people this update makes life easier?

  • @paperexplained
    @paperexplained 2 года назад +2

    The intern reading every sentence from a script :)))

    • @MattWojo
      @MattWojo 2 года назад +5

      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.

  • @FelipeVercingetorix
    @FelipeVercingetorix 2 года назад +1

    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.

    • @MattWojo
      @MattWojo 2 года назад

      Give it a try some time and let us know what you think!

  • @official_korea
    @official_korea Год назад

    Thank you so much. It worked for me.

  • @bennguyen1313
    @bennguyen1313 11 месяцев назад +2

    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.

  • @fernandovelazquez8295
    @fernandovelazquez8295 2 года назад +1

    Thank's 😎👍

  • @SCIENindustries
    @SCIENindustries Год назад +1

    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 ☹

  • @samx2222
    @samx2222 Год назад +2

    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?

  • @keyurjoshi
    @keyurjoshi 2 года назад +1

    :( 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'.

    • @MattWojo
      @MattWojo 2 года назад

      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.

  • @ejvandijk
    @ejvandijk Год назад +5

    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?🤔

    • @sougatobagchi7454
      @sougatobagchi7454 Год назад

      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.

    • @socrodex6235
      @socrodex6235 Год назад

      @@sougatobagchi7454 how can I do this for arch?

  • @bushramustofa2135
    @bushramustofa2135 2 года назад +2

    Hi guys, I want to mount USB from wsl to windows. Is there any way to do this. @Ben

  • @leirbag75
    @leirbag75 2 месяца назад

    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.

  • @qwertyiopzqz8075
    @qwertyiopzqz8075 2 года назад +1

    Tried to Connect iPhone but it says access denied

  • @HexDefender
    @HexDefender 7 месяцев назад +1

    Do i need to install drivers for a embedded device in wsl too...??

  • @Simplyunknownhere
    @Simplyunknownhere 2 месяца назад

    My usb device is showing in wsl window when I used lsusb command but not in lsblk

  • @STEALTH42UA
    @STEALTH42UA Год назад

    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?

  • @klev1983
    @klev1983 2 года назад

    Thanks! I connected my yubikey

  • @zurrechten244
    @zurrechten244 25 дней назад

    I mean. Why we need to do this? Why microsoft doesn't provide builtin support for this?

  • @user-ci6ky3ub2i
    @user-ci6ky3ub2i Год назад

    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?

  • @devTalks3641
    @devTalks3641 7 дней назад

    usbipd repository is down I can't access

  • @N0AGI
    @N0AGI 2 года назад +2

    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.

  • @THE-SLEDGEHAMMER
    @THE-SLEDGEHAMMER 2 года назад

    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

  • @pablo_costas
    @pablo_costas 2 года назад +1

    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 ?

    • @produktboost39
      @produktboost39 2 года назад

      First run in a powershell `wsl --update`
      And then `wsl --shutdown`
      Maybe you have to call `sudo apt update` into your distro after that.

    • @MattWojo
      @MattWojo 2 года назад

      wsl - -update

  • @some-thing-2024
    @some-thing-2024 2 года назад

    thanks

  • @kamillatocha
    @kamillatocha Год назад

    so with this can i share my usb device to another PC in same local network ?

  • @tajsec498
    @tajsec498 2 года назад

    perfect.

  • @Slybabyfox
    @Slybabyfox 10 месяцев назад

    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?

    • @eliyahhawila4577
      @eliyahhawila4577 6 месяцев назад

      Try downloading the driver of the specific wifi card chipset to your WSL2

  • @Th-in9lr
    @Th-in9lr 11 месяцев назад

    Bonjour, j’essaye de faire reconnaître une carte réseau wifi sous WSL avec Windows 10 et Kali

  • @cristianlambiase9526
    @cristianlambiase9526 2 года назад

    Quando Microsoft ci da la possibilità di scaricare la App Android su Windows11?

  • @kentjohansson6937
    @kentjohansson6937 2 года назад

    you should really use wsl2 in the video description as it seems to require wsl2 and not wsl

    • @MattWojo
      @MattWojo 2 года назад +1

      Good point - updated. Thanks!

  • @GuyA
    @GuyA 2 года назад

    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 !!

    • @MattWojo
      @MattWojo 2 года назад

      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.

  • @NickPaul41
    @NickPaul41 2 года назад +1

    Can we get this in windows 10?

    • @MattWojo
      @MattWojo 2 года назад

      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).

  • @Thanhvo31
    @Thanhvo31 2 года назад

    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?

    • @MattWojo
      @MattWojo 2 года назад +1

      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.

  • @jimishreds
    @jimishreds 2 года назад

    Will Nvlink be the next update?

  • @produktboost39
    @produktboost39 2 года назад

    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?

    • @henrikkjolhede6413
      @henrikkjolhede6413 2 года назад

      Try quotation marks around the id. "2-2". That worked for me after getting the same error

    • @arpitnayak5676
      @arpitnayak5676 2 года назад

      @@henrikkjolhede6413 sudo: usbip: command not found
      usbipd: error: Failed to attach device with ID '2-2'.
      i am getting this error

    • @henrikkjolhede6413
      @henrikkjolhede6413 2 года назад

      @@arpitnayak5676 If I remember correctly, you need to update the kernel. The update tool is available from Microsoft.

    • @mlmgadgetsspecialistandrep4035
      @mlmgadgetsspecialistandrep4035 2 года назад

      me too

  • @kostiapereguda
    @kostiapereguda 2 года назад

    Does this work on windows 10?

    • @MattWojo
      @MattWojo 2 года назад +1

      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).

  • @SCIENindustries
    @SCIENindustries 2 года назад +1

    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?

    • @kostiapereguda
      @kostiapereguda 2 года назад

      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.

    • @kostiapereguda
      @kostiapereguda 2 года назад +1

      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)

    • @MattWojo
      @MattWojo 2 года назад

      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.

    • @Nomad-qm3zf
      @Nomad-qm3zf 2 года назад

      @@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

    • @kostiapereguda
      @kostiapereguda 2 года назад +1

      @@Nomad-qm3zf clone the repo, checkout the needed tag and move to the step “Build USBIP tools”

  • @DooMRunneR
    @DooMRunneR 2 года назад +4

    windows 11.... pfffff.....

  • @nildesperandum2034
    @nildesperandum2034 7 месяцев назад

    THX BUT IF YOU WORK ON MICROSOFT TELL YOUR CHEFS TO BRING IT WINDOWS OFFICIALLY !!!

  • @idanishansari
    @idanishansari 2 года назад

    Great video but I don't like music when question arrives please change that music 🎵🙂

  • @DrN007
    @DrN007 2 года назад

    The Amish gave up the old ways??