How to program my ESP32 using WSL2?

leofabri
Posts: 9
Joined: Wed Feb 19, 2020 3:36 pm

How to program my ESP32 using WSL2?

Postby leofabri » Wed Feb 19, 2020 3:57 pm

Hello everyone, I need some help figuring out how to program ESP devices using WSL2.
I'm can compile the code on Ubuntu running on top of WSL2 but I'm still having difficulties flashing and monitoring the builds to my peripherals because as we all know, serial devices are not currently recognized.
Just to clarify, I know that it is possible to flash ESP devices directly through Windows, nevertheless, being Ubuntu my first choice when it comes to development, I would love to get it working on WSL2 (which happens to be way faster at compiling source code compared to WSL1) :roll:
I heard that there are some "hacks" that allow us to flash ESP devices by tunneling the COM connection to a TCP one. I tried to do that using "socat" on WSL1 which can interact with ttySX ports quite easily but that doesn't seem to work.

I tried to issue on my WSL1 distro:

Code: Select all

socat -d TCP4-LISTEN:1367,reuseaddr,fork /dev/ttyS3,raw
and then on WSL2:

Code: Select all

idf.py flash --port socket://<ip_of_my_machine>:1367
but I get:

Code: Select all

A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x30)
At this point, I started to become more skeptical about this tunneling strategy, but when I issued

Code: Select all

idf.py monitor --port socket://<ip_of_my_machine>:1367
everything worked. So, at this point, it looks like I'm unable to write the data to the ESP but I can read it without any problem.
___

Maybe I'm missing something but I'm not sure. I cannot find much documentation on the web and I don't know if this is the way to go. Some help would be appreciated.

ESP_Sprite
Posts: 9759
Joined: Thu Nov 26, 2015 4:08 am

Re: How to program my ESP32 using WSL2?

Postby ESP_Sprite » Wed Feb 19, 2020 7:40 pm

You could possibly get away with this, but the reset and jump to bootloader are normally done with handshaking lines which won't be forwarded by socat. If you manually pull GPIO0 low, reset the ESP32 and try to upload, it might work.

matevarga
Posts: 1
Joined: Sun May 31, 2020 2:04 pm

Re: How to program my ESP32 using WSL2?

Postby matevarga » Sun May 31, 2020 2:05 pm


Who is online

Users browsing this forum: Bing [Bot] and 128 guests