About

MicroPython on ESP8266

This tutorial features topics on How to get started on MicroPython. We will use the same NodeMCU Dev Board from AMICA for the tutorial since it helps in easy deployment of code. You may check the previous tutorial.
Being a new project,it is recommended to build the micropython firmware from the latest source.You may check the kickstarter campaign to know more on how the ESP8266 port came to life.If you need an old firmware you may go the official download page.


MP ESP12
Image Source : https://i.ytimg.com/vi/mq0nRgQIxj0/maxresdefault.jpg

Setting Up SDK

We will need OpenSource ESP SDK tool chain to build the binaries.You can find more about the SDK from here.

  1. To ensure that the depedencies are installed.
    sudo apt-get install make unrar-free autoconf automake libtool gcc g++ gperf flex bison texinfo gawk ncurses-dev libexpat-dev python-dev python python-serial sed git unzip bash help2man wget bzip2 libtool-bin
  2. Clone the source
    git clone --recursive https://github.com/pfalcon/esp-open-sdk.git
  3. Move to cloned directory.
    cd esp-open-sdk
  4. Build the SDK.
    make
    The process will take several minutes. It took me 30 minutes so please wait for the process to complete
  5. Add path for the bourne shell to find the program
    export PATH=/home/akshaim/Documents/ESP8266/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
    The program is located in xtensa-lx106-elf/bin hence please make sure that you give location as in your system

Building and Uploading Firmware

    We will now try to build/crosscompile the binaries from source.You can find more about micropython source from here. Before proceeding ensure that your working directory is esp-open-sdk.

  1. Clone the Micropython repository
    git clone --recursive https://github.com/micropython/micropython.git
    Now you will have micropython folder created inside esp-open-sdk folder.
  2. Change Directory
    cd micropython
  3. To add external dependencies
    git submodule update --init
  4. Build the cross compiler
    make -C mpy-cross
  5. Change directory
    cd esp8266
  6. Make
    make axtls
  7. Make the bin
    make
    The output will be a file named firmware-combined.bin located in esp8266/build
  8. Change Directory
    cd build
  9. Upload the code
    esptool.py --port=/dev/ttyUSB0 --baud 460800 write_flash -fm=dio -fs=32m 0x00000 firmware-combined.bin
    For more details on using ESPtool please refer my previous tutorial

>