Giter VIP home page Giter VIP logo

usbipd-win's Introduction

usbipd-win

Build CodeQL MegaLinter REUSE status codecov GitHub all releases

Windows software for sharing locally connected USB devices to other machines, including Hyper-V guests and WSL 2.

How to install

This software requires Microsoft Windows 10 (x64 only) / Microsoft Windows Server 2019, version 1809 or newer; it does not depend on any other software.

Run the installer (.msi) from the latest release on the Windows machine where your USB device is connected.

Alternatively, use the Windows Package Manager:

winget install usbipd

This will install:

  • A service called usbipd (display name: USBIP Device Host).
    You can check the status of this service using the Services app from Windows.
  • A command line tool usbipd.
    The location of this tool will be added to the PATH environment variable.
  • A firewall rule called usbipd to allow all local subnets to connect to the service.
    You can modify this firewall rule to fine tune access control.

Note

If you are using a third-party firewall, you may have to reconfigure it to allow incoming connections on TCP port 3240.

How to use

Share Devices

By default devices are not shared with USBIP clients. To lookup and share devices, run the following commands with administrator privileges:

usbipd --help
usbipd list
usbipd bind --busid=<BUSID>

Sharing a device is persistent; it survives reboots.

Tip

See the wiki for a list of tested devices.

Connecting Devices

Attaching devices to a client is non-persistent. You will have to re-attach after a reboot, or when the device resets or is physically unplugged/replugged.

Non-WSL 2

From another (possibly virtual) machine running Linux, use the usbip client-side tool:

usbip list --remote=<HOST>
sudo usbip attach --remote=<HOST> --busid=<BUSID>

Note

Client-side tooling exists for other operating systems such as Microsoft Windows, but not as part of this project.

WSL 2

Tip

In case you have used usbipd with WSL 2 before, the following has changed since version 4.0.0:

  • You have to share the device using usbipd bind first.
  • You no longer have to install any client-side tooling.
  • You no longer have to specify a specific distribution.
  • The syntax for the command to attach has changed slightly.

You can attach the device from within Windows with the following command, which does not require administrator privileges:

usbipd attach --wsl --busid=<BUSID>

Tip

See the wiki on how to add drivers for USB devices that are not supported by the default WSL 2 kernel.

GUI

For those who prefer a GUI over a CLI, the following is available:

How to remove

Uninstall via Add/Remove Programs or via Settings/Apps.

Alternatively, use the Windows Package Manager:

winget uninstall usbipd

usbipd-win's People

Contributors

benmcmorran avatar cho45 avatar dependabot[bot] avatar dorssel avatar github-actions[bot] avatar itsenkov avatar nelsondaniel avatar programmer86 avatar robotdad avatar shanselman avatar terlar avatar yejunhuang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

usbipd-win's Issues

Yubikey 5 and gpg works only as root

Hi,

First of all I am very fascinated of the project it awesome and gives the WSL one of the most missing capabilities. So thanks to all involved for all the work already done so far!

I was hopping to use my Yubikey 5 (which I saw is on the list of compatible devices) to gpg sign my git commits in WSL.
Attaching the Yubikey to WSL worked fine and flawless but when I run gpg --card-status in WSL I just get:

~$ gpg --card-status
gpg: selecting card failed: No such device
gpg: OpenPGP card not available: No such device

And in the log files of the scdaemon I can see the following error:

scdaemon[267] pcsc_establish_context failed: no service (0x8010001d)

However when I run run the command as root with sudo gpg --card-status I works and gpg can see my Yubikey.

So I am happy for any ideas or inputs why gpg can see the Yubkikey only when running as root but not as normal user.

Thank!

SET_CONFIGURATION: 2 fails with ArgumentOutOfRangeException

@dorssel Below is the log when I attach the realtek ethernet adapter on the dock.

PS C:\WINDOWS\system32> usbipd wsl list
BUSID  DEVICE                                                        STATE
1-3    USB Input Device                                              Not attached
1-6    Realtek DMFT - IR, USB Video Device, WinUsb Device            Not attached
1-10   Intel(R) Wireless Bluetooth(R)                                Not attached
2-2    Realtek USB GbE Family Controller                             Not attached
3-5    Realtek USB Audio                                             Not attached
7-3    USB Input Device                                              Not attached
8-1    J-Link driver, JLink CDC UART Port                            Not attached
PS C:\WINDOWS\system32> usbipd wsl attach --busid 2-2
[sudo] password for jim:
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> usbipd server Logging:LogLevel:Default=Trace
dbug: Microsoft.Extensions.Hosting.Internal.Host[1]
      Hosting starting
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\WINDOWS\system32
dbug: Microsoft.Extensions.Hosting.Internal.Host[2]
      Hosting started
dbug: UsbIpServer.Server[1000]
      new connection from 172.22.49.99
dbug: UsbIpServer.ConnectedClient[1000]
      Received opcode: OP_REQ_IMPORT
info: UsbIpServer.ConnectedClient[1]
      Client 172.22.49.99 claimed device at 2-2 (USB\VID_0BDA&PID_8153\000002000000).
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=1, flags=512, length=8, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 256 0 8
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=1, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 8, requested: 8
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=2, flags=0, length=0, ep=0
trce: UsbIpServer.AttachedClient[1001]
      0 49 40 0 0
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=2, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 0, requested: 0
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=3, flags=512, length=18, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 256 0 18
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=3, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 18, requested: 18
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=4, flags=512, length=5, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 3840 0 5
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=4, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 5, requested: 5
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=5, flags=512, length=22, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 3840 0 22
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=5, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 22, requested: 22
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=6, flags=512, length=9, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 512 0 9
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=6, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 9, requested: 9
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=7, flags=512, length=57, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 512 0 57
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=7, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 57, requested: 57
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=8, flags=512, length=9, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 513 0 9
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=8, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 9, requested: 9
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=9, flags=512, length=98, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 513 0 98
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=9, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 98, requested: 98
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=10, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 768 0 255
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=10, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 4, requested: 255
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=11, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 770 1033 255
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=11, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 40, requested: 255
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=12, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 769 1033 255
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=12, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 16, requested: 255
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=13, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[1001]
      128 6 774 1033 255
trce: UsbIpServer.AttachedClient[1001]
      Scheduled seqnum=13, pending count = 1
trce: UsbIpServer.AttachedClient[1001]
      actual: 26, requested: 255
trce: UsbIpServer.AttachedClient[1001]
      USBIP_CMD_SUBMIT, seqnum=14, flags=0, length=0, ep=0
dbug: UsbIpServer.AttachedClient[1000]
      Trapped SET_CONFIGURATION: 2
info: UsbIpServer.ConnectedClient[2]
      Client 172.22.49.99 released device at 2-2 (USB\VID_0BDA&PID_8153\000002000000).
fail: UsbIpServer.ConnectedClient[3]
      An exception occurred while communicating with the client:
      System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'configurationValue')
         at UsbIpServer.UsbConfigurationDescriptors.SetConfiguration(Byte configurationValue) in D:\a\usbipd-win\usbipd-win\UsbIpServer\UsbConfigurationDescriptors.cs:line 156
         at UsbIpServer.AttachedClient.HandleSubmitAsync(UsbIpHeaderBasic basic, UsbIpHeaderCmdSubmit submit, CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\AttachedClient.cs:line 292
         at UsbIpServer.AttachedClient.RunAsync(CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\AttachedClient.cs:line 477
         at UsbIpServer.ConnectedClient.HandleRequestImportAsync(CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ConnectedClient.cs:line 184
dbug: UsbIpServer.Server[1000]
      connection closed

Originally posted by @silabs-JimL in #82 (comment)

Unable to attach USB Device to WSL2

Hi,
I've two Windows10 21H2 systems running and on both the same issue.
It's not possible to attach an USB device into WSL2 Distro. I've tested it with Ubuntu 20.04 and Gentoo

I get following error log:
`
usbipd wsl attach --busid 2-4
Password:
usbip: error: Attach Request for 2-4 failed - Request Failed

usbipd: error: Failed to attach device with ID '2-4'.
`

The Server logs looks like following:

usbipd server Logging:LogLevel:Default=Trace dbug: Microsoft.Extensions.Hosting.Internal.Host[1] Hosting starting info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production info: Microsoft.Hosting.Lifetime[0] Content root path: C:\WINDOWS\system32 dbug: Microsoft.Extensions.Hosting.Internal.Host[2] Hosting started dbug: UsbIpServer.Server[1000] new connection from 172.30.92.220 dbug: UsbIpServer.ConnectedClient[1000] Received opcode: OP_REQ_IMPORT fail: UsbIpServer.ConnectedClient[3] An exception occurred while communicating with the client: System.IO.FileNotFoundException: Unable to find the specified file. at UsbIpServer.VBoxUsbMon.ClaimDeviceOnce(ExportedDevice device) in D:\a\usbipd-win\usbipd-win\UsbIpServer\VBoxUsbMon.cs:line 144 at UsbIpServer.VBoxUsbMon.ClaimDevice(ExportedDevice device) in D:\a\usbipd-win\usbipd-win\UsbIpServer\VBoxUsbMon.cs:line 155 at UsbIpServer.VBoxUsbMon.ClaimDevice(ExportedDevice device) in D:\a\usbipd-win\usbipd-win\UsbIpServer\VBoxUsbMon.cs:line 161 at UsbIpServer.ConnectedClient.HandleRequestImportAsync(CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ConnectedClient.cs:line 158 dbug: UsbIpServer.Server[1000] connection closed

WSL workaround for Ubuntu 21.10 and later (Impish Indri and Jammy Jellyfish)

Environment:
Microsoft Windows 11 22000.282
Ubuntu-CommPrev (updated to 21.10 and 22.04 respectively)
usbipd-win 1.1.1
WSL version 2
Kernel 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
linux-tools-5.13.0-20

Listing devices

C:\WINDOWS\system32>usbipd wsl list
BUSID DEVICE STATE
1-4 Logitech USB Input Device, USB-Eingabegerät Not attached
1-6 HP HD Camera Not attached
1-7 Intel(R) Wireless Bluetooth(R) Not attached
1-8 Synaptics FP Sensors (WBF) (PID=003f) Not attached
1-15 USB-Massenspeichergerät Not attached

Attaching USB-stick

C:\WINDOWS\system32>usbipd wsl attach --busid 1-15
[sudo] password for andi:
WARNING: usbip not found for kernel 5.10.60.1-microsoft

You may need to install the following packages for this specific kernel:
linux-tools-5.10.60.1-microsoft-standard-WSL2+
linux-cloud-tools-5.10.60.1-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-15'.

Notes:

Followed the given instructions: https://github.com/dorssel/usbipd-win/wiki/WSL-support
Linux tools v5.4.0-77 are not available in the repo, just v5.13.0-20. (https://packages.ubuntu.com/impish/linux-tools-generic)
I didn't check if this error occurs ob Ubuntu 21.04 or lower.

Fix:

Build USBIP as described and copy in addition the libusbip.so.0.
An custom kernel as well as the linux-tools package is not necessary.

USB storage not accessible

System:
Ubuntu 20.04.3 LTS (Ubuntu package from MS store)
5.10.60.1-microsoft-standard-WSL2+
linux-tools-5.4.0-77-generic.

I am trying to atach a usb flash drive with usbipd wsl attach --busid 1-4 which works without error.
I can see the device with lsusb:

Bus 002 Device 007: ID 0781:5588 SanDisk Corp. USB Extreme Pro

However, it is not visible with lsblk, sda-sdc are the virtual wsl disks:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 256G 0 disk
sdb 8:16 0 344.9M 1 disk
sdc 8:32 0 256G 0 disk /

In dmesg I can see that it is recognized but further data cannot be obtained:

[ 21.411126] scsi 1:0:0:0: Direct-Access SanDisk Extreme Pro 0 PQ: 0 ANSI: 6
[ 21.417819] sd 1:0:0:0: Attached scsi generic sg3 type 0
[ 22.717096] sd 1:0:0:0: [sdd] 250085376 512-byte logical blocks: (128 GB/119 GiB)
[ 58.314707] sd 1:0:0:0: [sdd] Write Protect is off
[ 58.320474] sd 1:0:0:0: [sdd] Mode Sense: 43 00 00 00
[ 58.404468] sd 1:0:0:0: [sdd] Asking for cache data failed
[ 58.407954] sd 1:0:0:0: [sdd] Assuming drive cache: write through
[ 58.411175] sd 1:0:0:0: [sdd] Read Capacity(10) failed: Result: hostbyte=0x07 driverbyte=0x00
[ 58.415419] sd 1:0:0:0: [sdd] Sense not available.
[ 58.417811] sd 1:0:0:0: [sdd] 0 512-byte logical blocks: (0 B/0 B)
[ 58.420867] sd 1:0:0:0: [sdd] Attached SCSI removable disk

The first three lines indicate everything works normal but after that nothing happens for a long time while errors come up later.

[ 54.092721] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
[ 55.473518] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
[ 56.853262] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
[ 58.243539] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
[ 58.385384] usb 2-1: USB disconnect, device number 2
[ 59.894291] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
[ 61.284380] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
[ 61.321844] usb usb2-port1: attempt power cycle
[ 62.774217] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
[ 64.164460] usb usb2-port1: Cannot enable. Maybe the USB cable is bad?
[ 64.202258] usb usb2-port1: unable to enumerate USB device

I tried with two different flash drives but the result is the same.
There's no cable involved as well as no external power supply possible, both by design.

Attached is the full dmesg log with USBIP dump messages:
dmesg.txt

Maybe someone has an idea? Thank you very much!

Unable to list usb devices to attach to WSL

Hi,

I'm running the Windows 11 WSL2 preview version (kernel 5.10.60.1-microsoft-standard-WSL2) and usbipd-win 1.1.1.

I've followed this guide and am unable to run usbipd wsl list.

I get the following error:

Unhandled exception. System.AggregateException: One or more errors occurred. (An item with the same key has already been added. Key: [1, UsbIpServer.UsbConfigurationDescriptors+UsbConfiguration])
 ---> System.ArgumentException: An item with the same key has already been added. Key: [1, UsbIpServer.UsbConfigurationDescriptors+UsbConfiguration]
   at System.Collections.Generic.TreeSet`1.AddIfNotPresent(T item)
   at System.Collections.Generic.SortedSet`1.Add(T item)
   at System.Collections.Generic.SortedDictionary`2.Add(TKey key, TValue value)
   at UsbIpServer.UsbConfigurationDescriptors.AddDescriptor(ReadOnlySpan`1 descriptor) in D:\a\usbipd-win\usbipd-win\UsbIpServer\UsbConfigurationDescriptors.cs:line 96
   at UsbIpServer.ExportedDevice.GetConfigurationDescriptor(DeviceFile hub, UInt16 connectionIndex, Byte numConfigurations)
   at UsbIpServer.ExportedDevice.GetDevice(SafeDeviceInfoSetHandle deviceInfoSet, SP_DEVINFO_DATA devInfoData, CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ExportedDevice.cs:line 202
   at UsbIpServer.ExportedDevice.GetAll(CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ExportedDevice.cs:line 239
   at UsbIpServer.Program.<>c.<<Main>b__19_18>d.MoveNext() in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 387
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass79_0.<OnExecute>b__0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at UsbIpServer.Program.Main(String[] args) in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 555

Any thoughts?

Thanks

feature request - whitelist of devices to auto-connect?

Many usb devices will start-up in "bootloader" mode for 1-5 seconds as they first get power applied, and afterwards will execute a 'main firmware' if available. If the main firmware is corrupted as part of a partial firmware update, then the bootloader can be used to re-flash without bricking the device. Bootloaders like this often have their own 'brief' usb identifiers etc. The only way to pass-through these devices to wsl for the few seconds of their existance would be to have a white-list of 'recently seen' devices that should be automatically connected to wsl on detection, and disconnected after .

`usbipd wsl attach` works only with the Debian implementation of `hostname`

Whe the usbipd wsl attach command is used, usbipd tries to run hostname --all-ip-addresses in the WSL instance to determine the IP address used by that instance:

var ipResult = await ProcessUtils.RunCapturedProcessAsync(WslPath, new[] { "--distribution", name, "--", "hostname", "--all-ip-addresses" }, Encoding.UTF8, cancellationToken);

However, apparently there are multiple different implementations of the hostname utility; the Debian one (which is present in Debian and Ubuntu distros) supports the --all-ip-addresses option, but the GNU inetutils implementation (e.g., inetutils 2.2-1 which is used by Arch Linux) does not, therefore usbipd wsl attach fails when the Arch Linux instance is targeted:

PS C:\WINDOWS\system32> usbipd wsl attach --busid 4-1 -d Arch
usbipd: error: The specified WSL distribution cannot be reached via the WSL virtual switch; try restarting the WSL distribution.

An inconvenient workaround is manually running usbipd bind on the Windows side and then usbip attach on the Linux side.

I'm not sure what would be the best way to get the list of IP addresses from the WSL instance. One possible option is ip -j address list, but the corresponding iproute2 package might not be installed too, and I'm not sure how common is the -j option support (although parsing the ip -o address list output could also be an option — -o should be supported by all existing versions of iproute2).

missing udev rules file

You say:

As a common example for using embedded devices with openocd copy share/openocd/contrib60-openocd.rules to the /etc/udev/rules.d folder.

but no such file exists in the repo (nor even the "share" folder)

USB3 Vision Camera is not working

Hello,

Thanks for the usbipd-win, it helps a lot with wsl2 , however I have some problem with USB3.

I have successfully used usbipd to connect multiple USB2 boards to my wsl2. However I am facing difficulty with a Basler USB3 Vision camera.

here is windows powershel output:

>usbipd list
Present:
BUSID  DEVICE                                                           STATE
1-2    Billboard Device                                              Not shared
1-3    USB Input Device                                              Not shared
1-4    USB Input Device                                              Not shared
1-5    USB Input Device                                              Not shared
1-8    USB Video Device                                              Not shared
1-10   Synaptics UWP WBDI                                            Not shared
1-14   Intel(R) Wireless Bluetooth(R)                                Not shared
1-17   Basler dart USB3 Vision Camera                                Attached

wsl output:

$ lsusb
Bus 002 Device 002: ID 2676:ba03 Basler AG daA1920-30uc
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ sudo usbip list -r 192.168.1.48
Exportable USB devices
======================
 - 192.168.1.48
       1-17: Basler AG : unknown product (2676:ba03)
           : USB\VID_2676&PID_BA03\23309140
           : Miscellaneous Device / ? / Interface Association (ef/02/01)
           :  0 - Miscellaneous Device / USB3 Vision / unknown protocol (ef/05/00)
           :  1 - Miscellaneous Device / USB3 Vision / unknown protocol (ef/05/02)
$ arv-tool-0.6 -d all:3
Failed to open USB device
Found 0 USB3Vision device (among 3 USB devices)
[GvDiscoverSocket::new] Add interface 127.0.0.1
[GvDiscoverSocket::new] Add interface 192.168.1.5
No device found

I already installed the library for Basler Camera, I used the same one on my ubuntu laptop and it is working, I doubt it would be Basler Camera driver.

Am I missing something here? Is there any extra steps to connect USB3 devices? Is USB3 supported at all? :-D

Thank you for your help in advance.

Workaround for WSL `usbip` client on Debian

@Eric-N-Be Your problem is different. It says:

sudo: usbip: command not found

This means that the USBIP client on the Linux end is not available. Please follow the instructions on how to setup the client side: https://github.com/dorssel/usbipd-win/wiki/WSL-support

thanks for your help ..

I have a debian distro, then a need to change a little your procedure.
i don't find any linux-tools-5.4.0-77-generic on debian 11 then i just install :

  • sudo apt-get update
  • sudo apt-get install usbutils (for lsusb)
  • sudo apt-get install hwdata
  • sudo apt-get install usbip

i don't have at this time change the /etc/sudoers

At this time it's working for a simple mass storage ... i will test later with "USB Serial Converter"
:~# lsusb
Bus 002 Device 002: ID 0951:1666 Kingston Technology DataTraveler 100 G3/G4/SE9 G2/50

edit : Working for me, thanks

Originally posted by @Eric-N-Be in #63 (comment)

usbipd wsl yubikey can't input to terminal

I been trying to use the usbipd which a great tool to bridge between wsl and my yubikey. I found an issue, is that I don't know where the usbipd yubikey give the input when I touch the yubikey for the access token. Thank you in advance.

IP address issue

Hello guys when i use usbipd i got an error which says this
C:\Windows\system32>usbipd wsl attach --busid 5-2
usbipd: error: The local IP address for the WSL virtual switch could not be found. Ensure WSL is running.

does anyone know how to fix that ??? any support will be appreciated

Segger J-Link issue

I'm trying to share my Segger J-Link over USB to my WSL2 instance, but no success right now. The device appears in lsusb list. JLinkGDBServerCL just replies that the connection to J-Link failed then it asks me Connected correctly?.

I'm trying to debug on-chip application from WSL2 using Visual Studio Code.

Environment settings:
Host: Windows 10 Pro 21H1
WSL2 instance: Ubuntu 20.04 LST (5.10.60.1-microsoft-standard-WSL2)
J-link version 7.58a installed in WSL2 instance above.
arm toolchain: arm-none-eabi-8-2018-q4-major

VSCode launch.json configuration:

"name": "DVC TopRow Emerald Inventory",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceFolder}",
"armToolchainPath": "/opt/gcc-arm-none-eabi/bin",
"executable": "path/to/elf",
"serverpath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe",
"servertype": "jlink",
"device": "MK10DX256xxx7",
"interface": "jtag",
"serialNumber": "proper serial number",
"runToMain": true,
"svdFile": "path/to/svd"

Contribution Request: Isochronous Support and UI Improvements

Hi, I’m an intern at Microsoft and I am interested in contributing support for isochronous transfer and some UI as part of my summer project. Would such a contribution be welcomed? My team would like to discuss my project with you so you have context on how we intend to use your project. Can you please contact me at [email protected]?

usbipd: error: Do not recognise my running WSL WM

When following this instructions: https://devblogs.microsoft.com/commandline/connecting-usb-devices-to-wsl/
I can not get the usbipd to recognise the WSL2 VM. Even though I have a WSL WC open / running.
See my Windows Terminal [tab1] below.

Windows Terminal [tab1]/ PowerShell (with Administrator rights)

C:\...> usbipd wsl attach --busid 1-1
    usbipd: error: Windows Subsystem for Linux version 2 is not available. 
C:\...> 
C:\...> usbipd --version
    usbipd-win
    1.1.1+17.Branch.master.Sha.b4799323ae62a2c58c736e2c16c0cc57e08cc08f
C:\...> 

Please, I need some advise - On what side should I start looking?

  1. Windows 11 side?
    • Windows version 21H2 / 22000.282 ?
    • WSL version 0.48.2.0 ?

  2. WSL 🐧 "Ubuntu-20.04" side?
    • Kernelversion: 5.10.60.1 ?
    • /usr/lib/linux-tools/5.4.0-77-generic ?

  3. ...or maybe due to Swedish settings in Win11.
    • Like decimal delimiter = "," (not "." as expected)
    • ...or our strange characters "ÅÄÖåäö" here and there 🤣

Some background/additional information.

Windows Terminal [tab2] / WSL Ubuntu-20.04

~$ uname -a
Linux Yoda 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
~$ 

Added Defaults secure_path="/usr/lib/linux-tools/5.4.0-77-generic:/usr/local/sbin:..." to /etc/sudoers

Windows Terminal[tab3] / PowerShell

C:\...> wsl --version --verbose  
WSL-version: 0.48.2.0 
Kernelversion: 5.10.60.1 
WSLg-version: 1.0.29 
Windows-version: 10.0.22000.282 
C:\...> 
C:\...> usbipd list
Present:
BUSID  DEVICE                                                        STATE
1-1    RP2 Boot, USB-masslagringsenhet                               Not shared  <= My target USB-device
1-4    Synaptics UWP WBDI SGX                                        Not shared
1-7    Integrated Camera                                             Not shared
1-8    Okänd USB-enhet (begäran om enhetsbeskrivning misslyckades)   Not shared
1-10   Intel(R) Wireless Bluetooth(R)                                Not shared
1-13   Okänd USB-enhet (adress kunde inte anges)                     Not shared
Persisted:
GUID                                    BUSID  DEVICE
C:\...> 

Information from Win11 Settings/About

Utgåva	        Windows 11 Pro   ⚠️  Running Win11 with Swedish settings!!
Version	        21H2
Installerad	‎2021-‎08-‎11
OS-version	22000.282
Gränssnitt	Gränssnittspaket för Windows-funktioner 1000.22000.318.0

usb device crashes when accessed from WSL

Hi! First of all, awesome work! Been looking for a USB port from WSL2 in windows for quite a while now :) And now I saw microsoft' dev post i was more than happy to give it a go.

So let me explain my situation. I want to link this radio device, the crazyradio PA from bitcraze to control and flash a tiny drone called the crazyflie. The PA is installed by zadig with libusb.

Unfortunately, if I try to access it through python on the WSL2 side, the usb device crashes, eventhough I can access it from windows with no problem.

After installing everything according to the wiki also see it in the list of usbipd on the windows side and once I attach it I see:
Windows: usbipd list

BUSID  DEVICE                                                        STATE
1-1    Crazyradio PA USB Dongle                                      Attached
1-2    Jabra Link 370 (Interface 0), USB Input Device                Not shared
1-6    Synaptics WBDI                                                Not shared
1-7    Intel(R) Wireless Bluetooth(R)                                Not shared
1-8    Integrated Camera                                             Not shared
1-9    Alcor Micro USB Smart Card Reader                             Not shared

lbusb on ubuntu:

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 038: ID 1915:7777 Nordic Semiconductor ASA Crazyradio PA USB Dongle
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

usbip port on ubuntu:

Imported USB devices
====================
libusbip: error: fopen
libusbip: error: read_record
Port 00: <Port in Use> at Full Speed(12Mbps)
       Nordic Semiconductor ASA : unknown product (1915:7777)
       1-1 -> unknown host, remote port and remote busid
           -> remote bus/dev 001/001

After trying to access it through pyusb, the following happens:

kim@DESKTOP~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
kim@DESKTOP:~$ usbip port --trace
usbip: error: open vhci_driver
usbip: error: list imported device

So there is something going wrong still! Maybe the libusbip error for fopen and read_record has something to do with it?

Here some more info about my system:

Host:
Windows 10 Pro
Version 10.0.19042 Build 19042

WSL2:
Ubuntu 20.04
Kernel version 5.10.60.1
Udev rules. SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="7777", MODE="0664", GROUP="plugdev"

Unhandled exception - DEVPKEY_Device_Address does not match DEVPKEY_Device_LocationInfo

Can't see list of USB devices. I'm using Windows 11 insider preview

C:\Windows\System32>usbipd wsl list
Unhandled exception. System.AggregateException: One or more errors occurred. (DEVPKEY_Device_Address (3) does not match DEVPKEY_Device_LocationInfo (2))
---> System.NotSupportedException: DEVPKEY_Device_Address (3) does not match DEVPKEY_Device_LocationInfo (2)
at UsbIpServer.ExportedDevice.GetDevice(SafeDeviceInfoSetHandle deviceInfoSet, SP_DEVINFO_DATA devInfoData, CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ExportedDevice.cs:line 158
at UsbIpServer.ExportedDevice.GetAll(CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ExportedDevice.cs:line 239
at UsbIpServer.Program.<>c.<

b__19_18>d.MoveNext() in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 387
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass79_0.b__0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at UsbIpServer.Program.Main(String[] args) in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 555

usbip win does not attach to devices listed

usbip win from cezanne 0.3.5 (latest) does not attach to a shared device.

This is due to the buffer not being padded with 0.
The solution is to find the first 0 and get the substring to that point.

git diff of my solution follows

diff --git a/UsbIpServer/ConnectedClient.cs b/UsbIpServer/ConnectedClient.cs
index 6a9fbd4..0878ed5 100644
--- a/UsbIpServer/ConnectedClient.cs
+++ b/UsbIpServer/ConnectedClient.cs
@@ -102,7 +102,13 @@ namespace UsbIpServer
             {
                 var buf = new byte[SYSFS_BUS_ID_SIZE];
                 await Stream.ReadExactlyAsync(buf, cancellationToken);
-                if (!BusId.TryParse(Encoding.UTF8.GetString(buf).TrimEnd('\0'), out busId))
+                var s = Encoding.UTF8.GetString(buf);
+                var end = s.IndexOf("\0");
+                if (end >= 0)
+                {
+                    s = s.Substring(0, end);
+                }
+                if (!BusId.TryParse(s, out busId))
                 {
                     await SendOpCodeAsync(OpCode.OP_REP_IMPORT, Status.ST_NODEV);
                     return;

Tested working.

Do I need to install these dependecies?

solved my wsl2 network issues (aka uninstall hyper-v, netst reset, etc - there is a bug MS still have to find..)

Got this far do i need to install all of these?

alexb@STUDY:/mnt/c/WINDOWS/system32$ usbipd wsl list
WARNING: usbipd not found for kernel 5.10.60.1-microsoft

You may need to install the following packages for this specific kernel:
linux-tools-5.10.60.1-microsoft-standard-WSL2
linux-cloud-tools-5.10.60.1-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

Does usbipd-win work with WSL2 preview from store?

I don't have WSL installed via add/remove features.
It is installed via the windows store (preview verison of wsl2)

Windows sees WSL as installed

STUDY\C:\Users\alex> wsl -l
Windows Subsystem for Linux Distributions:
Ubuntu (Default)

but usbipd doesn't

STUDY\C:\Users\alex> usbipd wsl attach --busid=6-2
usbipd: error: Windows Subsystem for Linux version 2 is not available. See https://aka.ms/installwsl.

(note if it matters wsl was removed from add/remove features AFTER usbipd was installed....)

[WSL2] Null bytes in virtual com port with a stlinkv2.1

Hi

I am running into a weird issue while using the stlink on my STM8 Nucleo-32 board. I have updated the stlink firmware to the latest available (V2J27M7) but the issue persists.

If I open the serial port on a windows application, everything works expected. After using usbipd to attach to wsl, I only read 0x0 from the serial port after an initial burst of data.

programming features of the stlink seem to be working as expected (using stm8flash). I have not used the mass storage device.

$ sudo tio /dev/ttyACM0
[tio 21:11:05] tio v1.32
[tio 21:11:05] Press ctrl-t q to quit
[tio 21:11:05] Connected
lloxxx
      Helloxxx
              Helloxxx
                      Helloxxx
                              Helloxxx
                                      Helloxxx
                                              Helloxxx
                                                      Helxx
                                                           Helloxxx
                                                                   Helloxxx
                                                                           Helloxxx
                                                                                   Heelloxxx
                                                                                            Helloxxx
                                                                                                    Helloxxx
                                                                                                            Helloxloxxx
                                                                                                                       Helloxxx
       Helloxxx
               Helloxxx
                       Helloxxx
                               Helloxxx
                                       Helloxxx
                                               Helloxxx
                                                       Helloxxx
                                                               Hello
[tio 21:11:08] Switched to hexadecimal mode
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[tio 21:11:09] Switched to normal mode

[tio 21:11:11] Disconnected

I don't see any exceptions in the usbipd log, and I'm not sure if it is a usbipd problem but I was hoping you could point me in the right direction
usbipd.log

Device description empty

Looks good :)

WARNING: bConfigurationValue 1 is duplicated. ignored.
Present:
BUSID  DEVICE                                                        STATE
1-5    Intel(R) Wireless Bluetooth(R)                                Not shared
1-6    Integrated Camera                                             Not shared
1-8    Synaptics WBDI                                                Not shared
2-2    DisplayLink USB Audio Adapter, DisplayLink USB Device         Not shared
5-4    Remote NDIS Compatible Device                                 Not shared
7-1                                                                  Not shared
7-2    USB Input Device                                              Not shared
7-3    STMicroelectronics STLink Virtual COM Port, STMicroelectr...  Not shared
8-1    Billboard Device, USB Input Device                            Not shared
8-4    USB Input Device                                              Not shared

Persisted:
GUID                                    BUSID  DEVICE

Originally posted by @ebinans in #54 (comment)

Failed to start RegistryWatcher, again, maybe #80

Hi,

This is, potentially, the same issue as #80 Failed to start RegistryWatcher
There, it is explained as registry problem with 32/64 bit ...
But I am using totally fresh Win11 notebook, latest official version of usbipd ...., no hacking with registry, ...

Same story as then: when I try to access usbipd server from WSL2, I receive error:

drazen@MACHINE:/mnt/c/Users/user$ sudo usbip list --remote=172.31.32.1
usbip: error: Exported Device List Request failed - Unknown Op Common Status
usbip: error: failed to get device list from 172.31.32.1

... and on host is the same RegistryWatcher error:

dbug: UsbIpServer.Server[1000]
new connection from 172.31.44.56
fail: UsbIpServer.RegistryWatcher[4]
An internal error occurred: Failed to start RegistryWatcher
System.Management.ManagementException: Not found
at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
at System.Management.ManagementEventWatcher.Start()
at UsbIpServer.RegistryWatcher..ctor(ILogger`1 logger) in D:\a\usbipd-win\usbipd-win\UsbIpServer\RegistryWatcher.cs:line 36
dbug: UsbIpServer.Server[1000]
connection closed

The same problem is when I try to attach some device from host console:

PS C:\WINDOWS\system32> usbipd wsl list
BUSID DEVICE STATE
2-3 Goodix fingerprint Not attached
2-4 USB Mass Storage Device Not attached
2-6 USB Video Device Not attached
4-4 Realtek USB GbE Family Controller Not attached
9-5 USB Input Device Not attached
10-2 USB Input Device Not attached
10-3 USB Input Device Not attached
10-5 USB Input Device Not attached
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> usbipd wsl attach --busid 2-4
[sudo] password for drazen:
usbip: error: Attach Request for 2-4 failed - Request Completed Successfully

usbipd: error: Failed to attach device with ID '2-4'.

On system I see a lot of WmiPrvSE.exe processes:

image

I didn't understand what was the solution:
a) to try to stop one of these processes, or all of these processes that are 32 bit, ... ?
b) to use your latest version of usbipd that is handling that (I think that I am using such version) ?
c) do something in registry ?
d) something else ?

Thanks in advance for help.

BR
D.

Sharing a device between host and wsl

Hi!
The documentation mention "sharing" of devices, but when I attach a device to WSL2, its no longer available on the host Windows 11.
Is it possible to have a device available on the host as well as shared to WSL?

Regards,
Johan

Mass storage devices not safely closed on Windows

Using usbipd wsl attach produces an error upon mounting in Linux:

The disk contains an unclean file system (0, 1).
The file system wasn't safely closed on Windows. Fixing.

It seems the hardware is not safely removed under Windows but virtually just "plugged out".
It may be a source for file system errors.

Tested on:
Microsoft Windows [Version 10.0.22000.346]
WSL Ubuntu 5.10.74.3-microsoft-standard-WSL2+

Unable to attach an STM Bootloader using 1.2.0

I upgraded to usbipd 1.2 (Thanks!) and I'm seeing this:

usbipd wsl list
BUSID  DEVICE                                                        STATE
1-13   Realtek Bluetooth Adapter                                     Not attached
1-14   USB Input Device                                              Not attached
1-20   USB Audio Device, USB Input Device, USB Video Device          Not attached
9-2    Logitech BRIO, USB Audio Device                               Not attached
9-3    STM32  BOOTLOADER                                             Not attached
10-2   American Power Conversion USB UPS                             Not attached
11-3   USB Mass Storage Device                                       Not attached
13-2   USB Input Device                                              Not attached
13-3   USB Input Device                                              Not attached
15-1   Logitech USB Input Device, Logitech Unifying USB receiver...  Not attached
15-2   USB Audio Device, USB Input Device                            Not attached
15-3   USB Input Device                                              Not attached
16-4   USB Input Device                                              Not attached
>usbipd wsl attach --busid 9-3
[sudo] password for scott:
usbip: error: Attach Request for 9-3 failed - Request Failed
usbipd: error: Failed to attach device with ID '9-3'.

Logs are

dbug: Microsoft.Extensions.Hosting.Internal.Host[1]
      Hosting starting
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\github\usbipd-win\UsbIpServer\bin\x64\Debug
dbug: Microsoft.Extensions.Hosting.Internal.Host[2]
      Hosting started
dbug: UsbIpServer.Server[1000]
      new connection from 172.19.29.168
dbug: UsbIpServer.ConnectedClient[1000]
      Received opcode: OP_REQ_IMPORT
fail: UsbIpServer.ConnectedClient[3]
      An exception occurred while communicating with the client:
      System.IO.FileNotFoundException: Unable to find the specified file.
         at UsbIpServer.VBoxUsbMon.ClaimDeviceOnce(ExportedDevice device) in D:\a\usbipd-win\usbipd-win\UsbIpServer\VBoxUsbMon.cs:line 144
         at UsbIpServer.VBoxUsbMon.ClaimDevice(ExportedDevice device) in D:\a\usbipd-win\usbipd-win\UsbIpServer\VBoxUsbMon.cs:line 155
         at UsbIpServer.VBoxUsbMon.ClaimDevice(ExportedDevice device) in D:\a\usbipd-win\usbipd-win\UsbIpServer\VBoxUsbMon.cs:line 161
         at UsbIpServer.ConnectedClient.HandleRequestImportAsync(CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ConnectedClient.cs:line 158
dbug: UsbIpServer.Server[1000]
      connection closed

pyocd probe Access denied, WSL2 udev permissions issue

I'm trying to run pyocd with DAPLink on WSL2 (Ubuntu 20.04). I'm able to attach and identify the DAPLink but there appears to be a udev issue. When I try to list the probes I get a permission error:

0000653:WARNING:pyusb_backend:[Errno 13] Access denied (insufficient permissions) while trying to interrogate a USB device (VID=0d28 PID=0204). This can probably be remedied with a udev rule. See <https://github.com/pyocd/pyOCD/tree/master/udev> for help.
0000653:WARNING:pyusb_v2_backend:[Errno 13] Access denied (insufficient permissions) while trying to interrogate a USB device (VID=0d28 PID=0204). This can probably be remedied with a udev rule. See <https://github.com/pyocd/pyOCD/tree/master/udev> for help.
No available debug probes are connected

I've added the 50-cmsis-dap.rules to /etc/udev/rules.d as specified in pyocd https://github.com/pyocd/pyOCD/tree/main/udev .
After adding the rules, I restarted WSL by running wsl --shutdown from command prompt but the issue persists. I am able to see the probe using sudo.

Trace Logs:

dbug: Microsoft.Extensions.Hosting.Internal.Host[1]
      Hosting starting
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Users\chadcoons
dbug: Microsoft.Extensions.Hosting.Internal.Host[2]
      Hosting started
dbug: UsbIpServer.Server[0]
      new connection from 172.19.158.27
dbug: UsbIpServer.ConnectedClient[0]
      Received opcode: OP_REQ_IMPORT
info: UsbIpServer.ConnectedClient[1]
      Client 172.19.158.27 claimed device at 2-1 (USB\VID_0D28&PID_0204\000000800E7F79D100000000000000000000000097969902).
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=81, flags=512, length=64, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 256 0 64
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=81, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 18, requested: 64
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=82, flags=512, length=18, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 256 0 18
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=82, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 18, requested: 18
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=83, flags=512, length=5, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 3840 0 5
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=83, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 5, requested: 5
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=84, flags=512, length=57, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 3840 0 57
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=84, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 57, requested: 57
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=85, flags=512, length=10, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 1536 0 10
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=85, pending count = 1
dbug: UsbIpServer.AttachedClient[0]
      USBSUP_XFER_STALL -> EPIPE -> 0
trce: UsbIpServer.AttachedClient[0]
      actual: 0, requested: 10
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=86, flags=512, length=10, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 1536 0 10
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=86, pending count = 1
dbug: UsbIpServer.AttachedClient[0]
      USBSUP_XFER_STALL -> EPIPE -> 0
trce: UsbIpServer.AttachedClient[0]
      actual: 0, requested: 10
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=87, flags=512, length=10, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 1536 0 10
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=87, pending count = 1
dbug: UsbIpServer.AttachedClient[0]
      USBSUP_XFER_STALL -> EPIPE -> 0
trce: UsbIpServer.AttachedClient[0]
      actual: 0, requested: 10
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=88, flags=512, length=9, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 512 0 9
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=88, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 9, requested: 9
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=89, flags=512, length=125, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 512 0 125
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=89, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 125, requested: 125
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=90, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 768 0 255
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=90, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 4, requested: 255
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=91, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 770 1033 255
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=91, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 36, requested: 255
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=92, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 769 1033 255
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=92, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 8, requested: 255
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=93, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 771 1033 255
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=93, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 98, requested: 255
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=94, flags=0, length=0, ep=0
dbug: UsbIpServer.AttachedClient[0]
      Trapped SET_CONFIGURATION: 1
trce: UsbIpServer.AttachedClient[0]
      actual: 0, requested: 0
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=95, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 772 1033 255
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=95, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 34, requested: 255
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=96, flags=0, length=7, ep=0
trce: UsbIpServer.AttachedClient[0]
      33 32 0 0 7
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=96, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 7, requested: 7
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=97, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 773 1033 255
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=97, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 34, requested: 255
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=98, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 774 1033 255
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=98, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 26, requested: 255
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=99, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 775 1033 255
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=99, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 36, requested: 255
trce: UsbIpServer.AttachedClient[0]
      USBIP_CMD_SUBMIT, seqnum=100, flags=512, length=255, ep=0
trce: UsbIpServer.AttachedClient[0]
      128 6 777 1033 255
trce: UsbIpServer.AttachedClient[0]
      Scheduled seqnum=100, pending count = 1
trce: UsbIpServer.AttachedClient[0]
      actual: 26, requested: 255
info: UsbIpServer.ConnectedClient[2]
      Client 172.19.158.27 released device at 2-1 (USB\VID_0D28&PID_0204\000000800E7F79D100000000000000000000000097969902). 

At this point I run pyocd list --probes on WSL2 terminal, no new trace logs write out

Signing cert expired?

Has the driver signing cert expired? I'm unable to install and per these verbose logs this smells like a cert issue.

DIFXAPP: ERROR: encountered while installing driver package 'C:\Program Files\usbipd-win\Drivers\VBoxUSB\VBoxUSB.inf' DIFXAPP: ERROR: InstallDriverPackages failed with error 0xE0000247 DIFXAPP: RETURN: InstallDriverPackages() 3758096967 (0xE0000247) CustomAction MsiInstallDrivers returned actual error code 1603

Workaround: attach failed with System.IO.FileNotFoundException

When I try to connect the device, it says the following:

PS C:\windows\system32> usbipd wsl attach --busid=6-1 [sudo] password for calipso: usbip: error: Attach Request for 6-1 failed - Request Failed usbipd: error: Failed to attach device with ID '6-1'. PS C:\windows\system32>
image

With extended error output the messages are as follows:

dbug: Microsoft.Extensions.Hosting.Internal.Host[1] Hosting starting info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production info: Microsoft.Hosting.Lifetime[0] Content root path: C:\windows\system32 dbug: Microsoft.Extensions.Hosting.Internal.Host[2] Hosting started dbug: UsbIpServer.Server[0] new connection from 172.21.14.67 dbug: UsbIpServer.ConnectedClient[0] Received opcode: OP_REQ_IMPORT fail: UsbIpServer.ConnectedClient[3] An exception occurred while communicating with the client: System.IO.FileNotFoundException: Unable to find the specified file. at UsbIpServer.VBoxUsbMon.ClaimDeviceOnce(ExportedDevice device) in D:\a\usbipd-win\usbipd-win\UsbIpServer\VBoxUsbMon.cs:line 144 at UsbIpServer.VBoxUsbMon.ClaimDevice(ExportedDevice device) in D:\a\usbipd-win\usbipd-win\UsbIpServer\VBoxUsbMon.cs:line 155 at UsbIpServer.VBoxUsbMon.ClaimDevice(ExportedDevice device) in D:\a\usbipd-win\usbipd-win\UsbIpServer\VBoxUsbMon.cs:line 161 at UsbIpServer.ConnectedClient.HandleRequestImportAsync(CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ConnectedClient.cs:line 158 dbug: UsbIpServer.Server[0] connection closed

image

Any ideas?

Missing folder for MSI build

Error when loading the solution (usbipd-win.sln) in VS 2019--
D:\Projects\usbipd-win\Installer\Installer.wixproj : error :
The imported project "D:\Projects\usbipd-win\Installer\gitversiontask\5.5.0\build\GitVersionTask.props" was not found.
Confirm that the expression in the Import declaration "gitversiontask\5.5.0\build\GitVersionTask.props" is correct, and that the file exists on disk.

Can't attach any devices to WSL - "Request Completed Successfully" & "Unknown Op Common Status"

The Problem

$ usbipd wsl list
BUSID  DEVICE                                                        STATE
1-5    USB Giriş Aygıtı, WinUsb Aygıtı                               Not attached
2-2    Logitech USB Input Device, USB Giriş Aygıtı                   Not attached
2-4    USB Giriş Aygıtı, WinUsb Aygıtı                               Not attached
6-2    USB Giriş Aygıtı                                              Not attached
6-3    USB Giriş Aygıtı, USB Ses Aygıtı                              Not attached
7-1    HD Pro Webcam C920, USB Ses Aygıtı                            Not attached
7-2    Microsoft Usbccid Akıllı Kart Okuyucusu (WUDF), USB Giriş...  Not attached
7-3    USB Giriş Aygıtı                                              Not attached
8-4    Billboard Cihazı                                              Not attached


$ usbipd wsl attach --busid 2-2
[sudo] password for yusuf:
usbip: error: Attach Request for 2-2 failed - Request Completed Successfully

usbipd: error: Failed to attach device with ID '2-2'.


$ usbipd wsl attach --busid 7-2
[sudo] password for yusuf:
usbip: error: Attach Request for 7-2 failed - Unknown Op Common Status

usbipd: error: Failed to attach device with ID '7-2'.


$ usbipd wsl attach --busid 2-2
[sudo] password for yusuf:
usbip: error: Attach Request for 2-2 failed - Request Completed Successfully

usbipd: error: Failed to attach device with ID '2-2'.


$ usbipd wsl attach --busid 7-2
[sudo] password for yusuf:
usbip: error: Attach Request for 7-2 failed - Request Completed Successfully

usbipd: error: Failed to attach device with ID '7-2'.

I can't attach any devices to WSL. I am getting Unknown Op Common Status and Request Completed Successfully(doesn't sound like an error but 🤷) errors. I couldn't figure out why a certain error is thrown under which circumstances. It seems random. For consecutive 13 tries, I got 4 consecutive Request Completed Successfully errors, then 4 consecutive Unknown Op Common Status errors, then 5 more Request Completed Successfully errors.

I tried attaching different devices. I tried attaching a certain device with and without a USB Hub, on different port locations and versions(USB 2, USB 3, etc.). I tried using various releases including 1.1.2 and some still unreleased draft versions such as 1.1.2+27.Branch.master.Sha.e77e634bea91aba546648ab32ae1ce59df831809. But, no luck 😞
When executing the attach command I don't hear any device disconnect/connect beep sounds, and the device doesn't disappear briefly on the device manager.
(I saw some of these troubleshooting steps on #63 (comment))

Device Information

Bus ID Friendly Name Hardware ID
2-2 Logitech Unifying Receiver USB\VID_046D&PID_C52B&REV_2411&MI_00
7-2 Yubico Yubikey 5 NFC USB\VID_1050&PID_0407&REV_0543&MI_02

System Information

Microsoft Windows 11 Education 21H2 (Build 22000.318)
Ubuntu 20.04.3 LTS on Windows 10 x86_64 (Kernel 5.10.60.1-microsoft-standard-WSL2)
Windows Subsystem for Linux Preview from Microsoft Store

Windows 10 freezes when usbip-win is used with Hyper-V Linux Fedora 34

Discussed in https://github.com/dorssel/usbipd-win/discussions/124

Originally posted by JohnRoden78 November 30, 2021
First of all, thank you for such a useful project! Unfortunately, I've run into a serious problem when trying to use it. I know that this usage is slightly outside your target (i.e Windows 11 / WSL2) but the information might be useful.

I am attempting to access a USB device (Aeotec Z-Stick) in Linux Fedora 34 running in a virtual machine hosted on Hyper-V running under Windows 10 Pro. I use usbipd.exe on Windows 10 to bind the USB port and then, on the Fedora 34 VM, use usbip to list and then attach the port. As soon as the attach command is issued, the Windows 10 machine freezes with a buzzing sound coming from the HDMI audio. The Fedora 34 VM is also frozen and cannot be accessed via SSH or VNC from another machine. A forced power off and reboot is required to restart the system.

Strangely, before the recent windows update (Feature Update to Windows 10, 21H2), there was no problem but it did not go away when I reverted the update.

I cannot work out yet if the freeze is due to a crash in the Fedora VM or in Windows 10 but I will try to find another separate Unix machine to test with the usbip protocol.

I would appreciate any insights you could give me.

-- Windows 10 CMD Window (Admin) ---------------------------------------------
C:\WINDOWS\system32>"\Program Files\usbipd-win\usbipd.exe" -v
usbipd-win
1.2.0+51.Branch.master.Sha.a1d6f0c6ff27baae9aab9f279a61d196dad3d0b9

C:\WINDOWS\system32>"\Program Files\usbipd-win\usbipd.exe" list
Present:
BUSID DEVICE STATE
2-1 USB Mass Storage Device Shared
2-5 USB Serial Device Shared
2-8 Intel(R) Wireless Bluetooth(R) Not shared
2-9 USB Mass Storage Device Not shared
4-1 HD Pro Webcam C920, USB Audio Device Not shared
4-3 USB Input Device Not shared
4-4 USB Input Device Not shared

Persisted:
GUID BUSID DEVICE
{1c8f598a-1874-47e3-aa6b-a2e3d3e9c191} 1-5 USB Serial Device

-- VM Linux Fedora 34 (root) ----------------------------------------------------------

$ usbip version
usbip (usbip-utils 2.0)

$ usbip list -r 192.168.0.82
Exportable USB devices
======================

  • 192.168.0.82
    2-1: Alcor Micro Corp. : Multi Flash Reader (058f:6366)
    : USB\VID_058F&PID_6366\058F63666485
    : (Defined at Interface level) (00/00/00)
    : 0 - Mass Storage / SCSI / Bulk-Only (08/06/50)
    2-5: Sigma Designs, Inc. : Aeotec Z-Stick Gen5 (ZW090) - UZB (0658:0200)
    : USB\VID_0658&PID_0200\5&437BA90&0&5
    : Communications / unknown subclass / unknown protocol (02/00/00)
    : 0 - Communications / Abstract (modem) / AT-commands (v.25ter) (02/02/01)
    : 1 - CDC Data / Unused / unknown protocol (0a/00/00)

$ usbip attach -r 192.168.0.82 -b 2-5 #### causes Windows 10 freeze ####

-- Windows 10 System Details: (from setup > about ) --------------------------

Processor Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz 3.40 GHz
Installed RAM 16.0 GB (15.9 GB usable)
System type 64-bit operating system, x64-based processor

Edition Windows 10 Pro
Version 21H1
Installed on ‎15/‎08/‎2020
OS build 19043.1348
Experience Windows Feature Experience Pack 120.2212.3920.0

WSL2 usbip - secure_path update not taken

Updated secure_path with sudo visudo but can't run usbip without the full filepath
I have tried wsl --shutdown and restarted the instance.

Update present in /etc/sudoers:

$ sudo cat /etc/sudoers
(file is stock other than this update)
...
Defaults secure_path="/usr/lib/linux-tools/5.4.0-77-generic:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
...

$ usbip
WARNING: usbip not found for kernel 5.10.60.1-microsoft

You may need to install the following packages for this specific kernel:
linux-tools-5.10.60.1-microsoft-standard-WSL2
linux-cloud-tools-5.10.60.1-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

$ /usr/lib/linux-tools/5.4.0-77-generic/usbip
usage: usbip [--debug] [--log] [--tcp-port PORT] [version]
[help]

attach Attach a remote USB device
detach Detach a remote USB device
list List exportable or local USB devices
bind Bind device to usbip-host.ko
unbind Unbind device from usbip-host.ko
port Show imported USB devices

$ uname -r
5.10.60.1-microsoft-standard-WSL2

I feel like I am missing something ridiculously simple! Any advice would be greatly appreciated!

USB Serial device not present in /dev

'lsusb' lists the device:

❯ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

But I don't see a /dev/ttyUSB* or a /dev/ttyACM*

I have also tried re-building the 5.10.60.1 WSL2 Kernel and adding CP210x driver from the menuconfig

exception when running usbipd

usbipd-win version 1.2.0 which is the latest.
Windows 10 21H1 build 19043

PS C:\WINDOWS\system32> usbipd wsl list Unhandled exception. System.AggregateException: One or more errors occurred. (DEVPKEY_Device_Address (12) does not match DEVPKEY_Device_LocationInfo (3)) ---> System.NotSupportedException: DEVPKEY_Device_Address (12) does not match DEVPKEY_Device_LocationInfo (3) at UsbIpServer.ExportedDevice.GetDevice(SafeDeviceInfoSetHandle deviceInfoSet, SP_DEVINFO_DATA devInfoData, CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ExportedDevice.cs:line 158 at UsbIpServer.ExportedDevice.GetAll(CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ExportedDevice.cs:line 239 at UsbIpServer.Program.<>c.<<Main>b__20_18>d.MoveNext() in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 388 --- End of inner exception stack trace --- at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task1.get_Result() at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass79_0.<OnExecute>b__0() at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at UsbIpServer.Program.Main(String[] args) in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 569

That used to work on Windows 10 2004, but the error appeared after I upgrade my Windows 10.

winget installer reboots without prompting...

Hi, I am really excited to see this available for the WSL!

I ran the winget installer to install things on my desktop a bit earlier, and was somewhat surprised when my desktop immediately rebooted itself without prompting me. Fortunately I didn't lose any work I had open, and I know drivers require a reboot before working, but I generally expect to be prompted to to reboot now or later.

I would ask/suggest that you either:

  1. prompt the user to reboot now or later or
  2. very clearly document this behavior in the README.

Thanks again for the awesome software!

Support for Android Debug Bridge (adb)

Hey, awesome project! I am using Windows 11 and WSL2 and tried to play around with ADB. Unfortunately, it does not seem to work at the moment. My current output is the following:

user@desktop:/mnt/c/Users/user$ lsusb
   Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
   Bus 001 Device 002: ID 2a70:4ee7 OnePlus AC2003
   Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
user@desktop:/mnt/c/Users/user$ adb devices -l
   List of devices attached
   * daemon not running; starting now at tcp:5037
   * daemon started successfully

user@desktop:/mnt/c/Users/user$

As you can see, my phone is available in WSL, but ADB does not see it. Do you have any idea if it might be a configuration issue or is it simply not currently supported?

Unable to connect USB to WSL

Following the post https://devblogs.microsoft.com/commandline/connecting-usb-devices-to-wsl/

I've installed usbipd-win_1.2.0.
Successfully listed the devices with PowerShell

PS C:\WINDOWS\system32> usbipd wsl list
BUSID  DEVICE                                                        STATE
1-5    ADB Device, SM-J500M, USB Serial Device                       Not attached
1-8    Microsoft Hardware USB Keyboard, USB Input Device             Not attached
1-9    Intel(R) Wireless Bluetooth(R)                                Not attached
1-10   USB Input Device, WinUsb Device                               Not attached
1-12   USB Input Device                                              Not attached
1-13   USB Input Device

Unfortunatelly, when I try to attach:

usbipd wsl attach -b 1-5

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

Back to WSL2, I've tried to install the packages, but they are not listed:

sudo apt install linux-tools-5.10.74.3-microsoft-standard-WSL2

Reading package lists... Done
Building dependency tree
Reading state information... Done
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'

How to proceed?

Environment

Windows: 21H2 (OS Build: 22000.318)
WSL: WSL Preview (the one from store), Ubuntu 20.04.3 LTS

Exception on usbipd wsl list

When I issue usbipd wsl list, I get an exception:

❯ usbipd list
Unhandled exception. System.AggregateException: One or more errors occurred. (An item with the same key has already been added. Key: [1, UsbIpServer.UsbConfigurationDescriptors+UsbConfiguration])
 ---> System.ArgumentException: An item with the same key has already been added. Key: [1, UsbIpServer.UsbConfigurationDescriptors+UsbConfiguration]
   at System.Collections.Generic.TreeSet`1.AddIfNotPresent(T item)
   at System.Collections.Generic.SortedSet`1.Add(T item)
   at System.Collections.Generic.SortedDictionary`2.Add(TKey key, TValue value)
   at UsbIpServer.UsbConfigurationDescriptors.AddDescriptor(ReadOnlySpan`1 descriptor) in D:\a\usbipd-win\usbipd-win\UsbIpServer\UsbConfigurationDescriptors.cs:line 96
   at UsbIpServer.ExportedDevice.GetConfigurationDescriptor(DeviceFile hub, UInt16 connectionIndex, Byte numConfigurations)
   at UsbIpServer.ExportedDevice.GetDevice(SafeDeviceInfoSetHandle deviceInfoSet, SP_DEVINFO_DATA devInfoData, CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ExportedDevice.cs:line 202
   at UsbIpServer.ExportedDevice.GetAll(CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\ExportedDevice.cs:line 239
   at UsbIpServer.Program.<>c.<<Main>b__19_9>d.MoveNext() in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 234
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass79_0.<OnExecute>b__0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at UsbIpServer.Program.Main(String[] args) in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 555

Running Windows 11 Pro Insider Preview
Build 22494

Service Crashes on starts

I installed using winget on win11
installed current version

Application: usbipd.exe
CoreCLR Version: 5.0.1121.47308
.NET Version: 5.0.11
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.Net.Sockets.TcpListener.Start(Int32 backlog)
   at UsbIpServer.Server.ExecuteAsync(CancellationToken stoppingToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\Server.cs:line 59
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at UsbIpServer.Program.ExecuteServer(String[] args) in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 582
   at UsbIpServer.Program.<>c__DisplayClass19_3.<Main>b__12() in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 349
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at UsbIpServer.Program.Main(String[] args) in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 555
Faulting application name: usbipd.exe, version: 1.1.1.143, time stamp: 0x614cbf2c
Faulting module name: KERNELBASE.dll, version: 10.0.22489.1000, time stamp: 0x6d237450
Exception code: 0xe0434352
Fault offset: 0x000000000003f29c
Faulting process id: 0x2fdc
Faulting application start time: 0x01d7d1be5ddd792c
Faulting application path: C:\Program Files\usbipd-win\usbipd.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 3c4d8cff-cc62-4b39-87be-0609746145e5
Faulting package full name: 
Faulting package-relative application ID: 
Fault bucket 1761208375485854480, type 4
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: usbipd.exe
P2: 1.1.1.143
P3: 614cbf2c
P4: KERNELBASE.dll
P5: 10.0.22489.1000
P6: 6d237450
P7: e0434352
P8: 000000000003f29c
P9: 
P10: 

Attached files:
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.06fbc066-e275-44ca-bdfe-7119ed33033e.tmp.mdmp
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.771e5b3c-2a08-4cd4-8e68-f9e3aef60a6d.tmp.WERInternalMetadata.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.ccc98cca-1a27-4e49-a700-ede6c0f31f69.tmp.xml
WPR_initiated_DiagTrackMiniLogger_OneTrace_User_Logger_20211011_1 EC_0_inject.etl
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.371f4ae1-3b74-49d0-b02b-e9a6c0572546.tmp.etl
WPR_initiated_DiagTrackMiniLogger_WPR System Collector_inject.etl
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.37268237-3b05-42ec-b4e2-0c1940d04e91.tmp.etl
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.7bbc396f-18a7-4a6a-9999-caf617a12a4b.tmp.csv
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.876268b9-ca60-4ca5-9961-4e4d6049f9b5.tmp.txt

These files may be available here:
\\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_usbipd.exe_ef47495212974ddfe9a9b8b19fc674f127ed7_cb48227a_3a642198-3cc4-4268-9e95-15687735b76d

Analysis symbol: 
Rechecking for solution: 0
Report Id: 3c4d8cff-cc62-4b39-87be-0609746145e5
Report Status: 268435456
Hashed bucket: 2d0924dc9ddecdf4687111afac46f310
Cab Guid: 0

Unable to attach because of a problem in RegistryWatcher

I was having a problem attaching any device, and based on my debugging the problem seems to occur in RegistryWatcher when it tries to find the usbipd-win RootPath. I'm not familiar with the RegistryWatcher API, so I might be barking up the wrong tree, but let me explain...

I installed the 1.1.1 release of usbipd-win.

I made the specified changes to my WSL2 Ubuntu 20.04 distribution to enable usbip.

From an Administrative command prompt, usbipd wsl list works as expected, but usbipd wsl attach --busid=3-4 (or any other busid) fails with:

usbip: error: Attach Request for 3-4 failed - Request Completed Successfully
usbipd: error: Failed to attach device with ID '3-4'.

I tried stopping the service then running "usbipd server Logging:LogLevel:Default=Trace" from a command prompt. The request still fails, and the output from usbipd didn't specify the problem:

new connection from 172.22.53.25
dbug: UsbIpServer.Server[0]
connection closed

So, I downloaded the master branch of the project's code, and ran it in Visual Studio 2019. When I ran the attach request, an exception occurred in RegistryWatcher:

 System.Management.ManagementException: Not found
       at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
       at System.Management.ManagementEventWatcher.Start()
       at UsbIpServer.RegistryWatcher..ctor() in C:\Users\gigam\source\repos\dotnet\usbipd-win\UsbIpServer\RegistryWatcher.cs:line 29
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
       at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
       at UsbIpServer.Server.<>c__DisplayClass7_1.<<ExecuteAsync>b__1>d.MoveNext() in C:\Users\gigam\source\repos\dotnet\usbipd-win\UsbIpServer\Server.cs:line 91

So, I put a breakpoint at line 29 of RegistryWatcher. The query it is running looks correct to me:

"SELECT * FROM RegistryTreeChangeEvent WHERE Hive='HKEY_LOCAL_MACHINE' AND RootPath='SOFTWARE\\\\usbipd-win'"

I checked the registry, and that key exists. But, when watcher.Start() runs, the "Not found" exception is thrown.

To see if the problem was specifically with the usbipd-win key, I changed the RootPath to a "known good" one:

"SELECT * FROM RegistryTreeChangeEvent WHERE Hive='HKEY_LOCAL_MACHINE' AND RootPath='SOFTWARE\\\\Microsoft'"

To my surprise, this not only prevented the "Not found" exception, but it actually allowed the program to continue successfully. It went into ConnectedClient.HandleRequestImportAsync() as expected, detached the device from Windows and attached it to Linux. The device showed up in Linux's lsusb output.

Although the code is using APIs that I've never worked with before, I assume that changing the RootPath will prevent detach requests from working, so this isn't a fix.

Do you have any ideas on why that RegistryWatcher query might fail on my PC, or what changes I might make to the query syntax to allow it to find the usbipd-win RootPath?

BTW, my PC isn't anything special: Win 11 Home upgraded from Win 10 Home. It's a relatively recent install of Win 10, from January of this year, and I've never messed around with the registry.

I exported the usbipd-win part of the registry. I can provide the full contents if you like, but the key names are:

Key Name:          HKEY_LOCAL_MACHINE\SOFTWARE\usbipd-win
. . .
Key Name:          HKEY_LOCAL_MACHINE\SOFTWARE\usbipd-win\Devices
. . .
Key Name:          HKEY_LOCAL_MACHINE\SOFTWARE\usbipd-win\Devices\{b0b1d849-c49e-4af5-9fc3-1a231181d714}
. . .
Key Name:          HKEY_LOCAL_MACHINE\SOFTWARE\usbipd-win\Devices\{b0b1d849-c49e-4af5-9fc3-1a231181d714}\Filter

Thanks,

Dan.

Any possibility of attaching usbip devices to Windows?

This project is great, but I'm hoping to use it backwards - connecting a USB device from a physical linux computer to a Windows Machine. There have been other implementations of USBIP for Windows that enabled this, however none of them are very well maintained or work without test signing.
I'm sure it's a long shot, but is this at all possible?

Potential memory corruption bug in DeviceFile.IoControlAsync

In DeviceFile.IoControlAsync, the input and output arrays are pinned using the lock statement for the call to DeviceIoControl. However, the arrays are then unlocked before the overlapped operation completes. If the GC moves the buffers after the arrays get unlocked, this could result in memory corruption or use-after-free when the win32 code attempts to read or write to the pointers.

To solve this, use an explicit GCHandle of type Pinned, and release it only when the overlapped operation completes.

fixed (byte* pInput = input, pOutput = output)

Found by code inspection

Not able to `usbipd wsl list` USB Devices

Discussed in https://github.com/dorssel/usbipd-win/discussions/76

Originally posted by tunguskar November 8, 2021
I followed the instructions. After all i Started powerShell on Windows side and typed: (No Admin Rights)

usbipd wsl list
All the devices were output. When I now want to bind a device (Hardware Debugger) I get the following error:

usbipd: error: Access denied.

When I start the power shell with admin privileges, I get the following:

PS C:\WINDOWS\system32> usbipd wsl list Unhandled exception. System.AggregateException: One or more errors occurred. (WSL failed to list distributions: ) ---> UsbIpServer.UnexpectedResultException: WSL failed to list distributions: at UsbIpServer.WslDistributions.CreateAsync(CancellationToken cancellationToken) in D:\a\usbipd-win\usbipd-win\UsbIpServer\WslDistributions.cs:line 90 at UsbIpServer.Program.<>c.<<Main>b__19_18>d.MoveNext() in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 386 --- End of inner exception stack trace --- at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task1.get_Result() at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass79_0.<OnExecute>b__0() at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at UsbIpServer.Program.Main(String[] args) in D:\a\usbipd-win\usbipd-win\UsbIpServer\Program.cs:line 555

AddDescriptor crashes adding duplicate key

When trying to run ./usbipd wsl list I get:

Unhandled exception. System.AggregateException: One or more errors occurred. (An item with the same key has already been added. Key: [1, UsbIpServer.UsbConfigurationDescriptors+UsbConfiguration])
 ---> System.ArgumentException: An item with the same key has already been added. Key: [1, UsbIpServer.UsbConfigurationDescriptors+UsbConfiguration]
   at System.Collections.Generic.TreeSet`1.AddIfNotPresent(T item)
   at System.Collections.Generic.SortedSet`1.Add(T item)
   at System.Collections.Generic.SortedDictionary`2.Add(TKey key, TValue value)
   at UsbIpServer.UsbConfigurationDescriptors.AddDescriptor(ReadOnlySpan`1 descriptor) in C:\github\usbipd-win\UsbIpServer\UsbConfigurationDescriptors.cs:line 98
   at UsbIpServer.ExportedDevice.GetConfigurationDescriptor(DeviceFile hub, UInt16 connectionIndex, Byte numConfigurations) in C:\github\usbipd-win\UsbIpServer\ExportedDevice.cs:line 130
   at UsbIpServer.ExportedDevice.GetDevice(SafeDeviceInfoSetHandle deviceInfoSet, SP_DEVINFO_DATA devInfoData, CancellationToken cancellationToken) in C:\github\usbipd-win\UsbIpServer\ExportedDevice.cs:line 202
   at UsbIpServer.ExportedDevice.GetAll(CancellationToken cancellationToken) in C:\github\usbipd-win\UsbIpServer\ExportedDevice.cs:line 239
   at UsbIpServer.Program.<>c.<<Main>b__19_18>d.MoveNext() in C:\github\usbipd-win\UsbIpServer\Program.cs:line 387
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass79_0.<OnExecute>b__0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at UsbIpServer.Program.Main(String[] args) in C:\github\usbipd-win\UsbIpServer\Program.cs:line 555

So I added some Console.WriteLine logging and get

Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Adding Key: 1 with Windows.Win32.Devices.Usb.USB_CONFIGURATION_DESCRIPTOR
Unhandled exception. System.AggregateException: One or more errors occurred. (An item with the same key has already been added. Key: [1, UsbIpServer.UsbConfigurationDescriptors+UsbConfiguration])

But I'm confused. Why didn't the second "adding key: 1" fail, and what's config.bConfigurationValue expected to be?

It seems like my machine has some number of devices that you're not expecting to "be the same" when loaded into the hashtable. Two mice? Two webcams? Two identical brand Anker USB Hubs? Yes to all of these things.

Any ideas on the best way to debug?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.