So Easy MicroPython — Update your MCU Firmware

Yungger
4 min readApr 23, 2021
Using NodeMCU PyFlasher to easily upload MicroPython firmware to your MCU

Step 1: Download MicroPython firmware

Go to official MicroPython Download page, and choose the model of your MCU module, for instance ESP8266 or ESP32.

Select either one of the latest version of “Firmware with ESP-IDF v?.x” (eg. v1.14)

Step 2: Download ModeMCU Flasher

Download one of NodeMCU Flasher:

Step 3: Flash the firmware to your MCU

Config the setting of the NodeMCU Flasher for you MCU:

  • Serial Port: where the MCU plug-in
  • Firmware: the .bin file downloaded
  • Erase flash: Yes
This example is for ESP8266

Click on “Flash NodeMCU” button to start erase and upload the firmware.

When console display “Firmware successfully flashed”, then press the RST button of the MCU or replug-in it.

Step 4: Check if MCU flashed OK ?

import uos
print("Board:{}, Version:{}".format(uos.uname().machine, uos.uname().version))

After uploaded and reset your MCU, then , you can copy the script to your preferred MicroPython IDE, most popular IDE for MicroPython development are Visual Studio Code, PyCharm, uPyCraft, Thonny.

Here, I use Thonny IDE for this demo, just copy the script, run it by clicking the GREEN arrow icon on top-left. As you can see, my MCU is ESP8266 and MicroPython version is v1.14, 2021–02–02.

Screen shot of Thonny IDE

***If nothing wrong, you should got the version of your MicroPython, then everything is done, and no need for the Step 5. ***

Step 5: Flash the firmware manually

if you still have trouble to flash the MicroPython firmware according to the steps 1~4, there is one another way to do it using console commands manually.

ESP32:

  • Eraser old-version firmware and data.
    % esptool.py --chip esp32 --port <your MCU's usb port> erase_flash
  • Upload the firmware to MCU
    % esptool.py --chip esp32 --port <your MCU's usb port> --baud 460800 write_flash -z 0x1000 <path of esp32-xxx.bin>

ESP8266:

  • Eraser old-version firmware and data.
    % esptool.py --port <your MCU's usb port> erase_flash
  • Upload the firmware to MCU
    % esptool.py --port <your MCU's usb port> --baud 460800 write_flash --flash_size=detect 0 <path of esp8266-xxx.bin>

***If nothing wrong, you should go to Step 4, and check again. ***

Step 6: Your first MicroPython

import utime
from machine import Pin
led = Pin(2, Pin.OUT)
for _ in range(5):
led.value(0)
utime.sleep(0.5)
led.value(1)
utime.sleep(0.5)

No surprise, the built-in LED will start to blink for 5 times automatically, meaning the MCU is now MicroPython compatible already。

If LED didn’t blink, you may try to press the RST button of the MCU, it should be OK without any doubt。

*** If no idea how to upload File to your MCU, read my other article “So Easy MicroPython — ESP8266/ESP32 MCU File Management” first. ***

DEMO:

This demo shows how to upload/update the firmware of to my ESP8266, and need to reset the MCU after flashed .

That’s all, so easy right ? Hope this helps !

Posted by Yungger

If it really help you, you are welcome to clap your hands clicking on top-left icon, or want to buy me a coffee to encourage me to write more, I thank you too 😘 😘 !!

--

--