Build custom NodeMCU firmware and flash it on ESP8266

Posted on by Wim Mostmans
ESP8266 on white paper

In this quick reference I’ll show you how to build the NodeMCU firmware from source and flash it on your ESP8266. In this case I used the ESP8266-01.

You can use these exact same steps to flash any version of ESP8266 but the way you will connect it to your FTDI will differ. A simple Google images search will help you to find the connection schema for your ESP8266 version.

How to connect ESP8266 01 wifi module to FTDI

  1. Clone the NodeMCU project git clone https://github.com/nodemcu/nodemcu-firmware.git. Or download it manually from GitHub if you’re not a command line lover.
  2. Open the nodemcu-firmware folder
  3. To enable and/or disable modules and settings in the firmware you can open /app/includes/user_config.h and /app/includes/user_modules.h and comment/uncomment what you need
  4. Run following Docker command sudo docker run --rm -ti -v `pwd`:/opt/nodemcu-firmware marcelstoer/nodemcu-build build. I need to run this as super user otherwise I get an error about the docker daemon not running.
  5. Wait for the command to finish and you’ll find your custom build firmware in the bin folder
  6. Install esptool using pip install esptool which we will use to flash the ESP8266
  7. Connect your ESP8266 to your FTDI using the diagram above. Do make sure your FTDI is 3.3v. If you use a 5v one you’ll toast your ESP. Trust me I’ve done this before. You can use a 5v FTDI but you’ll have to use a separate 3.3v power supply to power your ESP8266.
  8. Flash your ESP8266 using following command esptool.py --port <USB-kport-with-ESP8266> write_flash 0x00000 <NodeMCU-firmware-directory>/bin/nodemcu_[integer|float]_<Git-branch>.bin
  9. You can use a tool like ESPlorer to see if your flashed ESP8266 is working.

Pinout overview of the ESP8266 01 wifi module

Tip jar

Tip Jar

If you like this blog, leave a tip! Your tip will help provide the basic necessities which sustain this blog: coffee, beer and raincoats for surviving the pitiful Belgium climate.

Buy me a coffee
Wim Mostmans

About Wim Mostmans

Freelance full stack developer and Co-founder of the Employee Advocacy platform Ambassify, with a general interest for web technologies and electronics.

Leave a comment