Skip to content

Instantly share code, notes, and snippets.

@executed
Created December 30, 2025 02:41
Show Gist options
  • Select an option

  • Save executed/5b03de649a681af07ab095120a109884 to your computer and use it in GitHub Desktop.

Select an option

Save executed/5b03de649a681af07ab095120a109884 to your computer and use it in GitHub Desktop.
myevic repository firmware building Dockerfile (not confirmed to be working on device, but compiles alright)
# Use Ubuntu 20.04 as base
FROM ubuntu:20.04
# Prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y \
wget \
bzip2 \
make \
git \
python3 \
python3-pip \
python3-setuptools \
libusb-1.0-0-dev \
libudev-dev \
build-essential \
python3-dev \
libjpeg-dev \
zlib1g-dev \
libfreetype6-dev \
libncurses5 \
&& rm -rf /var/lib/apt/lists/*
# 1. Install ARM GCC 6-2017-q2
# We use this specific version to match the project's era.
RUN wget -qO- https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 | tar -xj -C /opt \
&& mv /opt/gcc-arm-none-eabi-6-2017-q2-update /opt/gcc-arm
# Add toolchain to PATH
ENV PATH="/opt/gcc-arm/bin:${PATH}"
# 2. Fix Toolchain Paths for myevic
# The Makefile constructs a path like '/opt/gcc-arm/gcc/...' which doesn't exist (should be lib/gcc).
RUN ln -s /opt/gcc-arm/lib/gcc /opt/gcc-arm/gcc
# 3. Populate 'v7e-m' Library Directories with SOFTFP libraries
# The linker needs libraries in a 'v7e-m' subdirectory.
# We search for 'softfp' libraries (Soft ABI, FPU instructions) to match the build flags.
# If 'softfp' is not found, we fall back to the base 'v7e-m' (Soft ABI, Soft Float).
# Fix GCC libraries (libgcc.a)
RUN mkdir -p /opt/gcc-arm/lib/gcc/arm-none-eabi/6.3.1/v7e-m \
&& SRC=$(find /opt/gcc-arm/lib/gcc/arm-none-eabi/6.3.1 -name libgcc.a | grep "v7e-m" | grep "softfp" | head -n 1) \
&& if [ -z "$SRC" ]; then SRC=$(find /opt/gcc-arm/lib/gcc/arm-none-eabi/6.3.1 -name libgcc.a | grep "v7e-m" | grep -v "hard" | head -n 1); fi \
&& cp "$SRC" /opt/gcc-arm/lib/gcc/arm-none-eabi/6.3.1/v7e-m/
# Fix Standard libraries (libc.a, libm.a, libnosys.a)
RUN mkdir -p /opt/gcc-arm/arm-none-eabi/lib/v7e-m \
&& for lib in libc.a libm.a libnosys.a; do \
SRC=$(find /opt/gcc-arm/arm-none-eabi/lib -name "$lib" | grep "v7e-m" | grep "softfp" | head -n 1); \
if [ -z "$SRC" ]; then SRC=$(find /opt/gcc-arm/arm-none-eabi/lib -name "$lib" | grep "v7e-m" | grep -v "hard" | head -n 1); fi; \
cp "$SRC" /opt/gcc-arm/arm-none-eabi/lib/v7e-m/; \
done
# 4. Install Python dependencies
RUN pip3 install --upgrade pip setuptools wheel \
&& pip3 install pybind11 pillow crcmod
# 5. Install python-evic
RUN git clone https://github.com/ClockSelect/python-evic.git /tmp/python-evic \
&& cd /tmp/python-evic \
&& pip3 install . \
&& rm -rf /tmp/python-evic
# Set working directory
WORKDIR /usr/src/myevic
# 6. Copy local source code
COPY . .
# 7. Setup Nuvoton SDK (Library only)
RUN git clone --depth 1 https://github.com/OpenNuvoton/M451BSP.git /tmp/bsp \
&& mkdir -p nuvoton-sdk \
&& cp -r /tmp/bsp/Library nuvoton-sdk/ \
&& rm -rf /tmp/bsp
# 8. Build the firmware
ENV EVICSDK=.
RUN make
# 9. Output Command
CMD ["sh", "-c", "cp -v bin/myevic.bin /output/ && echo 'Build successful: myevic.bin copied to output.'"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment