Introduction: WeMos D1 Mini Pro Flash NodeMCU Firmware

Picture of WeMos D1 Mini Pro Flash NodeMCU Firmware

This instructables show how to flash NodeMCU firmware to WeMos D1 mini Pro.

Step 1: Introduction

WeMos D1 mini Pro is a new ESP8266 dev board.

It is thin, light weight, built-in USB to serial chip and 16 MB flash!

Recently, it is the only board with built-in 16 MB flash (at least 4 times of flash space compare with other ESP board). However, there are still no one on the web know how to utilize all 16 MB flash space. (In Arduino, you can treat it as a normal 4 MB version ESP board but nothing more)

I can flash an older version (1.5.1 SDK) NodeMCU firmware to a 16 MB ESP board in my previous instructables. But when I flash the most recent version (1.5.4.1 SDK) of NodeMCU firmware to this board, it will loop forever on the rf_cal_size reboot.

After days of subsequent test, I found the SDK limitation and know the workaround to overcome this. This instructables show how to do that.

Step 2: Preparation

WeMos D1 mini Pro

You may order this at: https://www.aliexpress.com/store/product/WEMOS-D1-...

Download and install USB driver

https://www.silabs.com/products/mcu/Pages/USBtoUAR...

Download and install Python 2.x

Home page: https://www.python.org/

Download link: https://www.python.org/ftp/python/2.7.12/python-2....

Download and install esptool.py

Follow "Easy Installation" Section: https://github.com/espressif/esptool

Quota from manual install:

you may have to install pySerial manually by running something like pip install pyserial, easy_install pyserial or apt-get install python-serial, depending on your platform.

Download and install Esplorer

Project page: https://esp8266.ru/esplorer/

Download link: http://esp8266.ru/esplorer-latest/?f=ESPlorer.zip

Download and extract bin from SDK patch

Download page: http://espressif.com/en/support/download/sdks-demo...

Download link: http://espressif.com/sites/default/files/sdks/esp8...

Extract file: esp_init_data_default.bin

Step 3: ESP8266 NONOS SDK V1.5.4.1 Limitation

Picture of ESP8266 NONOS SDK V1.5.4.1 Limitation

ESP8266 NONOS SDK V1.5.4.1 use the flash memory last 5 sectors (@4096 bytes) to store the system data. The SDK can detect the flash size correctly while the flash size within the range from 256 KB to 4 MB. I guess because there are no ESP board with flash larger than 4 MB before, the SDK not defined 8 MB and 16 MB flash size. So, SDK failed to detect 8 MB and 16 MB flash correctly and fall back to the default size (512 KB).

The screen capture is the boot up message after flashed latest (2016/11/11) dev branch. The message "rf cal sector: 123" should mean the last 5th sector of 512 KB.

SDK use the 5 sectors just before 512 KB to store the system data is ok, but it introduce some rules on flashing firmware:

  • firmware size cannot over 491 KB (the space before the system data)
  • remember treat it as 512 KB flash size while flashing
  • manual flash the esp_init_data (part of system data) to the correct place (last 4th sector)

After SDK boot process, NodeMCU firmware is intelligent enough to detect the correct flash size and format the remained ~15.48 MB flash size to SPIFFS. It can store Lua code and other resource files, GREAT!

Step 4: Custom Build NodeMCU Firmware

Build your tailor-made firmware at NodeMCU custom builds website: https://nodemcu-build.com/

Submit build request -> wait build complete email -> download firmware

Suggest use master branch and remember limit selected modules to meet the firmware size not over 491 KB.

In case you don't want to build your own firmware, you can test with my attached firmware.

Step 5: Erase Flash

Picture of Erase Flash

It is better to cleanup the flash first before flash the firmware.

Run in console:

python esptools.py -p /dev/cu.SLAB_USBtoUART erase_flash

Erase flash operation is an async process, ESP board still running erase process after command return.

Open Esplorer, connect and wait (within a few minutes) some kind of response, that means erase process finished.

P.S. "/dev/cu.SLAB_USBtoUART" is the com port name, in Windows, it should be something like "com??"

Step 6: Flash Firmware

Picture of Flash Firmware

Put the custom build firmware file and esp_init_data_default.bin (extract from SDK zip) to current folder.

Run in console:

python esptool.py -p /dev/cu.SLAB_USBtoUART -b 921600 write_flash -ff 80m -fm qio -fs 4m 0x0 nodemcu-master-21-modules-2016-11-09-16-08-01-integer.bin 0x7c000 esp_init_data_default.bin

Open Esplorer, connect and press reset button on the ESP board.

Esplorer show "Formatting file system. Please wait..." message.

Wait a few minutes for format finish and then Esplorer will show Lua startup message.

P.S.

  • "/dev/cu.SLAB_USBtoUART" is the com port name, in Windows, it should be something like "com??"
  • "-fs 4m" means 512 KB flash size
  • "nodemcu-master-21-modules-2016-11-09-16-08-01-integer.bin" is the firmware file name, you may replace with your filename
  • 0x7c000 is the address of the last 4th sector for 512 KB flash

Step 7: Testing

Picture of Testing

The first 4 MB flash space should run normal as other ESP board. I would like to test the last part of flash space also can run normally.

Here is my testing steps:

  1. upload gen_dummy.lua script (script for generate 15 dummy files at 1 MB each)
  2. run gen_dummy.lua for fill up first 15 MB of SPIFFS space (last tens of minutes)
  3. upload NodeMCU WebIDE (https://github.com/moononournation/nodemcu-webide)
  4. restart ESP board
  5. check NodeMCU WebIDE run normal

testing result:

  • at step 2 I found it hanged while generating 14th dummy file, so I remove last 2 dummy files before step 3
  • gen dummy files obviously slower while nearly full
  • upload further files failed even removed last 2 dummy files, so I remove last 5 dummy files (remain dummy1-9) and upload again
  • NodeMCU WebIDE works fine!

Step 8: Happy Coding!

WeMos D1 mini Pro is thin, light weight, built in USB to serial chip and 16 MB flash. (although last few MBs may not usable)

It's time to use it build a tiny powerful IoT!

Comments

tiawild (author)2017-10-16

It doesn't work for me. When I press reset button after programm command, Esplorer show me this in a infinte loop:

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 26636, room 16
tail 12
chksum 0xa7
ho 0 tail 12 room 4
load 0x3ffe8000, len 2260, room 12
tail 8
chksum 0xe1
load 0x3ffe88d4, len 8, room 0
tail 8
chksum 0x3c
csum 0x3c
rl

陳亮 (author)tiawild2017-10-30

Hi tiawild, what ESP8266 board are you using? If you are not sure just take a picture and attach in the reply.

tiawild (author)陳亮2017-11-01

I'm using ESP8266 with 16MB flash:

陳亮 (author)tiawild2017-11-01

any photo?

tiawild (author)陳亮2017-11-05

I attach them to this post:

tiawild (author)tiawild2017-11-07

Do you understand what is wrong?

陳亮 (author)tiawild2017-11-07

Not exactly, have you wait

Step 5: Erase Flash

finish before go forward?

tiawild (author)陳亮2017-11-08

Oh yes, sure. You can see it again in this sequence:

陳亮 (author)tiawild2017-11-08

not sure, you may try slower flash setting. E.g. 40m instead of 80m or dio instead of qio.

tiawild (author)陳亮2017-11-08

Thank you for your help.

Unfortunately it doesn't work again. I have tried every combination: 40 QIO - 80 DIO - 40 DIO - 80 QIO.

With a baud rate of 74880 I receive always the rf section error when it boots and if I continue anyway with my lua file it has some problems with wifi module of NodeMCU. My programm could be executed correctly only for the first time.

陳亮 (author)tiawild2017-10-16

Hi tiawild, which firmware are you flashed? bin at step 4? or custom build?
If you encounter error in custom build, try download the bin file at step 4 first.

tiawild (author)陳亮2017-10-17

Using your bin file it's OK. Thank you

tiawild (author)tiawild2017-10-19

If I try to build my firmware from https://nodemcu-build.com/ It doesn't work again. I tried to build a firmware from the site with 18 modules (432KB) and when I use a simple sketch to connect it with my WiFi (wifi.STATION) it stops at "wifi.sta.config", it seems it hasn't this reference...

With your firmware instead I can run my sketch correctly only for the first time. If I restart my wemos it can't connect to my router no more...

It's very strange...

tiawild (author)tiawild2017-10-30

I have tried many times but I can't make it working...

I can flash your firmware and when I reset wemos I can see formatting message. Now, in this situation, if I choose 115200 as baude rate I receive the init.lua message and if I choose 74800 I can see again the rf cal sector error:

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 24960, room 16
tail 0
chksum 0x28
load 0x3ffe8000, len 2208, room 8
tail 8
chksum 0xa0
load 0x3ffe88a0, len 8, room 0
tail 8
chksum 0x85
csum 0x85
rf cal sector: 123
rf[112] ü‹Ö %¦ÔYÖQ

I think it's not properly flashed

weizhua (author)2016-11-30

Hi!

Thanks for posting this, I'm a beginner trying to work
with the WEMOS mini pro, previously I have done some projects with the
D1R2 with nodemcu.

However, as I am using windows, I am confused
with the console usage. Do I do it with powershell or in the ESPlorer
command line for the python commands? Is there something that I need
installed or I've missed?

陳亮 (author)weizhua2016-11-30

The command just run in command prompt, I guess you are not yet installed python 2.x.

weizhua (author)陳亮2016-11-30

Hi, I have python 2.x installed.

Realized in windows command prompt 'py' seemed to work instead of 'python', but I am met with this error instead:

Traceback (most recent call last):
File "esptool.py", line 26, in <module>
import serial
ImportError: No module named serial

What does this mean?

陳亮 (author)weizhua2016-11-30

Quota from manual install:

you may have to install pySerial manually by running something like pip install pyserial, easy_install pyserial or apt-get install python-serial, depending on your platform.

weizhua (author)陳亮2016-12-01

I've got it working now, thank you so much !

About This Instructable

19,402views

44favorites

License:

Bio: Do it yourself if you cannot buy one!
More by 陳亮:ESP32 Photo ClockUSB Tiny Tools - ScrewdriverCircuit Visualization
Add instructable to: