Container image with pre-built rust compiler for ESP32/ESP8266
This is a container which can be used to build a Rust project for the ESP32.
This container image provides a few tools which can be run like this:
docker run -ti -v $PWD:/home/project:z quay.io/ctron/rust-esp:latest
-tito attach the console, to show you the output and let you interact with the application running inside the container.
Note: Consider running the container with
--rmas well. This prevents Docker from keeping the container around after it exited. As all your sources are mapped from the host's file system into the container, you don't need to keep the container on disk, and can safe some disk storage.
-v $PWD:/home/project:zwill map the current directory into the location
/home/projectinside the container. This is required so that the tools inside the container can work with the project.
$PWDgets replaced by the shell with the current directory. This will only work in a Bourne like shell. On Windows you can use
%CD%instead. You can of course also replace this with the absolute path to your project.
You can drop the
:zsuffix, if you don't have SElinux on the host system.
All following examples use
$PWD:/home/project:z, replace this as required by your environment.
This will run the default command
build-project. This will try an automic full build, see below.
You can run other commands by providing a command manually:
docker run -ti -v $PWD:/home/project:z quay.io/ctron/rust-esp my-command-in-the-container
As you can run other commands, and the container is just a normal Linux, you can simply run
bashin the container and directly work there. Without the need to run docker with each command:
docker run -ti -v $PWD:/home/project:z quay.io/ctron/rust-esp bash
masterbranch of this repository will build into the
latesttag, which is also the default if you omit the
:latestsuffix in the container name.
Each git tag will also be build into a container image tag, so e.g. git tag
0.0.1, will be built into the container tag
So should the
latestimage break, it should always be possible to switch to a previous version.
There is also the
:developtag, which is based on the
developbranch in Git. It is used to try out new changes before merging into master.
Initially a few files need to be set up. The ESP-IDF components need to be configured and compiled. Run the following command to create an initial setup:
docker run -ti -v $PWD:/home/project:z quay.io/ctron/rust-esp create-project
This will create (overwrite) a few files, which are required to build the project.
docker run -ti -v $PWD:/home/project:z quay.io/ctron/rust-esp make menuconfig
Which will start the ESP-IDF build and shows you the menu config tool for configuring your ESP project. Be sure to save when you exit.
In order to build the project, run the following command:
docker run -ti -v $PWD:/home/project:z quay.io/ctron/rust-esp build-project
This will compile the ESP-IDF part, the rust part and finally convert it to an image which you can upload to your ESP.
You can then upload the image using the
docker run -ti --device=/dev/ttyUSB0 -v $PWD:/home/project:z rust-esp32 flash-project
If this doesn't work or you need to use differnt tool it might be easier to upload the image via
esptoolfrom the host machine. To do this call:
esptool write_flash 0x10000 esp-app.bin
You can also build the container image yourself, by cloning this repository and executing:
docker build . -t rust-esp
make menuconfigrenders a bit weird. The new Windows terminal improves this a lot.
make appwill run just fine, but after that it fails to compile. Maybe some issue with the Windows CIFS mapping in Docker. However, you can skip this step and run
xbuild-projectinstead. That will only compile the rust part.
This work is built upn the work of others. Please see: