In the previous tutorial, we were able to test the firmware MicroPython which is now pre-installed by default on the Wemos LoLin32 Lite. The MicroPython firmware is available for many micro-controllers. The pyBoard development boards (boards dedicated to MicroPython), WiPy carts, STM32 (STM32F4) based boards, Nucleo and Espruino Pico boards and ESP8266 and ESP32 development boards. To download the latest firmware that corresponds to your board, go to the official website of the MicroPython project on this page.
Install esptool
To install the MicroPython firmware on your board, you will need Espressif esptool tools. If you already have python (to find out, just run the command python –version in Terminal or command prompt on Windows), just run the command
pip install esptool
To learn more about the esptool command-line tool, you can read this article.
Flash the MicroPython firmware on an ESP8266 or ESP32 board
If it’s not done yet, go to this page to download the latest firmware version for ESP8266 or ESP32. We download directly a binary file that we just need to upload to the board using a USB cable.
Here, I propose to (re) install the firmware on an ESP32 board. For the ESP32, it’s simple, there is only one binary available. For ESP8266 boards, there are three different firmwares:
- The latest build (latest compilation), also called latest
- A version with debug mode enabled by default and WebRPL disabled
- A version for older ESP8266 with only 512KB of flash memory
Once downloaded, open the Terminal (Linux and macOS) or command prompt under Windows (or PowerSheel) and then plug in the board. Run the command ls/dev/tty* on Linux or macOS and mode on Windows to identify the USB port to which the board is connected. Here, an example on a Mac Mini (the bluetooth port is displayed).
ls /dev/tty* /dev/tty.Bluetooth-Incoming-Port /dev/tty.wchusbserial1440 ...
esptool.py --port /dev/tty.wchusbserial1440 erase_flash
Go to the download directory (cd ~/Downloads/ ) and start the firmware installation with the following command. Remember to replace the COM port and the firmware name before running it.
esptool.py --port /dev/tty.wchusbserial1440 --baud 460800 write_flash --flash_size=detect 0 esp32-20171130-v1.9.2-445-g84035f0f.bin
The installation starts immediately and takes about 15 seconds.
esptool.py v2.2-dev Connecting.... Detecting chip type... ESP32 Chip is ESP32D0WDQ6 (revision 1) Uploading stub... Running stub... Stub running... Changing baud rate to 460800 Changed. Configuring flash size... Auto-detected Flash size: 4MB Compressed 936288 bytes to 587495... Wrote 936288 bytes (587495 compressed) at 0x00000000 in 14.2 seconds (effective 529.2 kbit/s)... Hash of data verified. Leaving... Hard resetting...
We just have to check that everything works well by connecting with rshell presented in the previous tutorial.
rshell --buffer-size=30 -p /dev/tty.wchusbserial1440
rshell --buffer-size=30 -p /dev/tty.wchusbserial1440
- ESP32, GPIO pins and associated functions. I/O, PWM, RTC, I2C, SPI, ADC, DAC
- M5Stack Atomic GPS. ESP32 TinyGPS++ tracker, GPX export on SD card, visualization on Google Maps or VSCode
- How to store data on a micro SD card. Arduino code compatible ESP32, ESP8266
- Getting started Arduino. Receive commands from the serial port (ESP32 ESP8266 compatible)
- C++ functions print•println•printf•sprintf for Arduino ESP32 ESP8266. Combine•format → serial port
- C++ String functions. concat•c_srt•indexOf•replace•subString… for Arduino, ESP32, ESP8266