root@fandigunawan

November 23, 2017

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.

CaptureNodeMCU

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

CaptureWinSubsystem.PNG

Then reboot the computer

Afterward, go to Microsoft Store and search Ubuntu

CaptureMSStore

Select Ubuntu and InstallCaptureMSUbuntu

Then find the Ubuntu menu on your start menu.

CaptureUbuntu

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 https://github.com/nodemcu/nodemcu-firmware.git

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

make EXTRA_CCFLAGS=”-DBUILD_DATE=’\”‘$BUILD_DATE’\”‘” all

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

make EXTRA_CCFLAGS=”-DLUA_NUMBER_INTEGRAL -DBUILD_DATE=’\”‘$BUILD_DATE’\”‘” all

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)

CaptureFW

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

Further readings:

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: