Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions .github/workflows/publish-idf-rust-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ on:
default: '1.61.0.0'

jobs:
std-tags:
release-v4_4:
runs-on: ubuntu-latest
strategy:
matrix:
board: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3']
esp-idf: ['release/v4.4', 'master']
steps:
-
name: Checkout
Expand All @@ -38,17 +37,54 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
-
name: Build and push - ${{ matrix.board }}_${{ matrix.esp-idf }}_${{ github.event.inputs.toolchain-version }} tag
name: Build and push - ${{ matrix.board }}_v4.4_${{ github.event.inputs.toolchain-version }} tag
uses: docker/build-push-action@v2
with:
file: idf-rust.Dockerfile
file: idf-rust.Containerfile
build-args: |
XTENSA_TOOLCHAIN_VERSION=${{ github.event.inputs.toolchain-version }}
ESP_IDF_VERSION=${{ matrix.esp-idf }}
ESP_BOARD=${{ matrix.board }
ESP_IDF_VERSION=release/v4.4
ESP_BOARD=${{ matrix.board }}
context: .
platforms: linux/amd64, linux/arm64
push: true
tags: espressif/idf-rust:${{ matrix.board }}_${{ matrix.esp-idf }}_${{ github.event.inputs.toolchain-version }}
tags: espressif/idf-rust:${{ matrix.board }}_v4.4_${{ github.event.inputs.toolchain-version }}
master:
runs-on: ubuntu-latest
strategy:
matrix:
board: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3']
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.rust-build-branch }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
-
name: Build and push - ${{ matrix.board }}_master_${{ github.event.inputs.toolchain-version }} tag
uses: docker/build-push-action@v2
with:
file: idf-rust.Containerfile
build-args: |
XTENSA_TOOLCHAIN_VERSION=${{ github.event.inputs.toolchain-version }}
ESP_IDF_VERSION=master
ESP_BOARD=${{ matrix.board }}
context: .
platforms: linux/amd64, linux/arm64
push: true
tags: espressif/idf-rust:${{ matrix.board }}_master_${{ github.event.inputs.toolchain-version }}



21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,16 @@ When building for Xtensa targets, we need to [override the `esp` toolchain](http
idf.py build flash
```

## Podman/Docker Rust ESP environment
## Containers with Rust ESP environment

Alternatively, some container images, with pre-installed Rust and ESP-IDF, are published to Dockerhub and can be used to build Rust projects for ESP boards:

- [idf-rust](https://hub.docker.com/r/espressif/idf-rust) - contains only the toolchain.
- [idf-rust](https://hub.docker.com/r/espressif/idf-rust)
- Some tags contains only the toolchain. The naming convention for those tags is: `<xtensa-version>`
- Some tags contains full environment with esp-idf installed, [wokwi-server](https://github.com/MabezDev/wokwi-server)
and [web-flash](https://github.com/bjoernQ/esp-web-flash-server) to use them
in Dev Containers. This tags are generated for `linux/arm64` and `linux/amd64`,
and use the following naming convention: `<board>_<esp-idf>_<xtensa-version>`
- [idf-rust-examples](https://hub.docker.com/r/espressif/idf-rust-examples) - includes two examples: [rust-esp32-example](https://github.com/espressif/rust-esp32-example) and [rust-esp32-std-demo](https://github.com/ivmarkov/rust-esp32-std-demo).

Podman example with mapping multiple /dev/ttyUSB from host computer to the container:
Expand All @@ -233,9 +238,11 @@ docker run -it espressif/idf-rust-examples

If you are using the `idf-rust-examples` image, instructions will be displayed on the screen.

## Dev-Containers
## Dev Containers

There is also the option to integrate with Visual Studio Code using [remote containers](https://code.visualstudio.com/docs/remote/containers). With this method,
we would have a fully working environment to build projects in Rust for ESP boards
in VScode alongside useful settings and extensions, for more information,
please, refer to [esp-rs-devcontainer](https://github.com/SergioGasquez/esp-rs-devcontainer).
Dev Container support is offered for VS Code, Gitpod and GitHub Codespaces,
resulting in a fully working environment to develop for ESP boards in Rust,
flash and simulate projects with Wokwi from the container.

Template projects [esp-template](https://github.com/esp-rs/esp-template/) and
[esp-idf-template](https://github.com/esp-rs/esp-template/) include a question for Dev Containers support.
52 changes: 52 additions & 0 deletions idf-rust.Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Base image
ARG VARIANT=bullseye-slim
FROM debian:${VARIANT}
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
# Arguments
ARG CONTAINER_USER=esp
ARG CONTAINER_GROUP=esp
ARG NIGHTLY_TOOLCHAIN_VERSION=nightly
ARG XTENSA_TOOLCHAIN_VERSION=1.61.0.0
ARG ESP_IDF_VERSION=release/v4.4
ARG ESP_BOARD=esp32,esp32s2,esp32s3
ARG INSTALL_RUST_TOOLCHAIN=install-rust-toolchain.sh
# Install dependencies
RUN apt-get update \
&& apt-get install -y git curl gcc clang ninja-build libudev-dev unzip xz-utils \
python3 python3-pip python3-venv libusb-1.0-0 libssl-dev pkg-config libtinfo5 libpython2.7 \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
# Set user
RUN adduser --disabled-password --gecos "" ${CONTAINER_USER}
USER ${CONTAINER_USER}
WORKDIR /home/${CONTAINER_USER}
# Install rust toolchain(s), extra crates and esp-idf.
ENV PATH=${PATH}:/home/${CONTAINER_USER}/.cargo/bin
ADD --chown=${CONTAINER_USER}:${CONTAINER_GROUP} \
https://github.com/esp-rs/rust-build/releases/download/v${XTENSA_TOOLCHAIN_VERSION}/${INSTALL_RUST_TOOLCHAIN} \
${INSTALL_RUST_TOOLCHAIN}
RUN chmod a+x ${INSTALL_RUST_TOOLCHAIN} \
&& ./${INSTALL_RUST_TOOLCHAIN} \
--extra-crates "ldproxy cargo-espflash cargo-generate" \
--clear-cache "YES" \
--build-target "${ESP_BOARD}" \
--nightly-version "${NIGHTLY_TOOLCHAIN_VERSION}" \
--esp-idf-version "${ESP_IDF_VERSION}" \
--minified-esp-idf "YES" \
--export-file ${HOME}/export-esp.sh
# Install web-flash and wokwi-server
RUN curl -L https://github.com/bjoernQ/esp-web-flash-server/releases/latest/download/web-flash-x86_64-unknown-linux-gnu.zip \
-o /home/${CONTAINER_USER}/.cargo/bin/web-flash.zip \
&& unzip /home/${CONTAINER_USER}/.cargo/bin/web-flash.zip \
-d /home/${CONTAINER_USER}/.cargo/bin/ \
&& rm /home/${CONTAINER_USER}/.cargo/bin/web-flash.zip
RUN chmod u+x /home/${CONTAINER_USER}/.cargo/bin/web-flash
RUN curl -L https://github.com/MabezDev/wokwi-server/releases/latest/download/wokwi-server-x86_64-unknown-linux-gnu.zip \
-o /home/${CONTAINER_USER}/.cargo/bin/wokwi-server.zip \
&& unzip /home/${CONTAINER_USER}/.cargo/bin/wokwi-server.zip \
-d /home/${CONTAINER_USER}/.cargo/bin/ \
&& rm /home/${CONTAINER_USER}/.cargo/bin/wokwi-server.zip
RUN chmod u+x /home/${CONTAINER_USER}/.cargo/bin/wokwi-server
# Activate ESP-IDF and Xtensa Rust toolchain environment
RUN echo "source ${HOME}/export-esp.sh" >> ~/.bashrc