This little guide is meant to help you through flashing your WeMos D1 with the MicroPython firmware.
Go to http://micropython.org/download#esp8266 and download the latest version of the micropython firmware.
In order to write to the Flash memory of the D1, pin D3 must be connected to GND.
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
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.
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...
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.