Clone and edit the NodeMCU firmware locally on your platform. This image will take it from there and turn your code into a binary which you then can flash to the ESP8266.
This is based on a patch by Chris MacGregor since moving Ubuntu 22.10.
I see 3 types of NodeMCU developers:
-
NodeMCU "application developers"
They just need a ready-made firmware. I created a cloud build service with a nice UI and configuration options for them.
-
Occasional NodeMCU firmware hackers
They don't need full control over the complete tool chain and don't want to setup a Linux VM with the build environment. This image is exactly for them!
-
NodeMCU firmware developers
They commit or contribute to the project on GitHub and need their own full fledged build environment with the complete tool chain. They still might find this Docker image useful.
+This image has been created for purposes of the THiNX OpenSource IoT management platform.
Follow the instructions at https://docs.docker.com/get-started/.
Docker runs on a VirtualBox VM which by default only shares the user directory from the underlying guest OS. On Windows that is c:/Users/<user>
and on Mac it's /Users/<user>
. Hence, you need to clone the NodeMCU firmware repository to your user directory. If you want to place it outside the user directory you need to adjust the VirtualBox VM sharing settings accordingly.
git clone https://github.com/nodemcu/nodemcu-firmware.git
Start Docker and change to the NodeMCU firmware directory (in the Docker console). Then run:
docker run --rm -ti -v `pwd`:/opt/nodemcu-firmware suculent/nodemcu-docker-build
Depending on the performance of your system it takes 1-3min until the compilation finishes. The first time you run this it takes longer because Docker needs to download the image and create a container.
docker pull suculent/nodemcu-docker-build
Note for Windows users
(Docker on) Windows handles paths slightly differently. You need to specify the full path to the NodeMCU firmware directory in the command and you need to add an extra forward slash (/
) to the Windows path. The command thus becomes (c
equals C drive i.e. c:
):
docker run --rm -it -v //c/Users/<user>/<nodemcu-firmware>:/opt/nodemcu-firmware marcelstoer/nodemcu-build
If the Windows path contains spaces it would have to be wrapped in quotes as usual on Windows.
docker run --rm -it -v "//c/Users/monster tune/<nodemcu-firmware>":/opt/nodemcu-firmware marcelstoer/nodemcu-build
The two firmware files (integer and float) are created in the bin
sub folder of your NodeMCU root directory. You will also find a mapfile in the bin
folder with the same name as the firmware file but with a .map
ending.
You can pass the following optional parameters to the Docker build like so docker run -e "<parameter>=value" -e ...
.
IMAGE_NAME
The default firmware file names arenodemcu_float|integer_<branch>_<timestamp>.bin
. If you define an image name it replaces the<branch>_<timestamp>
suffix and the full image names becomenodemcu_float|integer_<image_name>.bin
.INTEGER_ONLY
Set this to 1 if you don't need NodeMCU with floating support, cuts the build time in half.FLOAT_ONLY
Set this to 1 if you only need NodeMCU with floating support, cuts the build time in half.
This variant also intends to support thinx.yml
file that should allow for remote module configuration except for pre-populating filesystem with custom Lua files (and/or modules).
Format of the file should be as follows (supports is now disabled, because barely deleting module is not sufficient; Makefile needs to be edited first).
nodemcu:
modules:
c:
- coap
- crypto
- dhtlib
- driver
- esp-gdbstub
- fatfs
- http
- include
- libc
- lua
- lwip
- mapfile
- mbedtls
- misc
- modules
- mqtt
- net
- pcm
- platform
- pm
- sjson
- smart
- spiffs
- swTimer
- task
- tsl2561
- u8glib
- ucglib
- user
- websocket
- wofs
lua:
- bh1750
- bmp085
- dht_lib
- ds18b20
- ds3231
- email
- hdc1000
- http
- lm92
- mcp23008
- redis
- si7021
- thinx
- tsl2561
- yeelink
There are several tools to flash the firmware to the ESP8266. If you were to use esptool (like I do) you'd run:
esptool.py --port <USB-port-with-ESP8266> write_flash 0x00000 <NodeMCU-firmware-directory>/bin/nodemcu_[integer|float]_<Git-branch>.bin
Don't leave comments on Docker Hub that are intended to be support requests. First, Docker Hub doesn't notify me when you write them, second I can't properly reply and third even if I could often it doesn't make much sense to keep them around forever and a day. Instead ask a question on StackOverflow and assign the nodemcu
and docker
tags.
For bugs and improvement suggestions create an issue at https://github.com/suculent/nodemcu-docker-build/issues.
Thanks to Paul Sokolovsky who created and maintains esp-open-sdk.
Thanks to http://frightanic.com who created original NodeMCU Docker builder and inspired all variants by THiNX.