Skip to content

Instantly share code, notes, and snippets.

@SebastiaanDeJonge
Last active February 2, 2019 19:08
Show Gist options
  • Save SebastiaanDeJonge/7c65e750f72f99130a633ac05c0751f0 to your computer and use it in GitHub Desktop.
Save SebastiaanDeJonge/7c65e750f72f99130a633ac05c0751f0 to your computer and use it in GitHub Desktop.
wemos-d1-flash-micropython.md

WeMos D1 - MicroPython Flash Guide

This little guide is meant to help you through flashing your WeMos D1 with the MicroPython firmware.

1. Download MicroPython Firmware

Go to http://micropython.org/download#esp8266 and download the latest version of the micropython firmware.

2. Enable Flash Writing

In order to write to the Flash memory of the D1, pin D3 must be connected to GND.

4. Find USB Serial Device

Find the correct port for the D1 by running the following command:

ls -lAh /dev/ | grep tty.wchusbserial

This will result in for example te following device: tty.wchusbserial30

5. Erase Current Flash

Using `esptool, erase the current flash memory with the following command (using the device found in the previous step).

esptool.py --port /dev/tty.wchusbserial30 erase_flash

This should give an output which may resemble the following:

esptool.py v2.5.1
Serial port /dev/tty.wchusbserial30
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: b4:e6:2d:53:cf:28
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 7.7s
Hard resetting via RTS pin...

Depending on your actual device, an LED on the device might blink when it's erasing the flash.

6. Write MicroPython Firmware to the Device

Now that the flash has been cleared, the new firmware can be uploaded using esptool as well.

esptool.py --port /dev/tty.wchusbserial30 --baud 115200 write_flash --flash_size=detect 0 ~/Downloads/esp8266-20190125-v1.10.bin

The baud rate may be set differently for your device, so you will have to experiment with that perhaps. I have found 115200 to be most common and stable.

esptool.py v2.5.1
Serial port /dev/tty.wchusbserial30
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: b4:e6:2d:53:cf:28
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0040
Compressed 615388 bytes to 399928...
Wrote 615388 bytes (399928 compressed) at 0x00000000 in 35.5 seconds (effective 138.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

7. Test Result

In order to test the result, you can simply run a screen command to connect to the serial port of the D1. Before you do though, pull the D3 to GND lead and reset the D1.

screen /dev/tty.wchusbserial30 115200

If flashing was successful, you should see the MicroPython header popup.


MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
Type "help()" for more information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment