Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2: Ubuntu 18.04 Serial devices are no longer mounted properly #4322

Open
david-dumke opened this issue Jul 19, 2019 · 189 comments
Open

WSL2: Ubuntu 18.04 Serial devices are no longer mounted properly #4322

david-dumke opened this issue Jul 19, 2019 · 189 comments
Labels
feature wsl2 Issue/feature applies to WSL 2

Comments

@david-dumke
Copy link

david-dumke commented Jul 19, 2019

  • Your Windows build number: Microsoft Windows [Version 10.0.18932.1000]

  • What you're doing and what's happening:

  1. run WSL2 Ubuntu 18.04
  2. plugin USB to serial device
  3. watch it mount under COM devices in device manager
  4. attempt to open the device in WSL2
  5. cat /dev/ttyS[X]
  • What's wrong / what should be happening instead:
    This works under WSL1 flawlessy, it no longer works in WSL2
    in WSL2 we can clearly see it is not connected or configured
    /dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
    COM3-wsl-pic

COM3-pic

@rubberduck203
Copy link

It’s clearly called out in the FAQ that there is currently no support for USB in WSL2.

I’d like to toss my voice in here that this should be a priority feature for WSL2.

One of the big benefits of WSL2 is the opportunity to run Docker natively instead of on Docker for Windows. It is notoriously hard to get access to USB devices in Docker on non-Linux systems.

I commonly use Docker for creating tool-chain images, but this falls apart when you’re working with embedded devices, where you need to connect to a USB device or serial port in order to flash/debug on device. If I can run a docker container natively and access USB ports with WSL2, I can make an extremely strong argument for switching from Mac to Windows.

@linweifu
Copy link

up

@zawawimanja
Copy link

so that why I cannot see my usb device in ubuntu.hurmmm

@rubberduck203
Copy link

It would be really nice if someone could chime in letting us know if this is even technically feasible.

@sebbean
Copy link

sebbean commented Dec 3, 2019

would love to know

@chenhu66
Copy link

chenhu66 commented Apr 4, 2020

what a pity! i gotta roll back to wsl 1. Hopefully, usb support comes up soom for wsl2

@tleroy-dev
Copy link

tleroy-dev commented May 11, 2020

what a pity! i gotta roll back to wsl 1. Hopefully, usb support comes up soom for wsl2

Can I have the detailed step to roll back from WSL2 to WSL1 ?
I found under https://docs.microsoft.com/en-us/windows/wsl/release-notes#build-18917 that WSL2 was introduced at build version 18917. Now, how can I re-install WSL from a specific build number ? Thank you.

EDIT my current build number is below 18917 and should be WSL1, right ? But the USB COM PORT is not recognized in WSL env.

My current os version:

PS C:\Users\nxf43719> [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      17134  0

@rubberduck203
Copy link

I thought you could have WSL1 and WSL2 installed side by side?

@tleroy-dev
Copy link

tleroy-dev commented May 11, 2020

@rubberduck203 it's not clear to me how to check which WSL version we are running. It is not described in the app store. From online information I have found:

We need to run Windows Build 16215 or later to install WSL 1.

WSL 2 is only available in Windows Builds 18917 or higher.

You can install both version if your build is higher than 18917.
So in my case I am running a 17134 build, I should only have WSL1 available, correct ?
In my case I still have troubles accessing serial USB device from my linux terminal under /dev/. They don't show up but are dettected in Windows Device Manager.

@bburky
Copy link

bburky commented May 11, 2020

@tleroy-dev If your system supports WSL2, you can choose WSL1 or WSL2 per distro.

VERSION from wsl --list --verbose shows if you're using WSL1 or WSL 2:

> wsl --list --verbose
  NAME                   STATE           VERSION
* docker-desktop-data    Stopped         2
  docker-desktop         Stopped         2
  Ubuntu-18.04           Stopped         2
  Fedora-32              Stopped         2
  Ubuntu                 Stopped         1

The normal recommendation is to use WSL2 for installation of all new WSL distros. Note, this doesn't affect your current installed WSL distros, if you have any already they will stay on WSL1.

wsl --set-default-version 2

If you want to manually upgrade a distro to WSL2 or "downgrade" it to WSL1, you can use --set-version. I keep a WSL1 distro around to have functioning /dev/ttyS* devices.

wsl --set-version Ubuntu 1

@tleroy-dev
Copy link

tleroy-dev commented May 11, 2020

@bburky Thanks for your response.

PS C:\Users\user> wsl --list --verbose
/bin/bash: --: invalid option

From that documentation, it looks like the wsl.exe command works only on build higher than 1903, older version use wslconfig.exe. Result of equivalent :

PS C:\Users\user> wslconfig.exe /list /all
Distributions du sous-système Windows pour Linux :
Ubuntu (par défaut)

It's in french in my case (system default), it does not output the version specifically, I guess from what I have described earlier, being on a pre-WSL2 build (17134) , only WSL 1 is enabled in my case.

@bburky
Copy link

bburky commented May 11, 2020

@tleroy-dev Yes, sounds like you're definitely on WSL1 then.

@tleroy-dev
Copy link

I have opened a new ticket for my problem under WSL 1 (#5203)

@AsciiWolf
Copy link

Any news regarding USB devices support in WSL2?

@kryptoklob
Copy link

Just upgraded to WSL2 for the native Docker integration, but frustrated that I can't continue to do Arduino development natively in WSL anymore without switching back and forth between WSL versions... any updates here?

@Ludorg
Copy link

Ludorg commented May 30, 2020

Just upgraded to WSL2 for the native Docker integration, but frustrated that I can't continue to do Arduino development natively in WSL anymore without switching back and forth between WSL versions... any updates here?

Same frustation and same behavior here...

@GearWalker
Copy link

I'm also working with embedded system build environment, really need this too!

@therealkenc therealkenc added the wsl2 Issue/feature applies to WSL 2 label Jun 7, 2020
@kategray
Copy link

kategray commented Jun 7, 2020

This is a huge blocker as well. Using WSL1 as a workaround, but there needs to be some way to get USB->Serial working on WSL2.

@all-chu
Copy link

all-chu commented Jun 19, 2020

Any updates on this? This is a showstopper for moving to WSL for embedded Linux development. There are issues with buildroot + WSL1 so that's not an option either.

@mkanet
Copy link

mkanet commented Jul 9, 2020

I guess I can forget about installing Home Assistant under WSL2 anytime soon. My HUSBZB-1-USB-HUB won't mount.

@ghost
Copy link

ghost commented Jul 17, 2020

Another vote for this, being able to attach serial over usb embedded devices to my docker containers would be a game changer

@shambodeva
Copy link

Bummer! I was happy to setup WSL 2 & install Ubuntu to build my project on linux. However i couldn't flash or access the serial/COM USB port from WSL 2. This feature is a huge blocker. Can you pull-in the device access support from WSL 1 immediately?

@dattrax
Copy link

dattrax commented Aug 2, 2020

I could really do with this to flash an embedded serial device.

@mastrolinux
Copy link

Arduino CIO here, as Arduino, we would like to contribute in making this happen. Allowing developers to work with WSL and Arduino boards would be fanstastic. As of now, our arduino-cli inside WSL does not allow people to see the list of the boards. Mainly related to #3099 and the closed one: #1929. Thank you for your great work!

@rickiewars
Copy link

I don't think it's possible to share a USB device across Windows and WSL2 (like you would be able to do in WSL1), either the host owns the USB device or it's passed through to WSL2 (like other VMs running fully fledged Linux kernel). But maybe providing a GUI for user to select which USB device they want to use with WSL2 is not a bad idea?🤔

This would be the solution I think and has been available in VirtualBox and KVM for years. Even through a command I should be happy with because it will be scriptable then.
Because the windows part is close source, Microsoft has to implement i themselves but they always can take some inspiration from KVM because the linux kernel is open source. It won't be an 1-to-1 comparison but I can't imagine the example is of any help at all.

I've switched to Linux full-time and virtualize Windows in kvm in case I need it because it seems that that gives me more options.

@milomai
Copy link

milomai commented Jul 4, 2022

just an idea:
in windows: turn serial to tcp (like com0com)
in linux: turn tcp to serial (like ser2net)

@charterchap
Copy link

The answer is in the post by @dobromyslov
to abbreviate:

ADMIN PS> wsl --update

PS> winget install --interactive --exact dorssel.usbipd-win

WSL> sudo apt install linux-tools-5.4.0-77-generic hwdata
WSL> sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/5.4.0-77-generic/usbip 20

# Open a new ADMIN PS
PS> usbipd wsl list
PS> usbipd wsl attach --busid <busid>

WSL> lsusb 
WSL> ll /dev/ttyUSB*
PS> usbipd wsl detach --busid <busid> # when you're done with your device

@ackshooerry
Copy link

Despite the finality of the most recent response, I don't think this issue is settled at all. I have followed all of the steps outlined here. I can see and attach my USB to serial adapter in PowerShell:

PS C:\WINDOWS\system32> usbipd wsl list
BUSID  VID:PID    DEVICE                                                        STATE
1-3    2c7c:0125  HighSpeed USB Composite Device (0008), Quectel USB DM Por...  Not attached
1-4    0bda:0129  Realtek USB 2.0 Card Reader                                   Not attached
1-5    067b:2303  Prolific USB-to-Serial Comm Port (COM8)                       Attached - Ubuntu-20.04
1-7    0bda:d723  Realtek Bluetooth Adapter, Realtek 8723DU Wireless LAN 80...  Not attached
1-8    058f:5608  USB 2.0 Web Camera                                            Not attached

I can see the USB device in WSL:

prompt:/dev$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

But when I list my TTY devices, I get:

prompt:/dev$ ls tty*
tty    tty11  tty15  tty19  tty22  tty26  tty3   tty33  tty37  tty40  tty44 tty48  tty51  tty55  tty59  tty62  tty9   ttyS3
tty0   tty12  tty16  tty2   tty23  tty27  tty30  tty34  tty38  tty41  tty45  tty49  tty52  tty56  tty6   tty63  ttyS0
tty1   tty13  tty17  tty20  tty24  tty28  tty31  tty35  tty39  tty42  tty46  tty5   tty53  tty57  tty60  tty7   ttyS1
tty10  tty14  tty18  tty21  tty25  tty29  tty32  tty36  tty4   tty43  tty47  tty50  tty54  tty58  tty61  tty8   ttyS2
prompt:/dev$ 

However, as seen above, this device is assigned to COM8 in Windows, so I would expect to see it as ttyS8 in WSL. Unfortunately, it isn't listed. As I read it, this is literally the exact same issue that was initially posted about here 3+ years ago.

I am running WSL2 on Windows 10, Ubuntu 20.04, Linux Core is 5.10.106.1.

@charterchap
Copy link

charterchap commented Nov 29, 2022

It will appear as ls -la /dev/ttyUSB* and will not correlate to the windows device in any way. The first you attach will probably show as /dev/ttyUSB0 although you clearly aren't getting that either. You can also try dmesg|grep tty to see if it has a device.
Also, use the ubuntu versions from the microsoft store you will have to change your kernel: https://github.com/dorssel/usbipd-win/wiki/WSL-support#building-your-own-usbip-enabled-wsl-2-kernel

@Eplankton
Copy link

I have exact same problem, have you found any solution yet? Please help me.

@joezappie
Copy link

@ackshooerry I also use prolific serial adapters, but from what I've tried the driver isn't included by default in the kernel. I did rebuild the kernel once and got my prolific adapters to work, but have since just bought FTDI USB serial cables as they work out of the box. Not sure if you did rebuild the kernel, or if that is these drivers are now included by default (last I tried was a few months ago).

@adeturner
Copy link

adeturner commented Jan 14, 2023

+1 Same issue - following the Pi pico install.
COM5 is not mapped to /dev/ttyS5, so minicom cant connect to it in Win10/WSL2
I tried usbipd, lsusb sees the device - no tty though

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 2e8a:0003 Raspberry Pi RP2 Boot
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

$ ls -l /dev/ttyU*
ls: cannot access '/dev/ttyU*': No such file or directory

$ ls -l /dev/ttyS*
crw------- 1 root root 4, 64 Jan 14 10:08 /dev/ttyS0
crw------- 1 root root 4, 65 Jan 14 10:08 /dev/ttyS1
crw------- 1 root root 4, 66 Jan 14 10:08 /dev/ttyS2
crw------- 1 root root 4, 67 Jan 14 10:08 /dev/ttyS3

$ dmesg | grep tty
# no output

@pwfff
Copy link

pwfff commented Jan 19, 2023

+1 here as well. Can't get my Prolific device to show up as /dev/ttyUSB* even though it's in lsusb. Guess I'm buying an FTDI cable because I've already spent too long on this and I sure ain't about to recompile my kernel for this...

@xanderificnl
Copy link

xanderificnl commented Mar 30, 2023

FWIW USBIP has worked wonders here..

windows> esptool.py erase_flash
"Access denied" # for a variety of devices; no other processes were using the devices & my terminal was elevated... 

installed USBIP & attach device to WSL

$ uname -a
Linux pc 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

$ ls -lah /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Mar 30 04:37 /dev/ttyUSB0

$ dmesg | grep tty
[  928.571117] usb 1-1: ch341-uart converter now attached to ttyUSB0

$ esptool erase_flash # 💩 
A fatal error occurred: ESP8266 ROM does not support function erase_flash.
$ esptool --help | awk '/^esptool.py/ {print $2}'
v2.8

# dockerage? sure, why not.
$ docker run --rm -t -i --device=/dev/ttyUSB0 espressif/idf esptool.py erase_flash
Chip erase completed successfully in 13.9s
^ writing requires sudo apparently.

@lsthiros
Copy link

This has been open for four years, rattling my inbox nonstop. Microsoft devs either needs to confirm that this is an intended major-feature removal and close the issue, or classify it as a major regression with known workaround (USBIP).

The silence on such a key feature is unacceptable, and the level disrespect towards the developer community shown through four years of silence is unbelievable.

Can we please have a triage statement from devs on where this issue stands, or at least what would be required from the community to develop a POR fix?

@lemonking77
Copy link

We really need this feature

@mkanet
Copy link

mkanet commented Jun 9, 2023

Just a note: Not everyone here has the skillset and/or motivation to jump through hoops installing usbipd-win, build their own USB/IP-enabled WSL 2 kernel, and try to get them to talk to each other.

I'm not even a developer... I'm just a regular guy who would like their USB dongle to actually work after installing Home Assistant. Currently, using it as VMWare VM on Win11.

@bwims
Copy link

bwims commented Jun 25, 2023

My guess is that Microsoft is using this as a lever to get people to upgrade to Win11

https://learn.microsoft.com/en-us/windows/wsl/connect-usb

Windows 11 is recommended for connecting USB devices to a Linux distribution running on WSL 2. However, Windows 10 can be used to connect USB devices by building your own USBIP enabled WSL 2 kernel following the [instructions in the USBIPD-WIN project repo](https://github.com/dorssel/usbipd-win/wiki/WSL-support).

@supleed2
Copy link

Even if it is, in both cases once you have a compatible kernel, you still need to use the usbipd-win project, which means running a command to pass through the device every time. It's not automatic at all as it was with WSL1. This is an issue on Win11 too.

@bwims
Copy link

bwims commented Jun 25, 2023

Even if it is, in both cases once you have a compatible kernel, you still need to use the usbipd-win project, which means running a command to pass through the device every time. It's not automatic at all as it was with WSL1. This is an issue on Win11 too.

I agree, but the point is, I'd be surprised if full USB support ever came to Win10, even if it eventually arrives for Win11. Yes, I am cynical but I do have reasons...

@slorquet
Copy link

Of course it is.

Who actually believes Microsoft is interested in Linux for the sake of advancing the free software community?

@koffes
Copy link

koffes commented Jul 6, 2023

I have read the entire thread, and I also join the bandwagon and ask if we can please get any timeline or news regarding this feature. The USBIPD is a nice workaround, but no replacement for native USB forwarding and multi-device auto-attaching which is present in VMware and VirtualBox.

@bwims
Copy link

bwims commented Jul 6, 2023

I've now installed VMWare, and it works perfectly well for my needs (Docker and access to USB devices)
EVEN BETTER, it uses NAT and DHCP to get a SENSIBLE IP address!

Sadly, it appears WSL1 and WSL2 are a waste of time for different reasons.

@jjclose
Copy link

jjclose commented Jul 6, 2023 via email

@adalava
Copy link

adalava commented Jul 6, 2023

I was enjoying WSL but I gave up and moved to Linux completely. I still have Windows installed on another partition since some tools are Windows only, but most Windows applications that use serial port are so simple that run fine under Wine on Linux.

@shadrqen
Copy link

shadrqen commented Mar 14, 2024

This guide will walk through the steps necessary to connect a USB device to a Linux distribution running on WSL 2 using the USB/IP open-source project, usbipd-win.

@jviskari
Copy link

jviskari commented Mar 15, 2024

Still workaround. This feature should be built in WSL.

@compnski
Copy link

I also gave up on windows and just use linux full time. https://www.codeweavers.com/crossover has been helpful in running any last software that regular wine didn't work with.

@crose72
Copy link

crose72 commented May 3, 2024

I actually followed the steps here https://learn.microsoft.com/en-us/windows/wsl/connect-usb and I had it working for both windows 10 and 11 from what I can remember. I haven't needed to connect my FTDI serial to USB converter to WSL2 for a while and I just followed my notes and it's no longer working. I can attach the device to WSL2, but it no longer shows up in /dev/ttyUSB0 anymore. How do I fix that?

@Clockwork-Muse
Copy link

@crose72 - You'll want/need to check the usbipd repo, likely.

Note that there are a number of issues with some specific serial chips, like this one, many of which stem from the default kernel not containing certain drivers - you may need to compile one yourself.

@crose72
Copy link

crose72 commented May 11, 2024

@Clockwork-Muse so it was working in July 2023 with my FTDI to USB, and I didn't change anything about my WSL2 setup so why would it just stop working?

@Clockwork-Muse
Copy link

I'm the wrong person to ask, unfortunately.

@crose72
Copy link

crose72 commented May 11, 2024

@Clockwork-Muse no worries, I'll try your suggestion all the same. Are there any FTDI to USB devices that you know work? If so I wouldn't mind getting one of those as a quick solution.

@mrv96
Copy link

mrv96 commented May 29, 2024

It seems that we have a solution for the issue of @crose72 (and mine): dorssel/usbipd-win#948 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature wsl2 Issue/feature applies to WSL 2
Projects
None yet
Development

No branches or pull requests