MicrosoftDocs / WSL

Source code behind the Windows Subsystem for Linux documentation.
https://docs.microsoft.com/windows/wsl
Other
1.88k stars 556 forks source link

wsl subcommand removed - Docs say otherwise #1868

Closed fpschrisiom closed 6 months ago

fpschrisiom commented 7 months ago

Documentation Issue

Run this command as per docs: usbipd wsl list

usbipd: error: The 'wsl' subcommand has been removed. Learn about the new syntax at https://learn.microsoft.com/windows/wsl/connect-usb#attach-a-usb-device

Link to documentation page

https://learn.microsoft.com/windows/wsl/connect-usb#attach-a-usb-device

Suggested Improvements

Please update documentation to reflect changes

BerndNW18 commented 7 months ago

leaving out the "wsl" option worked for me. I.e.: PS C:> usbipd list hope this helps :)

IngmarG commented 7 months ago

Works indeed, but the docs on the referenced page still uses the wsl subcommand.

ludy51 commented 7 months ago

I also encountered this problem, may I ask how to solve, the command must be added 'wsl', for wsl to access usb devices

ludy51 commented 7 months ago

Hi. Found a solution: The latest usbipd-win4.0.0 version reported an error under the window shell, unable to add the 'wsl' parameter, so that wsl can access usb devices. If it is replaced with 3.10, no error is reported. https://learn.microsoft.com/windows/wsl/connect-usb#attach-a-usb-device :The document mentions that downloading the latest version of usbipd-win requires corrections

BerndNW18 commented 7 months ago

Hi, here is my complete solution on how to forward a USB port to WSL2, using the latest usbipd-win. Note that my use-case is connecting to an rplidar fromSlamtec, which uses a Silicon Labs CP210x USB-to-serial Interface board to connect to the actual Lidar device.

ACTIVATING USB FORWARDING TO WSL2

Purpose: make USB to Serial Bridge accessible in WSL2 to test the RPLidar SDK build on WSL Linux (Ubuntu)

  1. Install usbipd-win on the Windows-host: https://github.com/dorssel/usbipd-win/releases

  2. Install USBIP tools and hardware-database in Linux (WSL) bernd@myOmen:\~$ sudo apt install linux-tools-generic hwdata bernd@myOmen:\~$ sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/*-generic/usbip 20

  3. Open Powershell (Administrator)

  4. PS C:\WINDOWS\system32> usbipd list Output: BUSID VID:PID DEVICE STATE 2-2 10c4:ea60 Silicon Labs CP210x USB to UART Bridge (COM3) Not shared 2-6 30c9:0069 HP Wide Vision HD Camera, Camera DFU Device Not shared 2-8 0461:4f03 USB Input Device Not shared 2-10 8087:0033 Intel(R) Wireless Bluetooth(R) Not shared 3-2 046d:081b Logi C310 HD WebCam Not shared 4-1 05a7:1020 Bose USB Audio, USB Input Device Not shared 4-2 046d:c52b Logitech USB Input Device, USB Input Device Not shared 4-3 04e8:329f Samsung CLP-320 Series Not shared

  5. We're interested in sharing the CP210x, so run PS C:\WINDOWS\system32> usbipd bind -b 2-2 where "2-2" is the value in BUSID column from usbipd list

  6. PS C:\WINDOWS\system32> usbipd list Output: BUSID VID:PID DEVICE STATE 2-2 10c4:ea60 Silicon Labs CP210x USB to UART Bridge (COM3) Shared 2-6 30c9:0069 HP Wide Vision HD Camera, Camera DFU Device Not shared

    "Shared" means ready to be forwarded, but still parked

  7. PS C:\WINDOWS\system32> usbipd attach --wsl --busid 2-2 #this will now forward the USB-device. You will hear the "unplug" chime in Windows. Output: usbipd: info: Using WSL distribution 'Ubuntu' to attach; the device will be available in all WSL 2 distributions. usbipd: info: Using IP address 172.26.144.1 to reach the host.

  8. PS C:\WINDOWS\system32> usbipd list #check if it worked Output: BUSID VID:PID DEVICE STATE 2-2 10c4:ea60 Silicon Labs CP210x USB to UART Bridge (COM3) Attached 2-6 30c9:0069 HP Wide Vision HD Camera, Camera DFU Device Not shared

  9. Open WSL

  10. bernd@myOmen:~$ lsusb Output: Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 10c4:ea60 Silicon Labs CP210x UART Bridge Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bingo!

  11. bernd@myOmen:~$ ls -l /dev/ttyUSB* #check permissions crw-rw---- 1 root dialout 188, 0 Dec 8 11:30 /dev/ttyUSB0

  12. check if you're in the group (dialout): bernd@myOmen:~$ groups bernd adm dialout cdrom floppy sudo audio dip video plugdev netdev docker

  13. change to RPLidar SDK folder where the built demos are

  14. run one of the sdk-demos to check if the connection works: bernd@myOmen:~/rplidar/rplidar_sdk/output/Linux/Release$ ./simple_grabber --channel --serial /dev/ttyUSB0 256000 Output: SLAMTEC LIDAR S/N: E6BAED95C4E493CDA5E69EF0776A4B69 Version: SL_LIDAR_SDK_VERSION Firmware Ver: 1.32 Hardware Rev: 6 Lidar health status : OK. (errorcode: 0) waiting for data...

    [histogram data is shown]

    Do you want to see all the data? (y/n) n -> works. Yay!

CLEANUP (un-forward USB)

  1. PS C:\WINDOWS\system32> usbipd detach --busid 2-2
  2. PS C:\WINDOWS\system32> usbipd list Connected: BUSID VID:PID DEVICE STATE 2-2 10c4:ea60 Silicon Labs CP210x USB to UART Bridge (COM3) Shared 2-6 30c9:0069 HP Wide Vision HD Camera, Camera DFU Device Not shared
  3. PS C:\WINDOWS\system32> usbipd unbind --busid 2-2
  4. PS C:\WINDOWS\system32> usbipd list Connected: BUSID VID:PID DEVICE STATE 2-2 10c4:ea60 Silicon Labs CP210x USB to UART Bridge (COM3) Not shared 2-6 30c9:0069 HP Wide Vision HD Camera, Camera DFU Device Not shared

REFERENCES

https://learn.microsoft.com/de-de/windows/wsl/connect-usb#attach-a-usb-device These instructions contain errors, which I attempt to correct with this document

https://github.com/MicrosoftDocs/WSL/issues/1868 Issue raised about above incorrect instructions `

zitons commented 7 months ago

uspipd list

it works

fancybear-dev commented 7 months ago

PR that addresses this is not yet merged; https://github.com/MicrosoftDocs/WSL/pull/1870

limkokhole commented 7 months ago

leaving out the "wsl" option worked for me. I.e.: PS C:> uspipd list hope this helps :)

You should fix typo uspipd to usbipd

Pignataro1999 commented 6 months ago

Hi, I followed all your instructions, but when I type the command ls -l /dev/ttyUSB the output is "ls: cannot access '/dev/ttyUSB' : no such file or directory. I already checked if I'm in the group dealout and I am. I'm trying to connect a USB camera I hope you can help me!

mattwojo commented 6 months ago

Thanks for filing this issue @limkokhole. This issue is being fixed in https://github.com/MicrosoftDocs/WSL/pull/1870.