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
#define BIT_RATE_DEFAULT BIT_RATE_9600

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

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

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