microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
16.91k stars 798 forks source link

USB device support, libusb (ADB support, etc) #2195

Open timcanham opened 7 years ago

timcanham commented 7 years ago

This bug-tracker is monitored by developers and other technical types. We like detail! So please use this form and tell us, concisely but precisely, what's up. Please fill out ALL THE FIELDS!

If you have a feature request, please post to the UserVoice. If you're reporting a BSOD, don't post here! Instead, e-mail "secure@microsoft.com", and if possible attach the minidump from "C:\Windows\minidump\".

n/a

See our contributing instructions for assistance.

lucasfolino commented 3 years ago

I completely agree with @digitalentropy. This is a feature that for me makes or breaks WSL. Right now WSL is more a fun little cool I can do that, or the occasional drop down to WSL to run a command like rsync or a quick script. I still need to have a full VM for things like Kali for wireless pen testing, or another distro for SDR work. I also use Linux for Arduino or other instance where I need to flash firmware to something and to be honest Linux has better tools for that job. Not as much for the Arduino, but since I need to flash other stuff my toolchain is in Linux since I need it any way.

dinvlad commented 3 years ago

I also agree @digitalentropy - unfortunately in this case though, this is not entirely WSL2's fault, since native USB pass-through is just not supported by Hyper-V, if it wasn't clear :)

I think to "properly" solve this problem we need to reach Hyper-V team somehow, and ask about their roadmap for USB pass-through (if any). Without that, I'd be glad to try my hand at the Hyper-V sockets proxy solution I suggested above, although being a workaround, this may or may not solve the problem for most. I'm not sure what else WSL2 team has up their sleeve however..

dlang123 commented 3 years ago

+1 for me as well. I have a use case where I need to connect some USB3 cameras to a linux WSL and then everything else is great. I also need to connect some UBlox GPS USB to a Linux WSL. USB passthrough matters a lot.

acederberg commented 3 years ago

usercase: mobile development

Trying to mess around with my iPhone without MacOS because I don't want to pay for it. I assumed that I would be able to use "libimobiledevice" and "ifuse" to do this with Linux to avoid building an physical version of Linux. I am just posting because I quite like both Windows and Linux, and would like to be able to "shove" both onto one machine with full functionality. I will return if I learn anything useful.

Thank you everybody who has contributed to this thread and the closed threads! Without you all I'd be much more lost than I am already.

kdubious commented 3 years ago

I'm using Buildroot to create an OS for an IoT style audio device. Great having WSL2 on my WinPC for doing that. Not so great that I can't dd a USB stick. Seems this would be a wonderful feature.

therealkenc commented 3 years ago

Not so great that I can't dd a USB stick

There is are open #6392 #6270 ➡️ #689 related to mounting a USB stick as a block device. This ask is libusb support.

scyto commented 3 years ago

This is needed for scenarios like docker - i have number of applications that require USB devices like USB serial zwave adapters, google coral for tensor flow applications, etc.

woreom commented 3 years ago

Hi, So I just reinstalled windows and my work usually uses OpenCV, webcam, and mxnet, In the previous versions I couldn't get them to work with wsl, I was wondering if anything has changed in these few months?

Bromvlieg commented 3 years ago

+1, only reason i need a actual linux machine around me is due WSL not supporting this.

enigmata commented 3 years ago

Likewise +1

scyto commented 3 years ago

I am unconvinced anyone from MS looks at the WSL/WSL2 issues any more - take a look at the mess of a github issue about DNS issues where people keep posting the same workarounds to an underlying set of bugs in the networking stack of windows / hyper-v / WSL2 - any github issue that turns into a chat forum or support thread is DOA in terms of being useful. Including this one :-(

I have stopped bothering to file as MS can't be bothered to actually manage their issues lists 1.1k un-addressed issues means this git repo is not being managed in any meaningful way and causing terrible signal to noise issues. Shame as WSL is freaking awesome. @satyanadella

the one bright spot i have had with MS and github is the filing of document issues / clarifications - they get addressed quickly. Funny document writers are doing better job with github than engineers :-)

tyeth commented 3 years ago

I am unconvinced anyone from MS looks at the WSL/WSL2 issues any more - take a look at the mess of a github issue about DNS issues where people keep posting the same workarounds to an underlying set of bugs in the networking stack of windows / hyper-v / WSL2 - any github issue that turns into a chat forum or support thread is DOA in terms of being useful. Including this one :-(

I have stopped bothering to file as MS can't be bothered to actually manage their issues lists 1.1k un-addressed issues means this git repo is not being managed in any meaningful way and causing terrible signal to noise issues. Shame as WSL is freaking awesome. @satyanadella

the one bright spot i have had with MS and github is the filing of document issues / clarifications - they get addressed quickly. Funny document writers are doing better job with github than engineers :-)

I sadly found twitter to be the best form of support with a lot of companies including Microsoft (Shout out @AzureSupport team 🥳 ). They almost always want to take it into DirectMessages (to protect you / hide their shame) and more often than not it's a quick escalation tool, bypassing things like paid support quotas (they can grant you free support incidents), etc. I found it to be prompt and thorough.

When I last looked for news in 2020 some key WSL2 people were at least present and shouting about new release features etc.

gaia commented 3 years ago

I am unconvinced anyone from MS looks at the WSL/WSL2 issues any more - take a look at the mess of a github issue about DNS issues where people keep posting the same workarounds to an underlying set of bugs in the networking stack of windows / hyper-v / WSL2 - any github issue that turns into a chat forum or support thread is DOA in terms of being useful. Including this one :-(

I have stopped bothering to file as MS can't be bothered to actually manage their issues lists 1.1k un-addressed issues means this git repo is not being managed in any meaningful way and causing terrible signal to noise issues. Shame as WSL is freaking awesome. @satyanadella

the one bright spot i have had with MS and github is the filing of document issues / clarifications - they get addressed quickly. Funny document writers are doing better job with github than engineers :-)

If MS abandons WSL, I will have to abandon Windows entirely.

GranoblasticMan commented 3 years ago

Probably a good idea at this point. Seems like the OS only exists to push Microsoft products and services these days with all the advertisements, "suggestions," etc. Microsoft has no real interest in the operating system from a usability standpoint.

lucasfolino commented 3 years ago

I think the issue is that the development of WSL is tied directly to Windows development and updates. It seems to only get updates when Windows is updated. So it moves slowly. I don't think it is abandoned because they where pushing people to it pretty hard. I think the issue how coupled it is to Windows so it may be that to make some of the bigger changes require changes to be made in Windows. I think the USB change is probably one of those changes. Now if we get a few release cycles with no or very little movement in WSL I would agree that Microsoft doesn't care.

jbcpollak commented 3 years ago

If MS abandons WSL, I will have to abandon Windows entirely

I think the idea was that MS doesn't review the repo on issues, not that they are abandoning the project. From everything I've seen the WSL has a ton of momentum.

I'd suggest keeping this issue on topic. If you have greater concerns about the repo you can file another issue or reach out to MS on another medium.

dinvlad commented 3 years ago

Yes, I think to keep it focused, we should ask what are the plans to enable USB pass-through in Hyper-V, and if there's a better avenue for us as users to communicate this request?

Iguins commented 3 years ago

Hello, As everyone mentioned before, it will be nice to know if we have any timeline from the Hyper-V team for usb passthrough. This is a much needed feature in WSL. Thanks

SmartBoy84 commented 3 years ago

This issue is likely going unnoticed. This has been sought after since wsl's initial release yet Microsoft has only made vague attempts to address it, why?

dinvlad commented 3 years ago

I'd imagine it's hard to communicate such requirements between different teams, which is not uncommon in organizations both big and small. We should probably try to find how to reach out to Hyper-V team more directly.

reitowo commented 2 years ago

Why can't WSL2 just provice some CLI or GUI tools like VMware Workstation's USB selection tool to let us select whether an USB device should connect to WSL or Windows? image

However, the ideal situation is WSL 2 can access USB devices shared with Windows.

mcuee commented 2 years ago

I also agree @digitalentropy - unfortunately in this case though, this is not entirely WSL2's fault, since native USB pass-through is just not supported by Hyper-V, if it wasn't clear :)

I think to "properly" solve this problem we need to reach Hyper-V team somehow, and ask about their roadmap for USB pass-through (if any). Without that, I'd be glad to try my hand at the Hyper-V sockets proxy solution I suggested above, although being a workaround, this may or may not solve the problem for most. I'm not sure what else WSL2 team has up their sleeve however..

Very good summary. Just wondering why Hyper-V is lacking USB support for so long.

mcuee commented 2 years ago

I do not use Hyper-V or WSL simply because it does not support USB.

juanmartinez-viamericas commented 2 years ago

Ensure to have the same ADB version in windows and wsl2.

On Windows:

adb tcpip 5555

Then on WSL 2:

adb connect [ip device]:5555

If it's the first time, it's going to ask you for permission in your phone, make sure to check the box to always grant permission. Then restart adb and connect again:

adb kill-server
adb connect [ip device]:5555

source: https://stackoverflow.com/a/65242444/812915

thomasthorsen commented 2 years ago

Using adb in WSL2 is simplest and works well if you just (only) install adb in Windows and just call the adb.exe binary from within WSL2.

  1. Download from here https://dl.google.com/android/repository/platform-tools-latest-windows.zip
  2. Extract the contents of this ZIP file into C:\adb (or any other folder)
  3. Add the folder C:\adb\platform-tools to the Path environment variable in Windows (if you need help with this, see https://www.xda-developers.com/adb-fastboot-any-directory-windows-linux/ and follow the instructions for Windows). You may need to restart WSL2 after this to make the new Path apply within the WSL2 environment (test by running adb.exe in WSL2).
  4. Add a symlink to adb.exe by executing: ln -s $(which adb.exe) $(dirname $(which adb.exe))/adb

The symlink added in step 4 means you don't have to type adb.exe, but can just type adb in commands, as you would expect from a native install.

reitowo commented 2 years ago

This is pretty clear that we all want an 'USB switch' feature just like VMWare provides.

SmartBoy84 commented 2 years ago

This is pretty clear that we all want an 'USB switch' feature just like VMWare provides.

The only problem seems to be finding a way to contact Microsoft/Hyper-V since they are clearly not taking any notice of this thread (or at least haven't addressed it)

There is no point promoting this thread anymore.

Toumash commented 2 years ago

What about this option? https://www.tenforums.com/virtualization/174394-how-add-webcam-windows-10-vm-hyper-v.html

Biswa96 commented 2 years ago

@cnSchwarzer Do you know how vmware does that? Or at least a general overview or docs of that technology.

dinvlad commented 2 years ago

@Toumash @Biswa96 As the article says, it's using RemoteFX USB Device Redirection, which is a tech available only in Windows host and guest environments..

Thanks for the info - but also remember that your HYPER-V VM must be Windows PRO or above because RDP server won't run on Windows HOME. (This is the VM -- and also the HOST needs to be WINDOWS 10 pro or above to enable HYPER-V for VM creation).

virtualhere commented 2 years ago

Can you guys give this a try https://www.virtualhere.com/comment/9758#comment-9758 and see if it works ok regarding passing through

dinvlad commented 2 years ago

@virtualhere it's not a free/open-source solution and relies on network stack communication, with all of the disadvantages as already discussed above. I looked at that thread a while back, but decided not to try it because of these reasons. I'm sure it would work ok for non-latency-sensitive applications, but I don't think this would be ideal in all cases, unfortunately (thanks for making it though!). Plus, we're mostly looking for a native solution from Microsoft here! 😉

SmartBoy84 commented 2 years ago

Can you guys give this a try https://www.virtualhere.com/comment/9758#comment-9758 and see if it works ok regarding passing through

@virtualhere Even USB/IP doesn't seem to work for me. I've compiled and loaded the latest WSL2 kernel which reportedly has USB/IP enabled but I can't seem to connect any device - it always returns "failed". VirtualHere and the client connect successfully as I can do "-t list" to see all the connected devices. Neither side is running the application as a daemon/service. I have been able to connect my Bluetooth dongle but nothing else seems to work (wifi adapters, serial adapters, iPhone, etc)

Hobbit44 commented 2 years ago

I have two use cases related to this:

  1. In work land i would like to be able to use my yubikey to auth to google for command line authorizations
  2. On personal i would like to be able to write to arduino or ESP chips from linux.

+1 would love USB support

arandomdev commented 2 years ago

On the release notes for kernel 5.10.60.1, it had this, Enable USB kernel configuration options for interacting with an Arduino over USB. Does anyone know what this does or changes?

craigloewen-msft commented 2 years ago

You are now able to access USB devices from within WSL using a 3rd party workflow. For full details I recommend that you watch this YouTube video: https://www.youtube.com/watch?v=I2jOuLU4o8E

The summary is that the Visual Studio team contributed to an open source and 3rd party project called usbipd-win. Using this tool will now allow you to pretty easily access your USB devices from within WSL, on any Windows 11 machine.

I'm going to keep this issue open as we would still like to track having a USB solution that is directly part of WSL, but using this project should unblock many scenarios mentioned here.

Thank you!

lucasfolino commented 2 years ago

Thank you for bringing this to our attention for it may fulfill some use cases for USB devices on WSL. This is still a work around and not true USB passthrough. It sounds like it is more of a USB IP connection. For some use cases this would work great like programming a Pi/Arduino or firmware flashing where latency may not be as big of an issue. My use case is raw access to a device I use wireless device like any Alfa cards for use with Kali Linux for some network security tests.

I think this is pretty cool and will try for my Alfa cards when I get a chance, but it still seems that there may be some IP overheard or issues with USB over IP. I feel that this functionality should be part of Hyper-V/WSL and not rely on third party app. This feature is also why I have stayed away from Hyper-V because I do testing that requires dongles, or other USB attachments for authentication or access to a device.

Quick questions does this work in Windows 10 or only Windows 11. I wasn't sure if WSL on Windows 11 is different or has something Windows 10 doesn't which would cause this not to work.

scyto commented 2 years ago

Thanks @craigloewen-msft just filed my first issue against the project for service crash :-)

I plan to try a radio usb device and zwave dongle to see if this works once the service crash is solved.

Also how should we install winget on server - just install the winget package manually? (there is no store)

Trass3r commented 2 years ago

Quick questions does this work in Windows 10 or only Windows 11. I wasn't sure if WSL on Windows 11 is different or has something Windows 10 doesn't which would cause this not to work.

You'll need to compile the kernel yourself for Win10: https://github.com/dorssel/usbipd-win/wiki/WSL-support Or maybe you can use a prebuilt https://github.com/nathanchance/WSL2-Linux-Kernel#readme in the future when it picks up those config changes.

sigprof commented 2 years ago

You'll need to compile the kernel yourself for Win10: https://github.com/dorssel/usbipd-win/wiki/WSL-support

Actually it seems that the required WSL kernel update (5.10.60.1) is now offered at least for Windows 10 21H1 — I got it automatically installed on 2021-11-03, and USB/IP works for me (with some rough edges that don't seem to be related to Windows 10/11 differences  — e.g., at the moment usbipd wsl attach works only when specifying a Debian/Ubuntu-based WSL instance; however, because all WSL instances actually run as containers within the same Linux VM, you can attach the device to a supported instance, but actually see the device in all other WSL instances running at the same time).

Biswa96 commented 2 years ago

Some clarifications.

Actually it seems that the required WSL kernel update (5.10.60.1) is now offered at least for Windows 10 21H1

You don't have to wait for the update. It can be downloaded from here https://www.catalog.update.microsoft.com/Search.aspx?q=wsl or here https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

because all WSL instances actually run as containers within the same Linux VM

Only the WSL2 instances are running in VM mode.

at the moment usbipd wsl attach works only when specifying a Debian/Ubuntu-based WSL instance

The usbip feature is not distribution specific.

sigprof commented 2 years ago

The usbip feature is not distribution specific.

The current release of usbipd-win has a compatibility problem which makes usbipd wsl attach work only when the Debian variant of the hostname utility is used by the specified WSL2 instance: dorssel/usbipd-win#85 (a fix is already in development though). In addition, there might be potential compatibility issues between the distro-provided usbip binary and the WSL2 kernel (but I did not notice anything like that in my testing).

ghost commented 2 years ago

Anything new here?

matrixes commented 2 years ago

You are now able to access USB devices from within WSL using a 3rd party workflow. For full details I recommend that you watch this YouTube video: https://www.youtube.com/watch?v=I2jOuLU4o8E

The summary is that the Visual Studio team contributed to an open source and 3rd party project called usbipd-win. Using this tool will now allow you to pretty easily access your USB devices from within WSL, on any Windows 11 machine.

I'm going to keep this issue open as we would still like to track having a USB solution that is directly part of WSL, but using this project should unblock many scenarios mentioned here.

Thank you!

usbipd-win is certainly a welcome alternative. I've been able to interface with e.g. an arduino using this method and it has its uses. One thing that I'd also like to get working is being able to use my Yubikey (4, if that's a useful detail) within WSL, accessible as a non superuser. There's some discussion about it here https://github.com/dorssel/usbipd-win/discussions/127#discussioncomment-1722693 but the quote "...you will need to compile a kernel with the correct drivers, I think..." is where I'm stuck.

dinvlad commented 2 years ago

@matrixes for the Yubikey, I've been successfully using it without usbipd-win for signing and pushing commits and Webauth inside WSL in a multi-WSL-distro scenario. It's pretty useful to be able to share the same Yubikey between Win and WSL, and I'm not sure if usbipd-win actually enables that (is it exclusive to the guest?)

beriberikix commented 2 years ago

Did you follow everything here? https://support.yubico.com/hc/en-us/articles/360013708900-Using-Your-U2F-YubiKey-with-Linux. I don't know enough about the yubikey but I've seen a lot of people successfully use usbipd-win in the following scenarios:

dinvlad commented 2 years ago

I haven't tried personally, as I've made it successfully and reproducibly work without usbipd-win and having to rebuild the kernel. Here's a guide I've composed on it from several other guides: https://gist.github.com/dinvlad/a62d44325fa2b989a046fe984a06e140

matrixes commented 2 years ago

Updated post


Did you follow everything here? https://support.yubico.com/hc/en-us/articles/360013708900-Using-Your-U2F-YubiKey-with-Linux. I don't know enough about the yubikey but I've seen a lot of people successfully use usbipd-win in the following scenarios:

* The device driver is already enabled or not needed, just need the proper udev rule ([example](https://github.com/Yubico/libu2f-host/blob/master/70-u2f.rules))

* They needed to build a custom kernel and enable the right driver (see [Enable common USB Serial devices by default #7686](https://github.com/microsoft/WSL/issues/7686))

* They were missing some user-space dependency or linking to an old version (ex. libusb)

It's unclear how HID is supported or if it's needed for a Yubikey, so this may not be that helpful for you!

I did not know of this, thanks for bringing it forward. I've followed the instructions (I enabled/included all USB devices/manufacturers I could find in the wsl-config interface) that are linked from #7686 and I'm unfortunately still not able to interact with the key as non-root. Here's the log up to this point.

Kernel before following instructions

$ uname -r
5.10.60.1-microsoft-standard-WSL2

Kernel after following instructions

$ uname -r
5.10.74.3-microsoft-standard-WSL2+

udev seems to find and attach the Yubikey properly

$ udevadm monitor
KERNEL[1353.300781] add      /devices/platform/vhci_hcd.0/usb1/1-1 (usb)
KERNEL[1353.305737] add      /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0 (usb)
KERNEL[1353.309796] add      /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0/0003:1050:0407.0009 (hid)
KERNEL[1353.309872] add      /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0/0003:1050:0407.0009/input/input4 (input)
KERNEL[1353.371106] bind     /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0/0003:1050:0407.0009 (hid)
KERNEL[1353.371156] bind     /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0 (usb)
KERNEL[1353.371200] add      /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.1 (usb)
KERNEL[1353.374674] add      /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.1/0003:1050:0407.000A (hid)

lsusb sees it fine

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

gpg does not recognise the device for my user

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

gpg recognises the device for root

$ sudo gpg --card-status
[sudo] password:
Reader ...........: Yubico YubiKey OTP FIDO CCID 00 00

I also tried this pointer https://github.com/dorssel/usbipd-win/discussions/127#discussioncomment-1817105 without success

It certainly seems like all this is close to working, but I can't tell where the answer is, only conclude that my user does not recognise the device while root does.

I haven't tried personally, as I've made it successfully and reproducibly work without usbipd-win and having to rebuild the kernel. Here's a guide I've composed on it from several other guides: https://gist.github.com/dinvlad/a62d44325fa2b989a046fe984a06e140

I have a very similar setup from https://blog.nimamoh.net/yubi-key-gpg-wsl2/ but it's janky and I'd rather get something closer to scdaemon working properly/natively instead of passing messages between WSL to Gpg4Win through socat glue.

onyxcherry commented 2 years ago

I haven't tried personally, as I've made it successfully and reproducibly work without usbipd-win and having to rebuild the kernel. Here's a guide I've composed on it from several other guides: https://gist.github.com/dinvlad/a62d44325fa2b989a046fe984a06e140

Did you follow everything here? https://support.yubico.com/hc/en-us/articles/360013708900-Using-Your-U2F-YubiKey-with-Linux. I don't know enough about the yubikey but I've seen a lot of people successfully use usbipd-win in the following scenarios:

  • The device driver is already enabled or not needed, just need the proper udev rule (example)
  • They needed to build a custom kernel and enable the right driver (see Enable common USB Serial devices by default #7686)
  • They were missing some user-space dependency or linking to an old version (ex. libusb)

It's unclear how HID is supported or if it's needed for a Yubikey, so this may not be that helpful for you!

Unfortunately, even with Yubico's udev rules - same as I wrote here https://github.com/microsoft/WSL/issues/2195#issuecomment-995195379 :(

SheepReaper commented 2 years ago

Did you follow everything here? https://support.yubico.com/hc/en-us/articles/360013708900-Using-Your-U2F-YubiKey-with-Linux. I don't know enough about the yubikey but I've seen a lot of people successfully use usbipd-win in the following scenarios:

* The device driver is already enabled or not needed, just need the proper udev rule ([example](https://github.com/Yubico/libu2f-host/blob/master/70-u2f.rules))

* They needed to build a custom kernel and enable the right driver (see [Enable common USB Serial devices by default #7686](https://github.com/microsoft/WSL/issues/7686))

* They were missing some user-space dependency or linking to an old version (ex. libusb)

It's unclear how HID is supported or if it's needed for a Yubikey, so this may not be that helpful for you!

I did not know of this, thanks for bringing it forward. I've followed the instructions (I enabled/included all USB devices/manufacturers I could find in the wsl-config interface) that are linked from #7686 and I'm unfortunately still not able to interact with the key as non-root. Here's the log up to this point.

Kernel before following instructions

$ uname -r
5.10.60.1-microsoft-standard-WSL2

Kernel after following instructions

$ uname -r
5.10.74.3-microsoft-standard-WSL2+

udev seems to find and attach the Yubikey properly

$ udevadm monitor
KERNEL[1353.300781] add      /devices/platform/vhci_hcd.0/usb1/1-1 (usb)
KERNEL[1353.305737] add      /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0 (usb)
KERNEL[1353.309796] add      /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0/0003:1050:0407.0009 (hid)
KERNEL[1353.309872] add      /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0/0003:1050:0407.0009/input/input4 (input)
KERNEL[1353.371106] bind     /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0/0003:1050:0407.0009 (hid)
KERNEL[1353.371156] bind     /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0 (usb)
KERNEL[1353.371200] add      /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.1 (usb)
KERNEL[1353.374674] add      /devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.1/0003:1050:0407.000A (hid)

lsusb sees it fine

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

gpg does not recognise the device for my user

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

gpg recognises the device for root

$ sudo gpg --card-status
[sudo] password:
Reader ...........: Yubico YubiKey OTP FIDO CCID 00 00

I also tried this pointer dorssel/usbipd-win#127 (comment) without success

It certainly seems like all this is close to working, but I can't tell where the answer is, only conclude that my user does not recognise the device while root does.

I haven't tried personally, as I've made it successfully and reproducibly work without usbipd-win and having to rebuild the kernel. Here's a guide I've composed on it from several other guides: https://gist.github.com/dinvlad/a62d44325fa2b989a046fe984a06e140

I have a very similar setup from https://blog.nimamoh.net/yubi-key-gpg-wsl2/ but it's janky and I'd rather get something closer to scdaemon working properly/natively instead of passing messages between WSL to Gpg4Win through socat glue.

Did you try adding yourself to the plugdev group? (or whichever group your udev rules are using for the yubikey) <- the root user isn't magic (most of the time) but it usually has more memberships than normal users, hence why it can see the device but you can't.