Recently I’ve been doing some experimenting with the NodeMCU ESP8266 and ESP32-S chips to use in home automation, sending data back to my Samsung SmartThings system. The ESP32 is considered a development board and as such not everything works as expected. One of the issues I was having was the ADC isn’t very linear resulting in some of my analog inputs being pretty far off (over 4%). With that said the firmware is being updated pretty regularly so I wanted to compile a new version. I attempted to follow the instructions available (https://nodemcu.readthedocs.io/en/dev-esp32/en/build/) but was having trouble. Finally I created a Ubuntu 16.04.3 LTS virtual machine using VirtualBox but then ran into a bunch of other issues since it didn’t have any of the dependencies installed. Well after some experimenting I got it working and here are the steps:
- Install Ubuntu 16 (should work with 17 also)
- Update it (search for update and launch the software updater)
- Drop to a terminal (CTRL+ALT+T), typing each item, and press enter:
- sudo apt-get update
- sudo apt-get upgrade
- sudo apt-get install libncurses5-dev libncursesw5-dev flex bison gperf python-serial
- sudo apt-get install git
git clone --branch dev-esp32 --recurse-submodules https://github.com/nodemcu/nodemcu-firmware.git nodemcu-firmware-esp32“
You should now be able to select your config options and save a sdkconfig file that you can use to make the firmware. Now I couldn’t save the sdkconfig in the same directory and ended up saving it to my home directory then making a copy of the modemcu-firmware-esp32 directory, pasting the config in there, and running make from there to compile. I’m assuming this is because I used git to pull down the repo and its read only (compiling from the copy with my sdkconfig worked so I didn’t try to figure it out).
If you want to get fancy you can also share out your USB through VirtualBox and flash the chip from the virtual machine using make flash but I didn’t like that idea so I transferred out the NodeMCU.bin from the build directory to my host machine (Windows 10) and used NodeMCU-PyFlasher-2.0 to flash to firmware. Afterward I found that my ADC’s, while not 100% accurate, were a lot closer. Hopefully they keep making progress on this chip as it seems like a very capable replacement to the ESP8266.
4 thoughts on “Compiling NodeMCU ESP32 Firmware”
Could you share a compiled firmware for an ESP32 board? I tired to compile a NodeMCU firmware for a Lolin32 Lite board, but I couldn’t get it to work (it was constantly looping at start). I tried flashing it with a MicroPython bin file and it worked. So did the C code flashed from the Arduino IDE.
I just compiled this one today off of a fresh clone of the ESP32 IDF: http://allandynes.com/wp-content/uploads/2018/08/NodeMCU.zip See if that helps.
this helped a lot – only detail missing is a “sudo” in front of the “make”
However, my preferred automated build tool for NodeMCU wasn t available on the ESP32 yet. Compiling the firmware was required – this turned out to be a surprisingly user-friendly experience, so I thought I’d share it with you. If I had known it would be so quick, this chip wouldn’t have sat on my desk unused quite so long!