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 easy methods 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 on 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 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 must have the ability to 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 publish is split in two elements, learn Half 1 or Half 2 relying on your board:

  • Half 1 – ESP32
  • Half 2 – ESP8266

Word: after putting in MicroPython firmware on your ESP32 or ESP8266, you possibly can 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 must 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.

You need to see an analogous 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: should you’re utilizing a unique 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 ESP32 serial port identify (in our case it’s COM7)
  5. Shut your Arduino IDE software program

Essential: for those who plug your ESP32 board to your pc, however you possibly can’t discover the ESP32 Port out there in your Arduino IDE, it may be certainly 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 out there, 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 examine 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 must 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 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 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, 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 is advisable to erase the ESP32 flash reminiscence. So, 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 will probably be erased.

Word: if after the “Connecting …” message you retain seeing new dots showing, it signifies that your ESP32 shouldn’t be in flashing mode. It’s essential 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 with your particulars:

esptool.py –chip esp32 –port <serial_port> write_flash -z 0x1000 <esp32-X.bin>

In our case, the ultimate command seems 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 it is best to see:

Your ESP32 was efficiently flashed with MicroPython firmware!

Notice: in the event you obtain an error making an attempt to flash the firmware, run the command once more and be sure to 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.

You must 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.

Observe: in case you’re utilizing a special board (like a PyBoard, WiPy, or different), go to MicroPython Downloads web page and obtain the proper 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

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

1. Should 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 examine 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 you need to see the serial port within the Instruments > Port menu.

2. When you’ve got the drivers put in, however you’ll be able to’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 with your ESP8266. Utilizing a a correct USB cable ought to remedy your drawback.

Discovering your MicroPython .bin file

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

cd Downloads

Listing 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, you’ll want to erase the ESP8266 flash reminiscence. So, 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 couple of seconds, the ESP8266 flash reminiscence shall be erased.

Notice: if after the “Connecting …” message you retain seeing new dots showing, it signifies that your ESP8266 is just not in flashing mode. You could 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’ll be able to lastly flash the MicroPython firmware. You want your serial port identify (COM7 in our case) and the ESP8266 .bin file location. Substitute the subsequent command with your particulars:

esptool.py –chip esp8266 –port <serial_port> write_flash –flash_mode dio –flash_size detect 0x0 <esp8266-X.bin>

In our case, the ultimate command appears 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 couple of seconds that is what you must see:

Your ESP8266 was efficiently flashed with MicroPython firmware!

Notice: in the event you obtain an error making an attempt to flash the firmware, run the command once more and be sure to 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.

For those who appreciated this submit, you may like our subsequent ones, so be sure to subscribe to the RNT weblog and obtain our free electronics eBooks.


Really helpful Assets