como-instalar-firmware-micropython

How to Install MicroPython Firmware on a Board

  • 3 min

Now that we know what MicroPython is and have installed an IDE on our computer, it’s time to upload the firmware to our board.

The firmware is the software that is loaded directly onto a device’s hardware and that it executes during its operation.

In the case of MicroPython, the firmware is a lightweight version of the Python interpreter that runs on the board’s microcontroller. This firmware allows Python code to be executed on the device.

The good news is that it’s very easy to install on our board. Let’s see how to do it.

Download the MicroPython Firmware

The first step is to download the appropriate firmware for your board. You can find the firmware files on the official MicroPython site: https://micropython.org/download/.

You will need to download the exact file for your specific board model and variant.

DeviceFile to Download
ESP32.bin file for your model
ESP8266.bin file for your ESP8266 model
Raspberry Pi Pico.uf2 file for your Rpi Pico model
Arduinos.hex file for your model
STM32.duf file for your model

Upload the Firmware to the Board

Now we need to upload the firmware to the board. To do this, connect the board to the computer using a USB cable.

The process varies depending on your board. Let’s see what the upload process would be like for an ESP32/ESP8266 and a Raspberry Pi Pico (any of its versions).

For other models (Arduino, STM32, etc), consult the information in the official documentation.

Installation on ESP32/ESP8266

Install esptool: If you don’t have it installed, you can install it using pip:

pip install esptool

Erase the flash memory: Before installing the new firmware, it is recommended to erase the board’s flash memory:

esptool.py —port /dev/ttyUSB0 erase_flash

Replace /dev/ttyUSB0 with the correct port on your system.

Load the firmware: Use esptool to load the downloaded firmware:

esptool.py —port /dev/ttyUSB0 —baud 460800 write_flash —flash_size=detect 0x1000 firmware.bin

Make sure to replace firmware.bin with the name of the file you downloaded.

Reset the board: Once the upload is complete, disconnect and reconnect the board to reset it.

For ESP32 and ESP8266, it is necessary to put the board into programming mode. This is generally done by connecting a specific pin (like GPIO0) to ground (GND) before connecting the board to the computer.

Depending on your board, it may do this automatically, by pressing a button, or you may have to do it manually.

Installation on Raspberry Pi Pico

The Raspberry Pi Pico is very much designed to run MicroPython, so uploading is very simple (you might even have it preloaded on the board).

To install the firmware on the Raspberry Pi Pico:

  1. Hold down the BOOTSEL button while connecting the board to the computer.
  2. This will put the board into mass storage mode, appearing as a drive on your PC (like a USB memory stick).
  3. Now you simply have to copy the .uf2 file directly, as you would with any file (for example with Ctrl + C / Ctrl + V, or by dragging the file)-.
  4. The board will automatically reset and load the MicroPython firmware, and you are ready to go.

Verify the Installation

Once the firmware is installed, you can verify that everything is working correctly using the REPL (Read-Eval-Print Loop).

But we will see this in the next tutorial.