ESP8266: using Docker to setup the build tool chain the easy way

When you get started with wonderful world of the ESP8266 your first step might have been to play around with the AT command firmware. Then you might have chosen one of the pre-built multi purpose firmwares, such as the NodeMCU or the NodeLua image. Then, the next logical step is to build a firmware yourself. But honestly, I was a bit afraid of this one, since it seemed all very Linux oriented and I wanted to run it on my Mac. Until I found zoobab’s Dockerfile. I had heard about Docker before but never used it myself. This tutorial will walk you through the whole process from “Nada to Tadaa!”

1. Install docker

Since docker is only truly native on Linux you might want to use another tool to get docker running under Windows and Mac OS X. It’s called boot2docker and uses a tiny Linux image running inside VirtualBox to get docker running on your non-linux OS. 
Go to http://boot2docker.io/ and download the version for your operating system and run the installer.
Note: while this worked without any problems on my Mac I had some (still unsolved) issues on Windows 7. Probably they were caused by pre-installed Git and VirtualBox. If possible remove these two applications before you install boot2docker and let the installer take care of re-installing them.
To test the successful installation run:

docker run hello-world

from the boot2docker command line.

2. Create the docker container

If you didn’t have git before starting this walkthrough you will have now: boot2docker should have installed it. That’s why you can now execute

git clone https://github.com/squix78/esp8266-docker-buildbox.git
cd esp8266-docker-buildbox/
docker build -t local/buildbox .

This last step might take a while (or two): in my case it took almost 20 minutes. But the good thing is that you’ll only have to do it once.

Related:  ESP8266 Products Hitting the Market

3. Run the docker container and compile your first firmware

Now it’s time to start the container:

docker run -i -t local/buildbox /bin/bash

Will start the container. Now you get to compile your first firmware by

su - esp8266
cd source-code-examples/blinky/
make
If everything worked out you’ll have to files in the firmware folder: 0x00000.bin and 0x40000.bin! Congratulations, you just built your first ESP8266!

Note: Now you’d still have to get the images somehow to your ESP8266. I will update this post shortly and describe how you can do that…

Now a beer! Did you like this post? It often takes me several hours of my free time to write one. If I was your neighbour would you offer me a beer for the hard work I did for you? The beauty is: beers can be teletransported with a painless donation using Paypal. A beer in a Swiss bar costs about USD $4.80. Or use this affiliate link if you order something on Banggood and I'll get a small kickback. Thank you!