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
200 changes: 200 additions & 0 deletions Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
# Base Image (ci-base)
#
# This image contains all tools required for CI operation, except the Zephyr SDK.

FROM ubuntu:24.04

ARG USERNAME=user
ARG UID=1000
ARG GID=1000
ARG PYTHON_VENV_PATH=/opt/python/venv
ARG WGET_ARGS="-q --show-progress --progress=bar:force:noscroll"
ARG UBUNTU_MIRROR_ARCHIVE=archive.ubuntu.com/ubuntu
ARG UBUNTU_MIRROR_SECURITY=security.ubuntu.com/ubuntu
ARG UBUNTU_MIRROR_PORTS=ports.ubuntu.com/ubuntu-ports

ARG KITWARE_NINJA_VERSION=1.11.1.g95dee.kitware.jobserver-1
ENV KITWARE_NINJA_VERSION=$KITWARE_NINJA_VERSION
ARG CCACHE_VERSION=4.9.1
ENV CCACHE_VERSION=$CCACHE_VERSION
ARG DOXYGEN_VERSION=1.14.0
ENV DOXYGEN_VERSION=$DOXYGEN_VERSION
ARG RENODE_VERSION=1.15.3
ENV RENODE_VERSION=$RENODE_VERSION
ARG LLVM_VERSION=20
ENV LLVM_VERSION=$LLVM_VERSION
ARG BSIM_VERSION=v2.7
ENV BSIM_VERSION=$BSIM_VERSION
ARG SPARSE_VERSION=9212270048c3bd23f56c20a83d4f89b870b2b26e
ENV SPARSE_VERSION=$SPARSE_VERSION
ARG PROTOC_VERSION=21.7
ENV PROTOC_VERSION=$PROTOC_VERSION
ARG FVP_BASE_REVC_VERSION=11.27_19
ENV FVP_BASE_REVC_VERSION=$FVP_BASE_REVC_VERSION
ARG FVP_BASE_AEMV8R_VERSION=11.27_19
ENV FVP_BASE_AEMV8R_VERSION=$FVP_BASE_AEMV8R_VERSION
ARG FVP_CORSTONE300_VERSION=11.27_42
ENV FVP_CORSTONE300_VERSION=$FVP_CORSTONE300_VERSION
ARG FVP_CORSTONE310_VERSION=11.27_42
ENV FVP_CORSTONE310_VERSION=$FVP_CORSTONE310_VERSION
ARG FVP_CORSTONE315_VERSION=11.27_42
ENV FVP_CORSTONE315_VERSION=$FVP_CORSTONE315_VERSION
ARG FVP_CORSTONE320_VERSION=11.27_25
ENV FVP_CORSTONE320_VERSION=$FVP_CORSTONE320_VERSION

# Set default shell during Docker image build to bash
SHELL ["/bin/bash", "-eo", "pipefail", "-c"]

Expand Down Expand Up @@ -123,6 +155,17 @@ RUN <<EOF
libsdl2-dev:i386
fi

# Install LLVM and Clang
wget ${WGET_ARGS} https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
./llvm.sh ${LLVM_VERSION} all
rm -f llvm.sh

# Install Python 3.9 for FVP
add-apt-repository -y ppa:deadsnakes/ppa
apt-get update -y
apt-get install -y python3.9-dev

# Clean up stale packages
apt-get autoremove --purge -y

Expand All @@ -136,6 +179,10 @@ RUN <<EOF
popd
EOF

# Set build environment variables
ENV PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
ENV OVMF_FD_PATH=/usr/share/ovmf/OVMF.fd

# Initialise system locale
RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8
Expand Down Expand Up @@ -182,6 +229,159 @@ EOF
# Make Zephyr Python virtual environment available globally
ENV PATH=${PYTHON_VENV_PATH}/bin:$PATH

# Install Kitware ninja
# NOTE: Pre-built Kitware ninja binaries are only available for x86_64 host.
RUN <<EOF
if [ "${HOSTTYPE}" = "x86_64" ]; then
wget ${WGET_ARGS} https://github.com/Kitware/ninja/releases/download/v${KITWARE_NINJA_VERSION}/ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz
tar xf ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz -C /opt
ln -s /opt/ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu/ninja /usr/local/bin
rm ninja-${KITWARE_NINJA_VERSION}_x86_64-linux-gnu.tar.gz
fi
EOF

# Install ccache
# NOTE: Pre-built ccache binaries are only available for x86_64 host.
RUN <<EOF
if [ "${HOSTTYPE}" = "x86_64" ]; then
wget ${WGET_ARGS} https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz
tar xf ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz -C /opt
ln -s /opt/ccache-${CCACHE_VERSION}-linux-x86_64/ccache /usr/local/bin
rm ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz
fi
EOF

# Install Doxygen (x86 only)
# NOTE: Pre-built Doxygen binaries are only available for x86_64 host.
RUN <<EOF
if [ "${HOSTTYPE}" = "x86_64" ]; then
wget ${WGET_ARGS} "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt
ln -s /opt/doxygen-${DOXYGEN_VERSION}/bin/doxygen /usr/local/bin
rm doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
fi
EOF

# Install BSIM
# Note: west needs an extra folder level, so we create a link to the old location to be backwards compatible
RUN <<EOF
mkdir -p /opt/bsim_west
cd /opt/
west init -m https://github.com/zephyrproject-rtos/babblesim-manifest.git --mr ${BSIM_VERSION} bsim_west
cd bsim_west/bsim
west update
make everything -j 8
echo ${BSIM_VERSION} > ./version
chmod ag+w . -R
ln -s /opt/bsim_west/bsim /opt/bsim
EOF

# Install sparse package for static analysis
RUN <<EOF
mkdir -p /opt/sparse
cd /opt/sparse
git clone https://git.kernel.org/pub/scm/devel/sparse/sparse.git
cd sparse
git checkout ${SPARSE_VERSION}
make -j8
PREFIX=/opt/sparse make install
rm -rf /opt/sparse/sparse
EOF

# Install protobuf-compiler
RUN <<EOF
mkdir -p /opt/protoc
cd /opt/protoc
PROTOC_HOSTTYPE=$(case $HOSTTYPE in x86_64) echo "x86_64";; aarch64) echo "aarch_64";; esac)
wget ${WGET_ARGS} https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip
unzip protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip
ln -s /opt/protoc/bin/protoc /usr/local/bin
rm -f protoc-${PROTOC_VERSION}-linux-${PROTOC_HOSTTYPE}.zip
EOF

# Install renode (x86 only)
# NOTE: Renode is currently only available for x86_64 host.
# We're using the portable version of Renode, which is self-contained and includes dotnet
RUN <<EOF
if [ "${HOSTTYPE}" = "x86_64" ]; then
RENODE_FILE=renode-${RENODE_VERSION}.linux-portable-dotnet.tar.gz
wget ${WGET_ARGS} https://github.com/renode/renode/releases/download/v${RENODE_VERSION}/${RENODE_FILE}
mkdir -p /opt/renode
tar xf ${RENODE_FILE} -C /opt/renode --strip-components=1
rm ${RENODE_FILE}
pip3 install -r /opt/renode/tests/requirements.txt --no-cache-dir
fi
EOF

# Add renode to path, make sure not to use the host's path,
# see https://stackoverflow.com/a/65119275
ENV PATH="/opt/renode:$PATH"

# Install FVP
#
# Ecosystem FVP License permits redistribution (refer to the relevant license available in the container).
RUN <<EOF
mkdir -p /opt/fvps
cd /opt/fvps

if [ "${HOSTTYPE}" = "x86_64" ]; then
SUFFIX=""
else
SUFFIX="_armv8l"
fi

declare -A FVP_INSTALLABLE=(
["300"]="${FVP_CORSTONE300_VERSION}"
["310"]="${FVP_CORSTONE310_VERSION}"
["315"]="${FVP_CORSTONE315_VERSION}"
["320"]="${FVP_CORSTONE320_VERSION}"
)
for corstone in ${!FVP_INSTALLABLE[@]}; do
version_build="${FVP_INSTALLABLE[$corstone]}"
echo "Downloading Corstone-${corstone} ${version_build}"
wget ${WGET_ARGS} -O- https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Corstone-IoT/Corstone-${corstone}/FVP_Corstone_SSE-${corstone}_${version_build}_Linux64${SUFFIX}.tgz | tar xz
./FVP_Corstone_SSE-${corstone}.sh --no-interactive --i-agree-to-the-contained-eula -d /opt/fvps/Corstone-${corstone}
rm FVP_Corstone_SSE-${corstone}.sh
ln -s /opt/fvps/Corstone-${corstone}/models/*/FVP_* /usr/local/bin
done

declare -A FVP_EXTRACTABLE=(
["RevC-2xAEMvA"]="${FVP_BASE_REVC_VERSION}"
["AEMv8R"]="${FVP_BASE_AEMV8R_VERSION}"
)
for base in ${!FVP_EXTRACTABLE[@]}; do
version_build="${FVP_EXTRACTABLE[$base]}"
echo "Downloading Base-${base} ${FVP_EXTRACTABLE[$base]}"
IFS="_" read version build <<< "${version_build}"
wget ${WGET_ARGS} -O- https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Architecture/FM-${version}/FVP_Base_${base}_${version_build}_Linux64${SUFFIX}.tgz | tar xz
done

ln -s /opt/fvps/*_pkg/models/*/FVP_* /usr/local/bin
EOF

ENV ARMFVP_BIN_PATH=/usr/local/bin

# Set up Rust
RUN <<EOF
# Install Cargo package manager
wget -q -O- "https://sh.rustup.rs" | sh -s -- -y --default-toolchain 1.86

# Make Cargo globally available for subsequent steps
PATH=~/.cargo/bin:$PATH

# Install uefi-run utility
cargo install uefi-run --root /usr

# Install Rust target support required by Zephyr
rustup target install riscv32i-unknown-none-elf
rustup target install riscv64imac-unknown-none-elf
rustup target install thumbv6m-none-eabi
rustup target install thumbv7em-none-eabi
rustup target install thumbv7m-none-eabi
rustup target install thumbv8m.main-none-eabi
rustup target install x86_64-unknown-none
EOF

# Create user account
RUN <<EOF
# Remove 'ubuntu' user to free UID 1000
Expand Down
Loading