Skip to content

Flashing Micropython to an ESP8266

Gijs Mos edited this page Nov 17, 2019 · 3 revisions

Preparations

  1. Make sure you have Python3 on your computer. Test this with typing "python -V". Is should respond with "Python 3.x.y". If you don't have it, get it installed.
  2. You also require Pip. It should come with Python3. You can test this with "pip -V". At the end of the output it should report "python 3.x".
  3. Next you need to install esptool. If you have pip working you only need to run "pip install esptool". If you like the gory details, the esptool documentation and sources are here: https://github.com/espressif/esptool. But you normally won't need them. You can test if you have it with 'python -m esptool'. It should print you a mini-manual. Depending on your environment, just typing 'esptool.py' also may do the trick.
  4. Finally you need to get the last Micropython binary for your Sensemaker's 8266a board. You can download it from firmware-combined-<some version>.bin from github.com/sensemakers/micropython/sma8266a_python. In normal cases take the one with the highest version number.

If you are using an OBA laptop at a Sensmakers workshop, steps 1 - 3 will already have been taken care of. You can verify this if you want as has been described.

Uploading Micropython to your board

  1. Connect the board to your computer via USB
  2. Find out what the assigned port number is. The procedure varies per operating system.
    • On Windows 10 you should use the Device Manager and look in the Ports tab. It may look like "USB-SERIAL CH340 (COM17)". In this example the COM17 is what you need. But the 17 can be any number.
    • On WSL under Windows you still look up using Device Manger. You will find COMxx. You then need to use /dev/ttySxx. SO you take the COM port number and append it to /dev/ttyS.
    • ToDo - Add other port schemes for Linux generic, Linux RasPi and Macintosh.
    • There is a trick you can use on all platforms, if you have the Arduino IDE up and running. Open it and look at the Tools->Port menu. It will give you the available ports in a neat list. When you have found the port you need you cab close the Arduino IDE. You won't need it further.
  3. The SMA8266a board needs to be put into programming mode manually. Other boards (WiMos Mini and most ESP32 boards for instance) may do this automatically. Just try if you have a different board.
    To enter flash mode manually:
    • press and hold the boot switch,
    • press and release the reset switch and
    • finally release the boot switch.
  4. Next run the command "python -m esptool --port <whatever found in step 2> erase_flash". This will erase everything on your board, including all your stored files. So if you are upgrading Micropython and you want to keep existing files, get them off the board first! But if this is your first time, no worries...
  5. Now that the board has been emptied, we are going to write the new Micropython. Repeat step 3 to get the board again into programming mode.
  6. Then execute "python -m esptool --port <whatever found in step 2> write_flash 0 firmware-combined-<some version>.bin". This will write the Micropython runtime to the board.
  7. When finished press the reset button on the board to get Micropython going.

Time to start using Micropython. To test the installation you can connect a terminal to the board as will be explained in Using the repl. By the way, repl means Read-Eval-Print-Loop. It is a way to type commands to Micropython and see the results on your laptop.