[EN] How to flash the MicroPython firmware to WeMos D1 Pro Mini

WeMos D1 Pro Mini is an ESP8266 board with 16MB Flash ROM memory, useful for taking unaltered images or data stored in Flash ROM for later usage. However, when flashing MicroPython firmware onto this board, there are steps that need to be done in addition to writing with the 4MB version of the board. (The method for the WeMos D1 R1 mini or ESP8266 board can be seen from this video) In this article, we will try to flash ROM and write a program to display board information.

(Figure. 1) WeMos D1 Pro mini is already connected to the computer.

Preparatory stage

First of all, we need to prepared equipment and these files.

  1. MicroPython firmware version 1.13 for ESP8266 from this link.
  2. Payload file for ESP8266 from here.
  3. python program for your current operating system.
  4. esptool.py which can be installed from python’s pip with the following installation command.
    pip install esptool
  5. Thonny installer which can be downloaded from the website or from pip with this following command.
    pip install thonny

Let’s get started

  1. Connect the micro-USB cable to the board and computer.
  2. Open Terminal.
  3. Delete the current ROM with the following command.
    python -m esptool –baud 460800 erase_flash –port portName
    esptool.exe –port portName –baud 460800 erase_flash
  4. Put all of your files in one place And write it down to ROM with the following command.
    python -m esptool –baud 460800 write_flash \
    -fm dio -fs 16MB 0x0 esp8266-20200911-v1.13.bin \
    0xffc000 esp_init_data_default.bin –port portName
    esptool.exe –port portName –baud 460800 write_flash -fm dio -fs 16MB 0x0 esp8266-20200911-v1.13.bin 0xffc000 esp_init_data_default.bin
  5. Open Thonny and connect to the board.
  6. Write a testing program (info-esp8266.py) and the result was as the following picture.
import os
import sys
import machine as mc
import gc
import time
if sys.platform == 'esp8266':
    import esp
    scl_pin = mc.Pin(5)
    sda_pin = mc.Pin(4)
    i2c = mc.I2C(scl=scl_pin,sda=sda_pin)
    scl_pin = None
    sda_pin = None
    i2c = None
uname = os.uname()
if sys.platform == 'esp8266':
mem_total = gc.mem_alloc()+gc.mem_free()
free_percent = str((gc.mem_free())/mem_total*100.0)+"%"
alloc_percent = str((gc.mem_alloc())/mem_total*100.0)+"%"
print("ID ............: {}".format(mc.unique_id()))
print("Platform ......: {}".format(sys.platform))
print("Version .......: {}".format(sys.version))
if sys.platform == 'esp8266':
    print("ROM Size ......: {} MBytes".format(esp.flash_size()/(1024*1024)))
print("   total ......: {} Bytes or {} MBytes".format(mem_total, mem_total/(1024*1024)))
print("   usage ......: {} Bytes or {}".format(gc.mem_alloc(),alloc_percent))
print("   free .......: {} Bytes or {}".format(gc.mem_free(),free_percent))
print("system name ...: {}".format(uname.sysname))
print("node name .....: {}".format(uname.nodename))
print("release .......: {}".format(uname.release))
print("version .......: {}".format(uname.version))
print("machine .......: {}".format(uname.machine))
if sys.platform == 'esp8266':
    print("Frequency .....: {} MHz".format(mc.freq()/1000000.0))
if i2c != None:
    devices = i2c.scan()
    i2c_dev = {32:'PCF8574',33:'PCF8574',34:'PCF8574',35:'PCF8574',36:'PCF8574',37:'PCF8574',38:'PCF8574',39:'LCD',56:'LCD',57:'PCF8574',58:'PCF8574',59:'PCF8574',
               60:'PCF8574/OLED',61:'PCF8574',62:'PCF8574',63:'PCF8574',68:'SHT31', 84:'24xx #1',85:'24xx #2',86:'24xx #3',87:'24xx #4',104:'RTC'}
    if len(devices)==0:
        print("No I2C")
    for io in devices:
        if io in i2c_dev:
            print("Address [",hex(io),"] Device :",i2c_dev[io])
            print("Address [",hex(io),"] Device : ???")
(Figure. 2) info-esp8266.py
(Figure. 3) result of info-esp8266.py


From this experiment, it was found that The firmware flashing for the WeMos D1 Pro mini board must include MicroPython and the ESP8266’s Data Area in order for the board to function normally, just like burning with Thonny program. The advantage of having more ROMs was allowed us to write more code, Can upload more files to store in ROM, etc.

Finally, I hope this article is helpful for anyone studying python programming on an ESP8266 board with 16MB ROM. And hope that the board reading sample code is probably a coding guideline to verify board status while running such as the remaining amount of RAM, Firmware version Or platforms that are currently working, etc.

If you want to discuss something, feel free to leave comments below.


1. https://medium.com/@rawat.s/micropython-for-esp8266-d932e51e6f47
2. http://www.micropython.org

(C) 2020, by Danai Jedsadathitikul and Jarut Busarathid
latest updated 2020/09/20
latest updated 2020/11/04