How to flash MIcroPython onto ESP-32s

An excellent reference is the official MicroPython one here.

Windows guide made at PyConZA sprints 2018

  1. Install CP210x drivers
  2. Find out COM port (in this case COM3)
    1. https://www.mathworks.com/help/supportpkg/arduinoio/ug/find-arduino-port-on-windows-mac-and-linux.html
  3. esptool.py --chip esp32 --port COM3 erase_flash
  4. wget http://micropython.org/resources/firmware/esp32-20180511-v1.9.4.bin
    1. Note that this is now an old firmware
  5. esptool.py --chip esp32 --port COM3 write_flash -z 0x1000 esp32-20180511-v1.9.4.bin
  6. Putty over serial to COM3 with baud rate 115200
  7. import webrepl_setup
  8. On flash, the AP mode was not enabled
  9. import network
  10. sta_if = network.WLAN(network.STA_IF)
  11. sta_if.active(True)
  12. sta_if.connect('Brave-Fiber-Ruckus', 'braveGl0bal')
  13. Leave putty open, or else all this will be undone
  14. Load up a webrepl
    1. Hosted
    2. or self-hosted
  15. Connect via WebREPL
  16. Download boot.py from the device and update it with the following lines:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    import webrepl
    import network
    
    webrepl.start()
    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected(): 
        print('connecting to network...') 
        sta_if.active(True) 
        # Note that your WiFi details will be different
        sta_if.connect('WiFi SSID', 'password') 
        while not sta_if.isconnected(): 
            pass
    print('network config:', sta_if.ifconfig())
    
  17. Send the updated file back to device.

  18. Now you can close Putty, reboot the device and it will immediately be on the network.

Reference pin-outs

Reference pinout Reference pinout