Setup a development environment for ESP8266


Abstract : Setup an ESP8266 dev board, taking advantage of it USB/UART interface to flash new native applications/firmwares (and, possibly, bootloaders?).

Context and expectations

So I recently order a “NodeMCU devkit”, and here it is :

My NodeMCU devkit board model, very same revision (image from Big Dan’s Blog)

To me it looked to provide what I basically expects from ‘Arduino’ boards : an MCU breakout, and some USB/UART connectivity through an FTDI-like chip (UART to USB), allowng programming the chip. It is even supported in Arduino IDE, but, let it to the noobs.

What I want with ESP8266 is to code in C(++) some custom firmware application, using my favorite editor and tools, build it through a makefile, and upload with a convinient command, (possibly using ‘make upload‘, as do with my duino, given the USB device is specified in the project’s makefile).

But dude, why the $#*& do you want to use this MCU ?

it integrates WiFi, as you can see on the picture.

  • it’s harvard architecture internally, like an AVR (but uses Instruction RAM — and ROM for storage — instead of fetching from program flash).
  • Also can run external program, but slower, since it needs to fetch instructions from external storage.
  • It’s 32-bit (arduino’s AVR are 8-bit), runs at 80 MHz (most 8-bit AVR are –officially– limited to 20MHz, and Arduino boards are clocked @16MHz),
  • It has 64 KiB of instruction RAM, 96 KiB of data RAM, where atmega328p (Chip of Arduino Uno) has 32KiB ‘PGM’ flash for code and 2KiB data RAM

Read more about this chip on wikipedia

The core CPU is far superior to 8-bit AVR one, as sold by Atmel.

At exactly the opposite of what most hobbists are doing ; i.e. using Espressif native firware of the ESP as a back-end peripheral, sending textual command to it from an Arduino-lib “powered” 8-bit AVR, through a 115200 (or even 9600 — sick !) bauds link…

On my side I want to takeover the chip firmware ! And maybe, but only if needed, use AVR8 as an “auxilliary” chip. I still like AVR and will use it in my first PCB design, when I’ll have finally learned to use KiCAD and enough time to implement the prototype. Also, AVR8 is still the best choice for  low power designs (IMHO).

What is needed step-by-step

I browsed, swimmed and sometimes sank in the massive database about ESP8266 provided by the WWW… First hours browsing for this chip are information overwhelming. After few time, one learns to recognize what is dedicated to him, what could be, what is definitively not. And enventually found a path that seems correct to reach my goal.

There are  alternative solutions (using native SDK, etc…) but the setup I describe below is (hopefully, but please let me know your feedback if any) the most “open source” flavoured one, for a greater control from the poweruser on the hardware.

Factually ; it’s easy as a piece of cake :

Install the toolchain

Just clone esp-open-sdk and build it with make. NodeMCU (the tag on the board sayed “nodemcu”, so it was my starting point) tutorial was recommanding to use :


option, so I get suspicious about it, and noted from the wiki that as :

This is the default choice which most people are looking for, […] just [typing make] is enough.

Ermmm. Nope. Just… let me think : Nope.

We are fucking freaks using ArchLinux, not in a virtual machine, futhermore ! We are not “most people“, we want a toolchain that integrates plainly in our GNU system, as avr-gcc does already for arduino-board based developments.

Then, make STANDALONE=n is the command we want for us.

As I read in some wiki : << get prepared for a long build session, so better got a coffee >>

Let me add : and possibly a marijuana cigarette….

.oO°(   yes, even with a good connection, you will squeeze and scratch it down before the build completes, and will have time to talk to the elves. To the elves ??? That was DMT, not marijuana, dude !    )°Oo.

Anyway, 10 minutes later (yes hours, ok, dude), back on good old Gaya planet, we can acheive the second step :

Note for the noobs

HINT : after that, either make install, or simply add a


line into your /etc/bashrc ; ~/bashrc or any script that setups your env.

NB : If your don’t understand what you have do now, press ALT-F4 for more help.

Install an SDK

I choosed esp-open-rtos because it’s an open source implementation, the only one I noticed to emerge among the “noise” about ESP in the first hours. Also it seems active (they have a chan on freenode, #esp-open-rtos).

I’m still learning, but so far I still consider this is, at least, a powerful solution that meets perfectly the needs I expressed formerly.

Just go to their well done github repository, the homepage’s explains almost everything (and has good links, wiki…)

I was able to seamlessly use the repo examples/, and I tested (all worked more or less) :

  • serial_echo (first flashing ever),
  • access_point (setup an access_point, and serves a minimalist ‘hello world’ telnet),
  • get_http (fetches a single, simple HTTP page each 10s, reports # success/failure)

The ONLY exception is that the access_point example did not take in account the SSID and keyword I #defined in the source code… Exposing a generic “ESP_” SSID and no security.

is  — That’s the ONLY point that didn’t work (but I did no debug on this so far).


I was used to setup the tty device in the project custom makefile, this SDK ask it to be on the command line (ESPPORT=/dev/ttyUSBx). What a change !

To upload the program build the commaand is not the “make upload” i’m used to type but “make flash“.

I’ll go to Arkham because of this very little tweak, i’m sure ! And that’s obviously one of the Joker’s tricks…

Postscriptae :

Nota buene : postscribere is a verb (meaning “to write after”), which postscriptum is the past participle. The word “postscriptae” itself is a joke — just like scriptus was a noun, and scriptae its plural — indicating I anticipate numerous editions of the post ;°)

And… After some research, it turns out the correct terms is likely to be postscriptos.

EDIT 1 : 29/11/2016

Eventually, it is more head-hache prone to find one’s own way in this world.

First, in my opinion, esp8266 user are in big majority Arduino users (but hardcore noobs ! lol, it’s not evil, I love them too). It’s annoying when searching/browsing the web, because you can’t even filter out the arduino word. So it’s false-positive/non-relevant result overwhelming. I did not try esp-open-rtos so far, just basic examples esp-open-sdk (non-os sdk API) compilation and flash (and tweak, and reflash, and…).

Another pitfall I did not foresee, was how to flash a specific module, given its memory map. is only semi-automated at that point, and does not the deduction for you, while I guess it could. There is a serious learning curve about correctly flashing the device. So far I limited my tests to the simpliest scenario, no serious multi-stage-bootloading, and further, no OTA udpate done yet.

Currently, i’m trying to compile esphttpd ; the aim being to reuse the libesphttpd in other projects, as it seems the top of the state-of-the-art (…not quite sure of that, but it is still a good piece of software anyway — still experimental though, I’m struggling with compilation problems right now…).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s