MicroPython – MicroPython compiling for ESP8266

After using in some examples the MicroPython firmware on the ESP8266 board

MicroPython – Nodes examples with DHT11, Relay and MQTT

this article shows how to generate the MicroPython firmware for the ESP8266 board.

The operating system used for this task is Debian 9, already encountered when we analyzed  the esptool utility

MicroPython – Python on embedded devices

Log on  with the operating system user on Debian 9, sviluppo in our case; under the home folder  create the Micropython folder and inside this folder the  esp8266 folder

The MicroPython source code is available at the following link

Github Micropython

Instructions to build the firmware for the ESP8266 are available at the link

MicroPython esp8266

Clone the repository

Download the cross compiler, as described here

Cross compiler

As indicated in the link above, download the source of the cross compiler always from the folder esp8266

Install the prerequisites for building

Proceed to the build of the cross compiler with the following commands

At the end of the build add the binary folder of the cross compiler to the PATH envinronment variable

Go into the micropython folder available under ~/Micropython/esp8266

Run

to add external dependencies.

Next step is the MicroPython cross compiler build

Finally we can build the ESP8266 firmware with the following commands

The firmware is generated under ports/esp8266/build folder with the name firmware_combined.bin.

Proceed to load the firmware with the command

where  /dev/ttyXXX is repalced with the actual serial port to which we connect the ESP8266 board.

In our case, the firmware upload was successful with the command

It is also possible to load the firmware_combined.bin image with the command

In the next article we’ll  analyze how to build the MicroPython firmware adding into the image additional MicroPython modules

MicroPython – MicroPython compiling for ESP8266 with additional modules