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:
Join your board to your pc
Open the Arduino IDE
Go to Instruments > Port
Save your ESP32 serial port identify (in our case itâs COM7)
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:
Join your board to your pc
Open the Arduino IDE
Go to Instruments > Port
Save your ESP8266 serial port identify (in our case itâs COM4)
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
The post Flashing MicroPython Firmware with esptool.py on ESP32 and ESP8266 appeared first on Playtab Tech.



















