How to Build the NodeMCU Firmware using BoUoW

By October 21, 2016ESP8266, IoT, Linux, Windows

The Windows 10 Anniversary Update includes the Windows Subsystem for Linux, as I had mentioned in a previous post. The Bash shell (succinctly named “Bash on Ubuntu on Windows”, or BoUoW if you’re actually trying to search for information) permits native Linux ELF64 binaries to run on Windows. It’s pretty clever, but a little limited in areas.

So, I wondered: since Linux is the preferred first-class build environment for ESP8266 firmware, can I build the NodeMCU firmware using BoUoW? Let’s find out!

First, you will need to activate the feature and install BoUoW. Refer to the instructions and/or Scott Hanselman’s video for details.

Next, make sure that the Linux environment is up to date:


Now we need to install the Build Essential tools, git, and zip (needed to make the NodeMCU firmware):


Next, decide where you want to install the toolchain. I like to use the /opt directory:


Johny Mattsson, one of the key contributors to the NodeMCU Firmware project, has a pre-built toolchain available on GitHub. This saves a great deal of time and complexity of trying to build the toolchain locally. So, use Git to clone that repository:


You will also need the NodeMCU Firmware source code (and make the folder writable):


When the project is built, new directories and files have to be created, so let’s make the current user the owner so that Linux will permit that. First, find out the username that BoUoW thinks you are (this is one that you would have created when you installed Bash – it is not necessarily your Windows username):


Next, substitute that username in this command to recursively set the owner of the directory tree:


You need to add the toolchain’s bin directory to the PATH environment variable. One convenient place to do this is within your .bashrc file so that it takes effect every time that you start BoUoW. Edit the file using:


Then add this line to the end:


Use Ctrl-X to exit, and answer “Yes” to all of the prompts in order to save over the existing file.

Close the shell window and open it again to log in. Now the PATH variable should have your modifications:


All that’s left now is to build the firmware:


The resulting .bin files will be located in /opt/nodemcu-firmware/bin. They get flashed to 0x00000 and 0x10000 on the ESP8266. Normally on Linux, you would just use to do this, but the Windows Subsystem for Linux does not yet support access to the Windows COM ports. So, at this time, the workaround is to copy the files from BoUoW to the Windows filesystem (located at /mnt/c/), and then use tooling from Windows to flash the binaries.

The good news is that it is indeed possible to build ESP8266 firmware on Windows using the Linux tooling without requiring a virtual machine!

The following two tabs change content below.