0-ESP32-MicroPython ESP32 ESP8266 guide MicroPython Project Tech

Flashing MicroPython Firmware with esptool.py on ESP32 and ESP8266

Flashing MicroPython Firmware with esptool.py on ESP32 and ESP8266

This posts exhibits the best way to flash MicroPython firmware on ESP32/ESP8266 boards utilizing the esptool.py. It really works on Home windows, Mac OS X, and Linux. For the official documentation, you possibly can go to the esptool.py GitHub web page.

Tip: for a neater technique to flash the ESP32/ESP8266 with MicroPython, we advocate studying this information to flash MicroPython with uPyCraft IDE. Nevertheless, we’ve just lately acquired feedback from our readers about having hassle putting in/utilizing uPyCraft IDE. For that cause, we’re posting an alternate technique utilizing the esptool.py software program.

Putting in esptool.py in your pc

To work with esptool.py, you’ll want both Python 2.7, Python three.Four or a more moderen Python set up in your system. We advocate utilizing Python three.7.X, so go to Python’s web site and set up it in your pc.

With Python three put in, open a Terminal window and set up the newest secure esptool.py launch with pip:

pip set up esptool

Observe: with some Python installations that command might not work and also you’ll obtain an error. If that’s the case, attempt to set up esptool.py with:

  • pip3 set up esptool
  • python -m pip set up esptool
  • pip2 set up esptool

After putting in, you’ll have esptool.py put in into the default Python executables listing and you need to be capable of run it with the command esptool.py. In your Terminal window, run the next command:

esptool.py

If it was put in correctly, it ought to show an identical message (no matter your working system):

With esptool.py put in in your pc, you’ll be able to simply flash your ESP32 or ESP8266 boards with the MicroPython firmware. This submit is split in two elements, learn Half 1 or Half 2 relying in your board:

  • Half 1 – ESP32
  • Half 2 – ESP8266

Notice: after putting in MicroPython firmware in your ESP32 or ESP8266, you’ll be able to return and use Arduino IDE once more. You simply have to add code utilizing Arduino IDE. Then, if you wish to use MicroPython once more, you want to flash MicroPython firmware.

[Part 1 – ESP32] Downloading and Flashing the MicroPython Firmware on ESP32

To obtain the newest model of MicroPython firmware for the ESP32, go to the MicroPython Downloads web page and scroll all the best way right down to the ESP32 part.

It is best to see an identical net web page (see determine under) with the newest hyperlink to obtain the ESP32 .bin file – for instance: esp32-20181007-v1.9.Four-631-g338635ccc.bin.

Word: for those who’re utilizing a unique board (like a PyBoard, WiPy, or different), go to MicroPython Downloads web page and obtain the suitable firmware on your board.

Discovering the Serial Port Identify

It’s a bit totally different to seek out the Serial port identify in every working system, so for simplicity causes we advocate discovering your ESP serial port identify via the Arduino IDE. Comply with these steps:

  1. Join your board to your pc
  2. Open the Arduino IDE
  3. Go to Instruments > Port
  4. Save your ESP32 serial port identify (in our case it’s COM7)
  5. Shut your Arduino IDE software program

Necessary: when you plug your ESP32 board to your pc, however you’ll be able to’t discover the ESP32 Port out there in your Arduino IDE, it is perhaps considered one of these two issues: 1. USB drivers lacking or 2. USB cable with out knowledge wires.

1. For those who don’t see your ESP’s COM port obtainable, this typically means you don’t have the USB drivers put in. Take a better take a look at the chip subsequent to the voltage regulator on board and verify its identify.

The ESP32 DEVKIT V1 DOIT board makes use of the CP2102 chip.

Go to Google and seek for your particular chip to seek out the drivers and set up them in your working system.

You possibly can obtain the CP2102 drivers on the Silicon Labs web site.

After they’re put in, restart the Arduino IDE and you need to see the serial port within the Instruments > Port menu.

2. When you’ve got the drivers put in, however you possibly can’t see your system, double-check that you simply’re utilizing a USB cable with knowledge wires.

USB cables from powerbanks typically don’t have knowledge wires (they’re cost solely). So, your pc won’t ever set up a serial communication together with your ESP32. Utilizing a a correct USB cable ought to clear up your drawback.

Discovering your MicroPython .bin file

After downloading the ESP32 .bin file, it must be in your Downloads folder. So, together with your Terminal window, you’ll have to navigate to the Downloads folder utilizing the cd command:

cd Downloads

Record all information in your Downloads folder to make sure that’s the place the .bin file is situated. In Home windows, you employ:

dir

On Mac OS X or Linux, run the subsequent command:

ls

As you’ll be able to see within the previous screenshot, the ESP32 .bin file is situated within the Downloads folder: esp32-20190113-v1.9.Four-779-g5064df207.bin.

Erasing ESP32 Flash Reminiscence

Earlier than flashing the MicroPython firmware, it’s worthwhile to erase the ESP32 flash reminiscence. So, together with your ESP32 related to your pc, hold-down the “BOOT/FLASH” button in your ESP32 board:

Whereas holding down the “BOOT/FLASH” button, run the next command to erase the ESP32 flash reminiscence:

esptool.py –chip esp32 erase_flash

When the “Erasing” course of begins, you’ll be able to launch the “BOOT/FLASH” button. After a couple of seconds, the ESP32 flash reminiscence might be erased.

Observe: if after the “Connecting …” message you retain seeing new dots showing, it signifies that your ESP32 is just not in flashing mode. It is advisable repeat all of the steps described earlier and maintain the “BOOT/FLASH” button once more to make sure that your ESP32 goes into flashing mode and completes the erasing course of efficiently.

Flashing MicroPython Firmware on ESP32 with esptool.py

Together with your ESP32 flash reminiscence erased, you possibly can lastly flash the MicroPython firmware. You want your serial port identify (COM7 in our case) and the ESP32 .bin file location. Substitute the subsequent command together with your particulars:

esptool.py –chip esp32 –port write_flash -z 0x1000

In our case, the ultimate command seems to be like this:

esptool.py –chip esp32 –port COM7 write_flash -z 0x1000 esp32-20190113-v1.9.Four-779-g5064df207.bin

Maintain down the “BOOT/FLASH“, earlier than operating the flash command. After a number of seconds that is what you need to see:

Your ESP32 was efficiently flashed with MicroPython firmware!

Word: when you obtain an error making an attempt to flash the firmware, run the command once more and ensure you are holding down the ESP32 “BOOT/FLASH” button.

[Part 2 – ESP8266] Downloading and Flashing the MicroPython Firmware on ESP8266

To obtain the newest model of MicroPython firmware for the ESP8266, go to the MicroPython Downloads web page and scroll all the best way right down to the ESP8266 part.

It is best to see an analogous net web page (see determine under) with the newest hyperlink to obtain the ESP8266 .bin file – for instance: esp8266-20180511-v1.9.Four.bin.

Word: in the event you’re utilizing a special board (like a PyBoard, WiPy, or different), go to MicroPython Downloads web page and obtain the correct firmware on your board.

Discovering the Serial Port Identify

It’s a bit totally different to seek out the Serial port identify in every working system, so for simplicity causes we advocate discovering your ESP serial port identify via the Arduino IDE. Comply with these steps:

  1. Join your board to your pc
  2. Open the Arduino IDE
  3. Go to Instruments > Port
  4. Save your ESP8266 serial port identify (in our case it’s COM4)
  5. Shut your Arduino IDE software program

Essential: when you plug your ESP8266 board to your pc, however you’ll be able to’t discover the ESP8266 Port obtainable in your Arduino, it could be certainly one of these two issues: 1. USB drivers lacking or 2. USB cable with out knowledge wires.

1. In the event you don’t see your ESP’s COM port obtainable, this typically means you don’t have the USB drivers put in. Take a better take a look at the chip subsequent to the voltage regulator on board and verify its identify.

The ESP8266 ESP-12E NodeMCU board makes use of the CP2102 chip.

Go to Google and seek for your particular chip to seek out the drivers and set up them in your working system.

You possibly can obtain the CP2102 drivers on the Silicon Labs web site.

After they’re put in, restart the Arduino IDE and it is best to see the serial port within the Instruments > Port menu.

2. In case you have the drivers put in, however you’ll be able to’t see your gadget, double-check that you simply’re utilizing a USB cable with knowledge wires.

USB cables from powerbanks typically don’t have knowledge wires (they’re cost solely). So, your pc won’t ever set up a serial communication together with your ESP8266. Utilizing a a correct USB cable ought to clear up your drawback.

Discovering your MicroPython .bin file

After downloading the ESP8266 .bin file, it must be in your Downloads folder. So, together with your Terminal window, you’ll have to navigate to the Downloads folder utilizing the cd command:

cd Downloads

Record all information in your Downloads folder to make sure that’s the place the .bin file is situated. In Home windows, you employ:

dir

On Mac OS X or Linux, run the subsequent command:

ls

As you’ll be able to see within the previous screenshot, the ESP8266 .bin file is situated within the Downloads folder: esp8266-20180511-v1.9.Four.bin.

Erasing ESP8266 Flash Reminiscence

Earlier than flashing the MicroPython firmware, it’s essential to erase the ESP8266 flash reminiscence. So, together with your ESP8266 related to your pc, hold-down the “BOOT/FLASH” button in your ESP8266 board:

Whereas holding down the “BOOT/FLASH” button, run the next command to erase the ESP8266 flash reminiscence:

esptool.py –chip esp8266 erase_flash

When the “Erasing” course of begins, you possibly can launch the “BOOT/FLASH” button. After a number of seconds, the ESP8266 flash reminiscence can be erased.

Observe: if after the “Connecting …” message you retain seeing new dots showing, it signifies that your ESP8266 shouldn’t be in flashing mode. You should repeat all of the steps described earlier and maintain the “BOOT/FLASH” button once more to make sure that your ESP8266 goes into flashing mode and completes the erasing course of efficiently.

Flashing MicroPython Firmware on ESP8266 with esptool.py

Together with your ESP8266 flash reminiscence erased, you possibly can lastly flash the MicroPython firmware. You want your serial port identify (COM7 in our case) and the ESP8266 .bin file location. Exchange the subsequent command together with your particulars:

esptool.py –chip esp8266 –port write_flash –flash_mode dio –flash_size detect 0x0

In our case, the ultimate command seems like this:

esptool.py –chip esp8266 –port COM4 write_flash –flash_mode dio –flash_size detect 0x0 esp8266-20180511-v1.9.Four.bin

Maintain down the “BOOT/FLASH“, earlier than operating the flash command. After a number of seconds that is what it is best to see:

Your ESP8266 was efficiently flashed with MicroPython firmware!

Word: in case you obtain an error making an attempt to flash the firmware, run the command once more and ensure you are holding down the ESP8266 “BOOT/FLASH” button.

Wrapping Up

We hope you’ve discovered this tutorial helpful. Your ESP32/ESP8266 ought to now be flashed with MicroPython firmware. To study extra about MicroPython learn: Getting Began with MicroPython on ESP32 and ESP8266.

When you favored this publish, you may like our subsequent ones, so ensure you subscribe to the RNT weblog and obtain our free electronics eBooks.


Beneficial Assets