Wednesday, August 17, 2016

Upgrading NodeMCU Firmware to v1.5 on EPS8266 (ESP-12E)

I've been updating firmware on my NodeMCU few times without issues - at least up to 0.9
The installation procedure has changed with SDK 1.5 - I've spent few hours before I got it right, so maybe this post will help you to save some time.

Here you will find all required information, but depending on your chip manufacturer you will need different combination of some options, and this is exactly the part when it's getting a bit tricky.

Since things are changing rapidly, I will point out exact versions in this tutorial, so that it's clear what was working with what at time of this writing.

Installing esptool

Download esptool v1.1 and unzip it.
This will give you possibility to execute form command line - we will use it below.

Determining version of your ESP8266 chip

As usual there are different versions, and probably you will have to modify flashing commands if you have different one.
sudo python -p /dev/tty.wchusbserial1410 flash_id v1.2-dev
Manufacturer: e0
Device: 4016

Well it's obviously ESP-12E with 4MB flash:

How do you tell? I've no idea - just google for "Manufacturer: e0 Device: 4016" and check what people are thinking.

Building custom firmware 

Now we have to obtain firmware containing Lua interpreter for our chip - it's everything that you will need in order to upload Lua scripts over serial. 

Basically you will need two binary files: 
  • custom firmware - something like: nodemcu-dev-7-modules-2016-08-10-10-43-59-integer.bin
  • initial-data-block (esp_init_data_default.bin)
Obviously you will need matching versions. 

There are two options to get those files: 
  • you can download it from my github repo - this will give you SDK
  • you can also use cloud service to build latest release. The link to latest initial-data-block can be found here - just search for esp_init_data_default.bin
I would prefer a latest version - as usual. But in case of some problems you can try using version provided on my github repo. At least this one was working in my case with ESP-12E, this might help you to locale a problem.

Erase flash

Put your chip into flash mode as described here. If you have development board it should have two buttons: flash and reset. In such case press flash and without releasing it press reset, after that release reset.

Now you have to determine com port, and change it in all commands in this tutorial. In my case it's: /dev/tty.wchusbserial1410

Let's finally erase flash!
sudo python -p /dev/tty.wchusbserial1410 erase_flash v1.1
Erasing flash (this may take a while)...

Now disconnect ESP from usb port, so that it can fully reset - pressing reset button does not have the same effect !

Flashing new firmware

Put your chip again into flash mode.
I am assuming that you have in you current directory two binary files: one with firmware (nodemcu-dev-7-modules-2016-08-10-10-43-59-integer.bin) and second with init-stuff (esp_init_data_default.bin).
sudo python -p /dev/tty.wchusbserial1410 write_flash -fm dio -fs 32m 0x000000 nodemcu-master-7-modules-2016-08-10-10-45-03-integer.bin 0x3fc000  esp_init_data_default.bin v1.1
Running Cesanta flasher stub...
Flash params set to 0x0240
Writing 385024 @ 0x0... 385024 (100 %)
Wrote 385024 bytes at 0x0 in 33.4 seconds (92.2 kbit/s)...
Writing 4096 @ 0x3fc000... 4096 (100 %)
Wrote 4096 bytes at 0x3fc000 in 0.4 seconds (80.0 kbit/s)...


I've used ESPlorer, and it looks just fine.