manintheit.org

manintheit.org


Share Serial Devices with WSL Machine

usbipd-win is a project to share serial devices with WSL machine. (Windows Subsystem for Linux).

It is highly useful when you develop embedded systems on Windows hosts inside WSL machine.

  • Download and install usbipd MSI Package in GitHub releases page.
  • Run CMD Prompt as Admin(Run as Administrator)
C:\Windows\System32>usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
1-4    0489:e0e2  MediaTek Bluetooth Adapter                                    Not shared
2-1    1a86:7523  USB-SERIAL CH340 (COM4)                                       Attached
4-1    05ac:12a8  Apple Mobile Device USB Composite Device                      Not shared
5-1    3277:0033  USB2.0 FHD UVC WebCam, USB2.0 IR UVC WebCam, Camera DFU D...  Not shared
7-3    046d:082d  HD Pro Webcam C920                                            Not shared

In this example, I want to share USB-SERIAL device in order to program ESP8266 chip.

Bind Serial Device:


C:\Windows\System32>usbipd bind  -i  1a86:7523
usbipd: info: Device with hardware-id '1a86:7523' found at busid '2-1'.

Attach Serial Device into WSL:

C:\Windows\System32>usbipd attach --wsl -i  1a86:7523
usbipd: info: Device with hardware-id '1a86:7523' found at busid '2-1'.
usbipd: info: Using WSL distribution 'Ubuntu' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Detected networking mode 'nat'.
usbipd: info: Using IP address 172.19.144.1 to reach the host.

dmesg message on WSL(Ubuntu)

[ 6188.974470] usb 1-1: SetAddress Request (2) to port 0
[ 6189.019112] usb 1-1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.54
[ 6189.019130] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 6189.019134] usb 1-1: Product: USB2.0-Serial
[ 6189.050824] usbcore: registered new interface driver ch341
[ 6189.050843] usbserial: USB Serial support registered for ch341-uart
[ 6189.050857] ch341 1-1:1.0: ch341-uart converter detected
[ 6189.064874] usb 1-1: ch341-uart converter now attached to ttyUSB0
[ 6250.842958] vhci_hcd: unlink->seqnum 6680
[ 6250.842963] vhci_hcd: urb->status -104
[ 6250.843465] vhci_hcd: unlink->seqnum 6681

As you see, serial device is attached to WSL as ttyUSB0



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.