Add Dockerfile and build script for ESP32 firmware

This commit is contained in:
2025-10-10 22:30:32 +02:00
parent 5cce419c74
commit 9f848dcc3f
2 changed files with 55 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
wget \
flex \
bison \
gperf \
python3 \
python3-pip \
python3-venv \
cmake \
ninja-build \
ccache \
libffi-dev \
libssl-dev \
dfu-util \
libusb-1.0-0 \
&& apt-get autoremove
WORKDIR /usr/src/
RUN mkdir -p ~/esp/firmware
RUN git clone --recursive https://github.com/espressif/esp-idf.git ~/esp/esp-idf
RUN cd ~/esp/esp-idf && ./install.sh esp32
ENV IDF_PATH=~/esp/esp-idf
RUN . $IDF_PATH/export.sh
COPY . ~/esp/firmware/
RUN cd ~/esp/firmware/
RUN idf.py set-target esp32
RUN idf.py menuconfig
RUN idf.py build
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -e
IMAGE_NAME="esp32-builder"
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
DOCKERFILE="$SCRIPT_DIR/Dockerfile"
BUILD_CTX="$SCRIPT_DIR"
DEST_BIN="$SCRIPT_DIR/build/esp32.bin"
docker build -t "$IMAGE_NAME" -f "$DOCKERFILE" "$BUILD_CTX"
mkdir -p "$(dirname "$DEST_BIN")"
docker run --rm "$IMAGE_NAME" \
cat /usr/src/build/esp32.bin > "$DEST_BIN"
esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 115200 write_flash 0x1000 firmware.bin \
|| { echo "To find the correct port run: ls /dev/cu.*. Then modify build-esp32.sh"; exit 1; }