espflash icon indicating copy to clipboard operation
espflash copied to clipboard

espflash on WSL 2 (with usbipd) doesn't work

Open dom96 opened this issue 1 year ago • 6 comments

I've successfully flashed my ESP32 via other tools in WSL 1, but espflash does not work for me (even if I try it with usbipd set up on WSL2).

Here is what I'm seeing:

$ sudo usbip list -r 172.19.96.1
Exportable USB devices
======================
 - 172.19.96.1
        1-7: Silicon Labs : CP210x UART Bridge (10c4:ea60)
           : USB\VID_10C4&PID_EA60\0001
           : (Defined at Interface level) (00/00/00)
           :  0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00)

$ sudo usbip attach -r 172.19.96.1 --busid=1-7
$ sudo usbip port
Imported USB devices
====================
Port 00: <Port in Use> at Full Speed(12Mbps)
       Silicon Labs : CP210x UART Bridge (10c4:ea60)
       1-1 -> usbip://172.19.96.1:3240/1-7
           -> remote bus/dev 001/007
$ espflash board-info
Error: espflash::no_serial

  × No serial ports could be detected
  help: Make sure you have connected a device to the host system. If the device is connected but not listed, try
        using the `--list-all-ports` flag.

Am I missing something or should this work?

dom96 avatar May 26 '24 20:05 dom96

Hi! Have you tried the --list-all-ports flag as suggested by the error message? I'm not a Windows user, but I know some colleagues are using WSL2 with no issues.

SergioGasquez avatar May 27 '24 09:05 SergioGasquez

Yep, I have. It doesn't change the output.

dom96 avatar May 27 '24 13:05 dom96

Also FWIW it's working just fine in Windows PowerShell.

dom96 avatar May 27 '24 13:05 dom96

I've successfully flashed my ESP32 via other tools in WSL 1, but espflash does not work for me (even if I try it with usbipd set up on WSL2).

My setup is:

  • Windows 10 Home
  • usbipd v.4.2.0 installed (Windows side)
  • WSL2 (Ubuntu 22.04.4 LTS by lsb_release -a)

Have you tried attaching the device completely from Windows side, i.e.

> usbipd attach --wsl -b 1-7

I don't ever (need to) do usbip on the WSL side. In particular, espflash board-info works for me with the above setup, and ESP32-C3-DevKit-RUST-1 (chip rev 0.4) board.

akauppi avatar Jun 12 '24 08:06 akauppi

..if that doesn't help, I would try installing the CP210x Universal Windows Driver (v.11.3.0) on Windows side from here.

I can see you are using a standard UART (not JTAG) connector. Could it be that even though WSL properly lists it as "Silicon Labs : CP210x UART Bridge", it'd still need a driver on the Windows side?

akauppi avatar Jun 12 '24 08:06 akauppi

..if that doesn't help, I would try installing the CP210x Universal Windows Driver (v.11.3.0) on Windows side from here.

I can see you are using a standard UART (not JTAG) connector. Could it be that even though WSL properly lists it as "Silicon Labs : CP210x UART Bridge", it'd still need a driver on the Windows side?

Exactly same problem for me.

Eplankton avatar Sep 07 '24 17:09 Eplankton

I solved this by enabling systemd based on usbipd-win/issues/948#.

In WSL2, create or edit /etc/wsl.conf and add the following to it. Source: https://learn.microsoft.com/en-us/windows/wsl/wsl-config#systemd-support

[boot]
systemd=true

wsl.exe --shutdown from the Windows side and now the device is recognized in WSL2 Debian after running usbipd attach --wsl --busid <busid> as ttyUSB0.

parsiya avatar Oct 13 '24 01:10 parsiya

Closing this as a solution was found, however I have opened https://github.com/esp-rs/espflash/issues/728 so that we don't forget to document this for people who may run into this problem in the future.

jessebraham avatar Jan 20 '25 13:01 jessebraham

I solved this by enabling systemd based on usbipd-win/issues/948#.

In WSL2, create or edit /etc/wsl.conf and add the following to it. Source: https://learn.microsoft.com/en-us/windows/wsl/wsl-config#systemd-support

[boot]
systemd=true

wsl.exe --shutdown from the Windows side and now the device is recognized in WSL2 Debian after running usbipd attach --wsl --busid <busid> as ttyUSB0.

@parsiya Thank you for this. This fixed the error I was getting in my wsl

korir248 avatar Mar 09 '25 12:03 korir248