Tag Archives: wifi

How to upload nodemcu firmware with esptool

In the article about the Nodemcu firmware building

Nodemcu firmware building

we created in the bin folder the  0x0000.bin and 0x100000.bin files and copied the  blank.bin and esp_init_data_default.bin files from the Espressif SDK.

According to the esptool tool documentation


the generic  command to load the firmware is the following

In our case, as we have a development kit with 4M of flash and an 9600 USB bps we have to specify the following parameters

  • mode=dio
  • size=32m

 Always according to the esptool documention, not generating the firmware with docker, we merged the two files, 0x0000.bin and 0x100000.bin,  into the nodemcu_float.bin file

 For our development kit we need to use the other two files

  • esp_init_data_default.bin: default init data.
  • blank.bin: to reset the configuration.

according to the mapping available at the following link

ESP8266 Guide

In our case we have to use (4M flash)

  • 0x3FC000 address for  esp_init_data_default.bin.
  • 0x3FE000 address for blank.bin

In the shell command window move into nodemcu-firmware and set the PATH variable

Then execute the following commands, with /dev/ttyUSB0 as COM port of the nodemcu dev kit

  • Flash erase

  • Firmware upload

In the next article we’ll upload our custom LUA code on the nodemcu dev kit.

Lua sample code

Nodemcu compilation on Linux

We’ll cover the steps to follow to create your own Nodemcu image with cross compiling on Linux.

We always start from the Debian envinronment described in the previous article

Debian Envinronment

 According the following link

Cross Compilation

as first step we prepare the cross compiling envinronment.

Log on Debian with our development user (sviluppo in our case) and create an esp8266 folder in  a terminal window

We install the prerequisites

We download the open-esp-sdk repository

to proceed to its compilation

At the end of the compilation we have the following messages

So we have to include in the PATH variable the following

We can clone at this point the Nodemcu firmware github. Always from the previous terminal window run

Once placed in the esp8266 folder execute

At the end go into the nodemcu-firmware folder

Before proceeding to the creation of our first firmware we have to make  changes in the app / include / user_config.h file configuration:

  • We enable the directive for our devkit 0.9 (our devkit)

#define DEVKIT_VERSION_0_9 1     // define this only if you use NodeMCU devkit v0.9

  • We change the USB communication speed (speed for our devkit)

//#define BIT_RATE_DEFAULT BIT_RATE_115200

  • We change the flash size to 4M (flash of our nodemcu devkit)

#define FLASH_4M
// #define FLASH_8M
// #define FLASH_16M

We save the file and proceed to the creation of the firmware with the command

At the end under the bin folder

we’ll find two files: 0x00000.bin and 0x100000.bin. We generate a single file nodemcu_float.bin with the command

At this point we have to enable the sviluppo user to use the usb port with the command

Debian has no need for additional USB drivers. In the presence of virtual machine enable the USB device.

Access to the SDK downloaded and compiled previously; in the bin folder copy the files

  • blank.bin
  • esp_init_data_default.bin

into the folder we generated the 0x00000.bin and 0x100000.bin files

binDefaultAt this point we are able to flash the firmware on the device using the esptool. In the next article we’ll descrive how to load the firmware

Nodemcu firmware upload with esptool

Uploading LUA code on ESP8266

After flashing the nodemcu firmware

Flashing the firmware

you can upload your own LUA script code on your device. To do this there are several tools

Uploading LUA code

In this article we’ll treat  ESPlorer


It ‘a java application available for Windows, Linux and OSX. As a prerequisite requires the presence of Java SE ver. 7 or higher.

Download the tool from the link listed below to a folder

ESPlorer Download

To run it excecute from command prompt

or we can use a script in dos or unix (ESPlorer.bat or ESPlorer.sh).

At this point we plug the Nodemcu devkit to the PC and set the communication parameters and the speed of the COM port.

In Windows we have the following screen


You can press Open, which allows access to the device.


You can proceed at this point to the creation of your own code in LUA script and upload it on the ESP8266; you can use the various modules available in the  firmware according to the documentation

Nodemcu API

In the next article we’ll describe how to compile your personalized firmware in Linux

Nodemcu compilation

Flashing the firmware using Nodemcu Flasher

In the previous article we examined the different ways to flash the firmware

Flashing Nodemcu firmware

Now we describe how to proceed in Windows.

Looking at the Nodemcu firmware github

Nodemcu github

we find the followng application for Windows

 Nodemcu flasher

 We download the version compatible with our Windows operating system (32 or 64 bit)

First operation is to install the USB-Serial chip drivers of our Nodemcu Devkit, as specified in previous article. We have a devkit Nodemcu ver. 0.9, so we have to install the CH340G drivers

CH340G Drivers

After the drivers installation we can download the Nodemcu flasher in a folder and plug the  USB-Micro Usb cable between the pc and the devkit. Our COM port should be visible in the Windows device manager in the COM  devices list


In our case it is available on the COM port 5.

The steps to follow are the following:

  • Run Nodemcu Flasher and choose the COM5 port.


  • In Config select  INTERNAL://NODEMCU  with address 0x00000.


  •  In Advanced we have the following parameters
    • Baudate: 9600 as specified in our devkit.
    • Flash size: 4MByte. Flash size of our devkit.
    • Flash Speed: 40MHz. The default speed.
    • SPI Mode: DIO is the default for 4Mb flash size.


  • Proceed with the flash of the firmware pressing the FLASH button


  • The application shows a progress bar of the operation


At the end you can close the window and make sure everything is working properly using a LUA script uploader program, which we’ll see in the next article

Uploading LUA code


How to flash the Nodemcu firmware

In previous article we described the ESP8266 wifi module integrate into the Nodemcu development kit

ESP8266 WiFi Module

Here we look at how to load the firmware on the device.

First step is to assess the nodemcu development kit model we are working with. In our case we’ll perform the various operations with a development board Nodemcu V0.9. The USB-Serial chipset in this case is the CH340G

The drivers for this chipset can be downloaded directly from github of nodemcu

USB-Serial Drivers

To load the firmware, you can use the methods described in the Nodemcu site

Flashing Firmware

Basically there are two main methods:

  • Flash through the Windows Nodemcu Flasher tool

Nodemcu Flasher

  • Flash via a utility in Python to use in Linux, OSX or Windows


The Nodemcu flasher tool allows you to load a default firmware on the card  intuitively and quickly.

As can be seen from the above documentation of the  devkit you do not need to take any action on the pin GPI0 ESP to put the devive in flash mode; the flash operation and execution start automatically.

In the next article we’ll flash the firmware using the Nodemcu Flasher tool

Flashing the firmware with Nodemcu Flasher

Nodemcu Firmware

As discussed in previous article

ESP8266 WiFi Module

we’ll work on the ESP8266 SOC using the Nodemcu firmware

Firmware Nodemcu

Nodemcu is, to date at rev., based on LUA 5.1.4. It is based upon Expressif SDK NONOS

Expressif SDK NONOS

It uses the spiffs filesystem

spiffs filesystem

We can get the firmware, as specified at the link

Nodemcu building

with different methods

  • Using a cloud service, specifying the additional modules if required

Nodemcu Custom Build

  • Using a Docker system

Docker Nodemcu Build

  •  Using cross compilation under a Linux system

We’ll descrive how to install the cross compilation envinronment under our Debian machine described in previous post.

The easiest way to get a default firmware is to use the Nodemcu Flasher tool.

In the next article we’ll treat how to load the firmware using various tools, among which the Nodemcu Flasher tool

How to flash the Nodemcu firmware

ESP8266 Wifi Module

In this article we describe briefly the ESP8266 wifi chip from Espressif


This lower power SOC  contains a 32 bit RISC MCU and a wifi module. At the Espressif web site we can find the detailed informations about the ESP8266

ESP8266 Resources

The device datasheet is available in the following pdf document

ESP8266 Datasheet

The ESP8266 modules are available individually or in a development platform; the last system simplifies its usage as the development kit contains all the hardware to use rapidly the soc device; we are already ready to load the firmware and use the device.

On internet various web sites describe home automation or iot projects using this soc.

A reference site for the ESP8266 is

ESP8266 Forum

In the forum we can find the various systems utilized to develop applications for the ESP8266. The most relevant tools are

  • Arduino Ide

Arduino IDE

ESP8266 Arduino github

  • Espressif SDK

SDK Forum


  • PlatformIO


  • Nodemcu

Nodemcu at esp8266.com forum


Nodemcu github

We can buy the ESP8266 module from various internet online websites, for example ebay, as a single module

ESP8266 on ebay

or as a development kit

ESP8266 Development Kit

Different ESP8266  AI-Thinker modules are available


We’ll use the Nodemcu development kit. This kit contains the AI-Thinker ESP-12/ESP-12E modules. In the ebay search we have as results  ESP8266 ESP-01 modules too and development kits from other vendors.

On the Nodemcu github we can find the development kits we’ll use afterward. There are two versions

  • Nodemcu V1 (ESP-12E) development kit

Nodemcu devkit V1.0

  • Nodemcu  V0.9 (ESP-12) development kit

Nodemcu devkit V0.9

At the following link we can find the description of the different AI-Thinker modules and as obtain informations about the flash inside the device

ESP8266 Modules

From the Nodemcu github

Nodemcu Devkit

the pins available in the devkit 1.0  are the following

In next articles we’ll describe how to obtain the Nodemcu firmware, how to load it on the device, how to compile it and we’ll show some example using the LUA scripting language utilized by the Nodemcu firmware


with the LUA software modules available for the ESP8266

Nodemcu documentation

In the next article we’ll describe the Nodemcu firmware

Nodemcu Firmware

Building openwrt package

In the previous article

Building OpenWrt firmware

we described how to build the OpenWrt for the TP-Link TL-MR3420 V1 router. Now we show how to build a package, vsftpd, and install it using the shell command window

As for the firmware building execute

and access the section for this package, i.e.  Network->File Transfer, and enable it as moduleOpenWrtModulovsftpdSave the settings  in the .config file and execute

At the end of the task the package is available in the packages folder under the router platformOpenWrtModulovsftpdCompilatoTransfer the file on the router as root using scp (WinScp on windows) into the folder /tmp. In this case don’t update the packages repository using the web interface (if done reboot the device); log on to the router  using ssh as root and execute the command

OpenWrt offers many packages that allow you to greatly enhance the functionality of the device, but some packages require more resources, so you can install them on routers with more powerful hardware.

Building OpenWrt firmware

After the brief description of OpenWrt system in the previous article


we describe now how to build the firmware for our router.

We use as tartget device the TP-Link TL-MR3420 router version 1.

This model is in the list of the supported OpenWrt devices; here is the specific documentation for this device

TP-Link TL-MR3420

From the documentation we know that the SOC is an Atheros AR7241. This information will be used in the configruation phase of the buildin envinronment.  As a preliminary operation also download the original firmware of this router from the link

Original Firmware

In the page TP-Link TL-MR3420 we find the links to two differents versions of the OpenWrt firmware:

  • Firmware used to install OpenWrt: openwrt-15.05.1-ar71xx-generic-tl-mr3420-v1-squashfs-factory.bin.
  • Firmware used to update OpenWrt: openwrt-15.05.1-ar71xx-generic-tl-mr3420-v1-squashfs-sysupgrade.bin

If we have the original firmware in our device we must utilize the first one, while in the case of updates we use the second one..

We now execute the operation described in the link

OpenWrt Building

in the Debian envinronment installed in previous article

Debian Envinronment

In a shell command window we install the prerequisites as non root user (sviluppo in our case)

We create a folder OpenWrt under the home user folder (sviluppo in our case) and clone the repository. In this build we choose the stable branch 15.05

At the end of the git task, execute

We are now ready to build the firmware of the TP-Link TL-MR3420 V1.

Execute the command

and we choose as target Target System AR7xxx/AR9xxx as described in the following screenshotsOpenWrtmenuconfigWith the following choices we change the options

  • y: we buil it.
  • m: we build it as module.
  • n: we skip it.

At the following link

OpenWrt Building

we find all the documentation about the building.

In the Target System with enter we can choose our Target PlatformOpenWrtmenuconfigAtherosWe have to install the base packages to admin the system, so we access LuCI OptionOpenWrtmenuconfigLucithen CollectionsOpenWrtmenuconfigLuciCollectionsand at the end the luci package; with this option the system installs an http server tooOpenWrtmenuconfigLuciCollectionsBaseWe choose as modules some cryptographics packages in the kernel modules sectionsOpenWrtmenuconfigKernelModulesthen Cryptographic Api modulesOpenWrtmenuconfigKernelModulesCryptoApiand at the end the following modules merged into the firmware fileOpenWrtmenuconfigKernelModulesCryptoApioptionsYou should save the configuration in a file in order to use it again later. Finally save the configuration in the .config file.

We can now exit the menuconfig and execute the following command in the shell command window

This task checks for the prerequisites.

To build the firmware we execute

in verbose mode.

At the end of the task we can find the firmware in the atheros platform under the bin folder. In our case our images are highlighted in the following screenshotOpenWrtFirmwareWe can now flash the firmware.

WARNING: Before installing the firmware verify the recovery process of your router in the event of a problem, i.e how to start in recovery mode, flash via tftp, use JTAG, etc. The image installation on the device is at your own risk. We accept no responsibility if the installation leads to  malfunction or block of the device.

The OpenWrt web site describes all the vaious options to build the firmware and packages. In the next article

Building OpenWrt package

we’ll describe how to build and install from a shell window command the vsftpd package.

OpenWrt firmware

In this article we describe briefly OpenWrt


As stated in the above link OpenWrt is a linux distribution for wireless devices. It is available for different routers as listed in the following page

OpenWrt Supported Devices

The firmware is an open source one, it is modular with the possibility to use various packages.

At the following link we find the documentation about packages and the opkg command


After the OpenWrt firmware installation we can login using the ssh protocol in a unix shell command and check the installed packages, installable package and so on.

The command

shows the available packages for the device.

This command works if the list of the repositories is available in the opkg.conf file,

OpenWrt packages repositories

but the same operation is available trhrough the web interface

First we log on to the router with a browserOpenWrtLoginWe access to the Software sectionOpenWrtSoftwarepngWe press the Update lists buttonOpenWrtSoftwareUpdateListThe list is loadedOpenWrtSoftwareListNow we search for a package, for example vsftpdOpenWrtSoftwareUpdateListAfter the search we can proceed to the installationOpenWrtSoftwareInstallvsftpdWe can find it among the installed packagesOpenWrtSoftwarevsftpdInstallatoIn future articles we will describe how to build the image for your router along with an additional package

Building OpenWrt firmware