Notes on using Windows Subsystem for Linux with ESP-IDF

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Notes on using Windows Subsystem for Linux with ESP-IDF

Postby kolban » Sun Oct 22, 2017 10:47 pm

The great news is that the latest versions of Windows 10 support excellent integration between a Linux distribution and windows. Here are some of the core links:

https://msdn.microsoft.com/en-us/commandline/wsl/about

What this means for us in ESP32 land is that we can configure Windows Subsystem for Linux (WSL) and instantly open an shell prompt. In that shell prompt, we can install an ESP-IDF environment including the tool chain and build ESP-IDF applications. We can also access the COM/serial port and flash to the device. Within WSL we can access the Windows file system meaning that we can use Windows based editing tools (eg. Eclipse or Visual Studio ...) and perform our editing.

This appears to be first class integration between Windows and Linux and (opinion) should mean that there should be little use for tools that attempted to provide a Posix environment in windows on Windows itself.

In tests, no significant problems were found. The worst was attempting to perform parallel builds with "make -j5" which seemed to fail non-deterministically.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Lucas.Hutchinson
Posts: 79
Joined: Tue Apr 26, 2016 5:10 am

Re: Notes on using Windows Subsystem for Linux with ESP-IDF

Postby Lucas.Hutchinson » Mon Oct 23, 2017 7:11 pm

I have tinkered with it before, and it seemed to work well for me.

The only major problem that i encountered is that when cloning all the source code, it needs to be cloned with Linux line endings (yes sounds obvious i know), as i found it would not build with the windows style line endings. (where the MSYS32 environment will).
Not really a big deal, but could be a trap for new people.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Notes on using Windows Subsystem for Linux with ESP-IDF

Postby ESP_Angus » Tue Oct 24, 2017 7:19 am

Lucas.Hutchinson wrote: The only major problem that i encountered is that when cloning all the source code, it needs to be cloned with Linux line endings (yes sounds obvious i know), as i found it would not build with the windows style line endings. (where the MSYS32 environment will).
Not really a big deal, but could be a trap for new people.
That's interesting, thanks Lucas. We actually run a test as part of our Continuous Integration (on Linux) that an example can be built with all of the IDF code switched to windows line endings. It seems odd that this doesn't carry over to the Linux Subsystem for Windows.

Do you recall what the failure mode is?

chegewara
Posts: 2230
Joined: Wed Jun 14, 2017 9:00 pm

Re: Notes on using Windows Subsystem for Linux with ESP-IDF

Postby chegewara » Tue Oct 24, 2017 6:32 pm

Im just starting to play with it. Most time took me to upgrade windows 10 before i could install ubuntu. I have windows 10 pro (bought legit genuin key for less than $8). First try was hello world example from esp-idf and compiled and flashed with no problem. One thing i have had to figured was serial port. Under WSL it will be /dev/ttySx, where x match comX under windows. But before we flash we need to change permissions on this port with sudo chmod 666 /dev/ttySx.

Compiling with make -j makes my CPU hurt, but my laptop with intel E3 can handle make -j3.

Lucas.Hutchinson
Posts: 79
Joined: Tue Apr 26, 2016 5:10 am

Re: Notes on using Windows Subsystem for Linux with ESP-IDF

Postby Lucas.Hutchinson » Tue Oct 24, 2017 7:18 pm

I am not exactly sure what the failure mode was. It was about 2-3 months ago. I am not 100% sure it was line endings, it could have been something else. i just remember re-cloning m code and the idf using the WSL git to a new folder let me build.

I have since mostly just relied on the pre-compiled toolchain, or switching over to a full linux install and building in there.

One other thing to note: I find linux (and to a lesser extent WSL) to be much faster to do a full re-build than on the pre-compiled toolchain.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Notes on using Windows Subsystem for Linux with ESP-IDF

Postby ESP_Angus » Wed Oct 25, 2017 3:30 am

Lucas.Hutchinson wrote: One other thing to note: I find linux (and to a lesser extent WSL) to be much faster to do a full re-build than on the pre-compiled toolchain.
Yes, MSYS2's additional layers to support *nix APIs on Windows causes us a big performance hit. The main impacts seem to be forking new processes and filesystem access. We've been looking for better solutions to this.

We've also noticed WSL is better but due to its filesystem translations it's not as fast as native Linux (or possibly even in Linux in a VM, depending.)

Who is online

Users browsing this forum: No registered users and 180 guests