Programming ESP8266 with the Open SDK – Intro

Esp8266 boards

Bought a ESP8266 just to use it paired with Arduino? Too bad!
For less than 5 euros, it packs a 32 bit general purpose CPU and everything you need for WiFi connectivity (TCP/IP stack, WEP, WPA etc.) and 16 GPIO.
It is generally accompained by a flash memory which contains the firmware. It is really a lot of power in a small footprint!
Information is scattered everywhere though, it can be daunting to learn it as a first platform so I recommend some previous experience with programmable boards. If your only experience is Arduino, hooray! Hopefully you’ll be learning something new without much swearing as I did instead.
I’ll do my best to be comprehensible and not boring, and to keep everything in one post (or series of posts) updating as I learn more.

The CPU can be booted in three different ways:
Flash Mode, default booting mode. Firmware is read and executed from the flash memory;
UART Mode, used to program our board (through a Serial-to-Usb adapter);
SDIO Mode, loads firmware from an SDIO card?
Switching from a mode to another requires to reset the module while changing pin configuration as shown:


There are two UARTs and 16 GPIOs (PWM capable), it is even capable of JTAG debugging, though I haven’t got the opportunity yet to know how.

Some functionalities (like OTA updates, SDIO booting) are covered more deeply in documents only available by signing a Non-disclosure Agreement with Espressif Systems. More info can be found here.

As soon as I read first posts describing all his capabilities my mind started wandering! Most examples found on the internet though uses the AT firmware included in the Espressif Esp8266 SDK as an example. AT commands are issued via UART, so that it can be used as a cheap WiFi antenna paired with some other board.
But custom firmwares can be built with the proper toolchain and loaded into the MCU with a Serial to USB adapter.

I installed the (mostly) Open SDK by pfalcon that takes credit for actually simplifying the process while being more open than the Espressif one. Installation process consists in

apt-get install make unrar autoconf automake libtool libtool-bin gcc g++ gperf flex bison texinfo gawk ncurses-dev libexpat-dev python sed
git clone --recursive
cd esp-open-sdk/

The added dependency, libtool-bin, is for Debian Jessie. After installing the chain (let’s say under /opt/esp), you can start right away by creating a folder under sdk with the name of your project.

Under user/ goes the user_main.c file, that contains the main routine:

void user_init(void)

In include/ you can put every header file, though many projects prefer distinction between “your” headers (which go there) and other libraries that go in the driver/ directory.

Enough talk for now, in the next post we’ll wire it up and start programming!

Leave a Reply