Skip to content

history

Vlad Iliescu edited this page Mar 20, 2017 · 1 revision

A bit of history on how I got to this solution

First thing first, due to various circumstances I used VMware to handle the make for ESP32. I tried the Windows toolchain but is seemed kid of meh.. plus I'm not a big fan of MSYS and it seemed kind of lazy to me. All in all I had to stick to WMware and Ubuntu 16.04 for a while.

Until one day it struck me that some time way back, when Windows 10 was still launching, they presented Bash for Windows. And so it begun...

So I installed the bash, configured it, added the toolchain and environment, all ready and working, I had a working make env. Perfect until now...

Here I had the idea to just use bash -c "<command_with_make>" from my IDE, then add all the steps in the build routine and have everything working from a button (more like a shortcut.. but hey... still...).

And there it was my first mistake. I had just assumed that everything would work as expected. The first thing I did was to run the command in a cmd. All well and dandy, worked like a charm. Added the commend in the IDE tools.. bum.. there it was Error: 0x80070057. After long hours of Google, trial and error, running it from cmd with different output captures, running it from PowerShell also with different strategies, I reached the conclusion that you cannot redirect any output of the bash.. in any way except the console. What did this mean is that if I were to do something will have to be in a console output.

OK I thought, I'll just write a small batch file and that's it. Until then I can still use my new found Ubuntu on Windows. First make.. all good.. go for make flash monitor.. cannot locate /dev/ttyUSB0.. OOOOK.. where is my USB.. Is the cable ok ... do I need special drivers.. nope!..

Turn out that Bash on windows does not support removable drives (maybe add a vote here). I though to myself: Hey flashing is still done by a python script, maybe it can run on windows. So I copied the command that the make spits out at the end to an open PowerShell (remember this for later :P) and it worked like a charm. To mentioned I had previously installed python 3.6 and pyserial via pip.

Perfect, I now have all the ingredients I need to write a primitive script that runs make on Ubuntu and then run flash and monitor on Windows. So I got to work..

Some time later the esp32-make.bat was ready. Time to test it. esp32-make all (bash -l -c "cd /esp/project/path && make") runs great. For the flash I just hardcoded the python flash command in the *.bat file. Run esp32-make flash... instant timeout... whaaaat?!?... But it did work previously. Run the command again, this time in cmd.. same result.. instant timeout. Ok.. run the script from PowerShell esp32-make flash.. again fail. DO DEBUG!!.. check spelling... check again with comparator (:D). Nope... Then in a desperate act a run the bare python command in PowerShell... It works!!

Again turns out I had made two mistakes.. First is the obvious one.. I tested the script in a PowerShell before writing the script. Second is that I had no knowledge that a *.bat file always runs the command in a cmd environment even if you run it from PowerShell.

I this point it was clear to me that if I ever wanted a script to run it will have to be a PowerShell script. I begun sketching the script, command by command, make all to make flash only the minimum necessary. It all seemed to work. I even changed the make monitor to run in cmd env so that the pretty colored text is displayed nice.

From here on you can check the git to see the features and commit history. Only small things, Even found a way to share output between Ubuntu and Windows by using a file. (check the commits :P).

So here is how I ended up learning PowerShell and using it for my ESP32 project with no more VM, no dual boot Ubuntu.. nothing.. just the plain ol` Windows (:D) and Bash for Windows.

Clone this wiki locally