Difference between revisions of "ESP8266 NodeMCU Firmware"

From ElectroDragon
Jump to navigation Jump to search
(Created page with "== Custom firmware == === Online custom-build, or Docker Build === * Could run from https://nodemcu-build.com/ * Docker build * Install docker, git clone or download nodemcu f...")
 
 
Line 58: Line 58:
 
* If the file large than 16K should edit main.c to change this:
 
* If the file large than 16K should edit main.c to change this:
 
  4*4*1024 = 16K, can change to 8*4*1024 = 32K
 
  4*4*1024 = 16K, can change to 8*4*1024 = 32K
 +
 +
 +
[[category: NodeMCU]]

Latest revision as of 13:01, 18 June 2020

Custom firmware

Online custom-build, or Docker Build

  • Could run from https://nodemcu-build.com/
  • Docker build
  • Install docker, git clone or download nodemcu firmware from github to your user directory for example c:\users\electrodragon\
git clone https://github.com/nodemcu/nodemcu-firmware.git
  • run command to generate bin firmware file, in windows folder c:/user/hechao/nodemcu-firmware/ can not be changed, for example:
docker run --rm -it -v //c/Users/electrodragon/nodemcu-firmware:/opt/nodemcu-firmware marcelstoer/nodemcu-build
  • run either integer or float only INTEGER or FLOAT
docker run -e "INTEGER_ONLY=1" --rm -it -v //c/Users/electrodragon/nodemcu-firmware:/opt/nodemcu-firmware marcelstoer/nodemcu-build
docker run -e "FLOAT_ONLY=1" --rm -it -v //c/Users/hechao/nodemcu-firmware:/opt/nodemcu-firmware marcelstoer/nodemcu-build

Build Details

Enable/disable Modules - user_modules.h

Edit app/include/user_modules.h and comment-out the #define statement for modules you don't need. Example:

...
#define LUA_USE_MODULES_MQTT
// #define LUA_USE_MODULES_COAP
// #define LUA_USE_MODULES_U8G
...

board related configuration - user_config.h

Enable smart config: in file /app/include/user_config.h

//#define WIFI_SMART_ENABLE

version related properties - user_version.h

#define NODE_VERSION    "NodeMCU 1.5.4.1 - custom build by electrodragon.com"
#ifndef BUILD_DATE  
#define BUILD_DATE        "2016-09-23"

Flashing details

  • Need to flash nodemcu firmware and your code bin firmware now together into target device
  • calculate your nodemcu firmware size for the code bin firmware address first, for example:
  1. use the nodemcu firmware, size on disk as below:

Nodemcu size on disc.png

  1. so the bits size is: 408KB + 4KB =412 KB, 412 KB*1024 = 421888, change from dec to hex by using "calculator" you get 67000
  2. so for the two firmware, the upload address should be:
0x00000 for nodemcu firmware bin
and 0x67000 for your code firmware bin
  1. Finally use esp download tool, combine bin function to combine the two bin files

Spiffy combine.png


Custom Lua to Bin file by Using SPIFFY

  • The following methods has too many bugs, main file spiffs also obsoleted, better do not use
  • Reference: spiffimg and spiffy use spiffs as core file

Setup

/home/esp8266/Share/nodemcu-firmware-master/spiffy
  • in spiffy folder, create build and run make, a few files will be generated into build folder
  • create files folder, files to store lua file like init.lua print ("Hello")
  • run spiffy to build the rom, before this, you may need delete file "spiff_rom.bin" first, this is the generated bin file
./build/spiffy
  • Open file spiff_rom.bin by ultraedit can see the original codes
  • If the file large than 16K should edit main.c to change this:
4*4*1024 = 16K, can change to 8*4*1024 = 32K