ESP32 How to flash MicroPython firmware

ESP32 How to flash MicroPython firmware.

For Windows 10 users.

In order to program an ESP32 development board you first have to put(Flash) the MicroPython firmware onto the device. The proven method of flashing firmware to devices is esptool.py.

Using esptool.py has lots of advantages. It works on Windows, is reliable fast, and as I will show later is easy to automate using scripts.

tpmplogo-sml

TECH PREP Series

This is the first in my new TECH PREP series… yaayyyyy!

ESP32 How to flash MicroPython firmware.

For Windows 10 users.

Note.. You can use the esptool.py at the windows 10 command prompt to do everything you need to flash MicroPython to your ESP32 and many other uses.

However, with my visual disability, I really don’t like typing long commands (lousy typist and sometimes using speech to text).  Also, I figure that we have computers to make less typing for us, the old script it once then edit it forever rule. So, what I’ll show is my way of using the esptool with Windows 10. No, this is not the only way, but it has worked well for me for a long time.

We will need to go to the Windows 10 command prompt to do some set up but after that everything is done in windows 10.

winstart

Right-click your mouse on the winStart icon  at the bottom left of your screen  will bring up

mnucp

If it has the Command Prompt (Admin)

Everything is good to continue to Python installation on your Windows 10.

If it looks like the following (showing  Windows PowerShell (Admin))

mnups

We will have to make a small change.

rgtclktb

Right-click your mouse on the tack bar

taskbarsettings

Click on Taskbar settings.

psoff

Turn the Replace Command Prompt to OFF

 

Close the window and it’s done.

If you wish to restore the Windows PowerShell Prompt later

simply reverse this procedure at any time.

Python installation on your Windows 10.

To use esptool.py, you’ll first need a Python installation on your Windows 10  system.

My recommendation would be the download and install the latest Python 3.7.X,  Now would be a good time to install it on your computer.

win_installer

When you have  Python installed, open a Terminal window. To do this…

winstart

on the Windows desktop right click on the start icon

Open command prompt (admin)

esp-cp-1

Click  command prompt (admin)

Type pip install esptool then press enter.

ecppie

Wait for the esptool installation to finish, then close the command prompt.

Download MicroPython firmware.

Next, we will need to download the latest version of MicroPython firmware for the ESP32, go to the MicroPython Downloads page.

Note, you are looking for Standard firmware in the ESP32 section.

esp32-fw-dl

Then a file link that looks similar to this esp32-20190526-v1.10-387-g1470184bd.bin

NOTE:  it will be different this is only an example.

What you should do now is open File Explorer and create a folder, let’s call it ‘myesp32’.

then copy the bin.file from our download folder to this folder.

makefolder

namefolder

fileinfolder

Find your esp32’s COM Port.

Another thing we need to do before going any further is to know which COM port your ESP32 device is connected to.

Keeping this as simple as I can, the following should work.

On your keyboard, press the Win logo key img_57fef72359c9c

Type devmgmt.msc and click OK.

img_5806e27e27212

code7

Click to drop down Ports (COM & LPT)
and you should see the entry for Silicon Labs CP210x
In most cases, this will be the  COM port we are looking for.

oh, I mentioned the auto scripting… you will first need to install

Git for Windows.

https://git-scm.com/download/win

git-win-dl-f-v4

Create a GIT bash script.

To create our flashesp32.sh script to auto flash MicroPython firmware onto our ESP32

open your favorite text editor (I like Notepad++)  and type in the following three lines then save to the folder

where your MicroPython bin file is located. ie in this case  myesp32

esptool.py –chip esp32 –port COM4  erase_flash
esptool.py –chip esp32 –port COM4 –baud 460800 write_flash -z 0x1000 esp32-20190526-v1.10-387-g1470184bd.bin

  read -p “Press enter to continue”

 Note * change the COM TO YOUR port

Note you don’t need to call the file flashesp32.sh BUT the filename must end with the .sh extension.

 

Run our GIT bash script.

In File Explorer browse to our myesp32 folder,  double click flashesp32.sh  to execute it.

All very civilized.

bashscriptdone

The result.

 

The script erases the Flash Memory then goes ahead and flashes the new firmware to the device; wait till the end and it will show you how wonderful it is, then the enter key to exit.

Writing and using a script like this makes it much easier to change things like COM ports or bin file names. And as a side note, you should study GIT for windows there is so much more to it.

 There you go the first of the tech prep collection, done and dusted. Next up, we will set up the Thonny IDE, write some code and send it to our ESP32… then watch the fireworks.  See you then.

 

Cheer’s

Al