Run the Arduino command-line builder in a docker container. This image will take it from there and turn your Arduino project into a binary which you then can flash to the ESP8266/ESP32.
-
Application developers
They just need a ready-made firmware.
-
Occasional 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 has been created for purposes of the THiNX OpenSource IoT management platform.
Follow the instructions at https://docs.docker.com/get-started/.
Enter any Arduino project repository root. Builder expects thinx.yml file with build configuration (see Examples in THINX Device API Documentation). To build the project, just run:
docker run --rm -t -v `pwd`:/opt/workspace suculent/arduino-docker-build
Preparation
- Install and run
socat
to tunnel the X11
$ brew install socat
$ socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
- Insert your IP address here to display Arduino IDE using X11/socat
docker run --rm -ti -e DISPLAY=127.0.0.1:0 -v `pwd`:/opt/workspace suculent/arduino-docker-build
- Start terminal and change to the your Arduino project repository (that contains mandatory directory containing your .ino file). Then run:
docker run --rm -ti -v `pwd`:/opt/workspace suculent/arduino-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/arduino-docker-build
Note for Windows users
(Docker on) Windows handles paths slightly differently. The command thus becomes (c
equals C drive i.e. c:
):
docker run --rm -it -v //c/Users/<user>/<arduino-builder>:/opt/arduino-builder suculent/arduino-docker-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/"/opt/arduino-builder suculent/arduino-docker-build``
In case there is a lib
folder next to your .ino
file, it will be copied to the build path from your repository.
The firmware file is created in the bin
sub folder of your 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 ...
.
WORKDIR
Just an parametrization example, will deprecate or be used for additional libraries.
The builder is able to re-create designated environment.h (exact filename should be defined in thinx.yml) from environment.json. The environment.h is used to customize variables in project.
In case you need to modify GCC CFLAGS using environment variables, use the cflags
variable which will be passed to Arduino builder since 0.8.0.
There are several tools to flash the firmware to the ESP8266/ESP32. If you were to use esptool (like I do) you'd run:
esptool.py --port <seria-port> write_flash 0x00000 firmware.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 arduino
and docker
tags.
For bugs and improvement suggestions create an issue at https://github.com/suculent/arduino-docker-build/issues.
Thanks to Marcel Stoer who inspired me with his NodeMCU firmware builder on http://frightanic.com