November 23, 2017

Flashing NodeMCU Firmware

Filed under: Electronics, Microcontroller, Software Development, Uncategorized — fandigunawan @ 4:27 am

After compiling the firmware, I need to upload the firmware manually. The tool required to flash the board (on Windows) can be obtained here, and then select Download.


You will need WinRAR or 7-Zip (free) to extract the rar archive. Double click the exe file and select ESP8266 Download Tool


You need to set the correct Crystal Freq, SPI Speed, SPI Mode and Flash Size (please check the datasheet of your board). The default setting Crytal Freq 26Mhz, SPI Speed 40Mhz, SPI Mode DIO and Flash Size 32 Mbit is just fine on my board. The next is to select the firmware and set the address to 0x0. The COM port needs to be selected as well, if you have not installed the USB to Serial driver please check the manufacturer website or download the driver manually. I found out that there are several variants of USB to Serial chip : CH340, CP2102 and FTDI. Well, you can google it to download the driver.

Then, press start to download the firmware and voila, you get yourself new updated firmware



Espressif ESP8266 Compiler on Windows 10 for NodeMCU

Filed under: Electronics, Microcontroller, Software Development, Uncategorized — Tags: , , , , — fandigunawan @ 3:59 am

I got a new board to play with, it is a WiFi board that is programmable so that I will not need extra Arduino or other development board that will increase complexity or cost. The WiFi board is NodeMCU, it has GPIO, SPI, I2C, ADC and many more features on it. As the board is open sourced both in hardware and software terms, you may visit their github page to see the whole development package. The board’s price is quite cheap, well in Indonesia I got it for about 5USD.


NodeMCU board is preloaded with default firmware where you can code directly using Lua script. For Lua documentation of the board please visit user manual page  or clone the firmware source code and read the documentation.

The problem arose when actually not all of the modules was built into default firmware (besides, the firmware is pretty old 1.4 compared to the current version 2.1). Therefore, I need to compile the firmware by myself. There are several ways to compile the firmware :

  1. Online build service (easiest) where you can choose which modules to be embedded into the firmware and then after the build process is completed the link to the firmware will be emailed back to you
  2. Linux Docker Image
  3. Linux build environment which requires you full fledged Linux OS
  4. Linux on Windows (which will be covered here)

To be able install Linux subsystem on Windows there are several prerequisite :

  1. Windows 10 version 16215 or higher
  2. x64 machine

Go to Run and type Appwiz.cpl select Turn on Windows features on or off. Check Windows Subsystem for Linux


Then reboot the computer

Afterward, go to Microsoft Store and search Ubuntu


Select Ubuntu and InstallCaptureMSUbuntu

Then find the Ubuntu menu on your start menu.


Execute the following lines:

sudo apt–get update

sudo apt-get install  build-essential zip gdb git vim make unrar autoconf automake
bison texinfo libtool gcc g++ gperf libc-dbg ncurses-dev expat flex help2man
lua5.1 lua5.1-doc luarocks srecord python2.7

for m in bitlib luafilesystem md5 luaposix luasocket; do sudo luarocks install $m; done

git clone

You need to change your directory to your firmware source code in my case nodemcu-firmware-2.1.0-master_20170824

cd nodemcu-firmware-2.1.0-master_20170824

After cloning the latest firmware you need to setup the compiler

luarocks install luafilesystem

tar -Jxvf tools/esp-open-sdk.tar.xz

export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin

lua tools/cross-lua.lua || exit 1

To select which modules to be selected or deselected, you can change app/include/user_modules.h files. Uncomment the module if you think it is not necessary.

To enable TLS support check app/include/user_config.h and uncomment CLIENT_SSL_ENABLE

There are 2 version of firmware, one with floating number support and one with integer number. If you are dealing with floating number the float firmware is the correct choice.

Then you may compile the firmware using the following command

Float firmware

export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin

export BUILD_DATE=$(date +%Y%m%d)

make clean


cd bin/

srec_cat -output nodemcu_float_$BUILD_DATE.bin -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000

The build result will be in bin/nodemcu_float_$BUILD_DATE.bin

Integer firmware

export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin

export BUILD_DATE=$(date +%Y%m%d)

make clean


cd bin/

srec_cat -output nodemcu_integer_$BUILD_DATE.bin -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000

The build result will be in bin/nodemcu_integer_$BUILD_DATE.bin

There you go the firmware that you need (integer firmware)


I will post further about how to flash and create the first “hello world”program

Further readings:

Blog at