How to reinstall the MicroPython firmware on an ESP8266 or ESP32 with the script

Table of Contents

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*
If the board is not visible, you need to install the CH341 driver on your machine, follow this tutorial for that and come back after --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. --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. v2.2-dev
Detecting chip type... ESP32
Chip is ESP32D0WDQ6 (revision 1)
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
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.

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
Note. If you can not connect with rshell, no choice, it will restart the computer or the Raspberry Pi!
Click to rate this post!
[Total: 0 Average: 0]

Thanks for your reading

Did you like this project ? Don't miss any more projects by subscribing to our weekly newsletter!

Are you having a problem with this topic?

Maybe someone has already found the solution, visit the forum before asking your question
We will be happy to hear your thoughts

Leave a Reply

Read more
DIY Projects
DIY Projects