forked from zephyrproject-rtos/docker-image
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.base
More file actions
418 lines (370 loc) · 12.2 KB
/
Copy pathDockerfile.base
File metadata and controls
418 lines (370 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# 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.13.2
ENV CCACHE_VERSION=$CCACHE_VERSION
ARG DOXYGEN_VERSION=1.16.1
ENV DOXYGEN_VERSION=$DOXYGEN_VERSION
ARG RENODE_VERSION=1.16.0
ENV RENODE_VERSION=$RENODE_VERSION
ARG LLVM_VERSION=20
ENV LLVM_VERSION=$LLVM_VERSION
ARG BSIM_VERSION=v3.0.1
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
ARG FVP_CORSTONE1000_A320_VERSION=11.30_27
ENV FVP_CORSTONE1000_A320_VERSION=$FVP_CORSTONE1000_A320_VERSION
# Set default shell during Docker image build to bash
SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
# Set non-interactive frontend for apt-get to skip any user confirmations
ENV DEBIAN_FRONTEND=noninteractive
# Install APT packages
RUN <<EOF
# Set up custom Ubuntu APT mirrors
pushd /etc/apt/sources.list.d
cp ubuntu.sources ubuntu.sources.bak
sed -i "s#archive.ubuntu.com/ubuntu#${UBUNTU_MIRROR_ARCHIVE}#" ubuntu.sources
sed -i "s#security.ubuntu.com/ubuntu#${UBUNTU_MIRROR_SECURITY}#" ubuntu.sources
sed -i "s#ports.ubuntu.com/ubuntu-ports#${UBUNTU_MIRROR_PORTS}#" ubuntu.sources
popd
# Enable 32-bit package support for x86-64
if [ "${HOSTTYPE}" = "x86_64" ]; then
dpkg --add-architecture i386
fi
# Upgrade system packages
apt-get -y update
apt-get -y upgrade
# Install base packages
apt-get install --no-install-recommends -y \
software-properties-common \
lsb-release \
autoconf \
automake \
bison \
build-essential \
ca-certificates \
chrpath \
cmake \
cpio \
device-tree-compiler \
dfu-util \
diffstat \
dos2unix \
doxygen \
file \
flex \
g++ \
gawk \
gcc \
gcovr \
gdb \
gdisk \
git \
git-core \
gnupg \
gperf \
graphviz \
help2man \
iproute2 \
lcov \
libcairo2-dev \
libfuse3-dev \
libglib2.0-dev \
libgtk2.0-0 \
liblocale-gettext-perl \
libncurses5-dev \
libpcap-dev \
libpopt0 \
libsdl1.2-dev \
libsdl2-dev \
libssl-dev \
libtool \
libtool-bin \
locales \
make \
net-tools \
nodejs \
npm \
openssh-client \
parallel \
pkg-config \
python3 \
python3-dev \
python3-pip \
python3-ply \
python3-setuptools \
python3-venv \
python-is-python3 \
rsync \
socat \
srecord \
sudo \
texinfo \
unzip \
uuid-runtime \
valgrind \
wget \
ovmf \
xz-utils \
thrift-compiler
# Install x86-64 image-specific packages
if [ "${HOSTTYPE}" = "x86_64" ]; then
# Mark `python3` as held because APT otherwise tries to remove it during i386
# package installation.
apt-mark hold python3 python3-apt
# Install multi-lib gcc
apt-get install --no-install-recommends -y \
gcc-multilib \
g++-multilib
# Install 32-bit dependencies
apt-get install --no-install-recommends -y \
libc6-dbg:i386 \
libfuse-dev:i386 \
libfuse3-dev:i386 \
libsdl2-dev:i386
fi
# Install LLVM and Clang
apt-get install --no-install-recommends -y \
clang-${LLVM_VERSION} \
clang-format-${LLVM_VERSION} \
clang-tidy-${LLVM_VERSION} \
clang-tools-${LLVM_VERSION} \
clangd-${LLVM_VERSION} \
libc++-${LLVM_VERSION}-dev \
libclang-rt-${LLVM_VERSION}-dev \
lld-${LLVM_VERSION} \
lldb-${LLVM_VERSION} \
llvm-${LLVM_VERSION} \
llvm-${LLVM_VERSION}-dev
# 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
# Clean up local repository
apt-get clean -y
rm -rf /var/lib/apt/lists/*
# Restore original Ubuntu mirrors
pushd /etc/apt/sources.list.d
mv -f ubuntu.sources.bak ubuntu.sources
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
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
# Set up Python virtual environment for Zephyr
RUN <<EOF
# Initialise virtual environment
mkdir -p ${PYTHON_VENV_PATH}
python3 -m venv ${PYTHON_VENV_PATH}
# Activate virtual environment for subsequent steps
source ${PYTHON_VENV_PATH}/bin/activate
# Install pip package manager
pip install --no-cache-dir --upgrade pip setuptools wheel
# Install Zephyr requirements
pip install --no-cache-dir \
-r https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/main/scripts/requirements.txt \
-r https://raw.githubusercontent.com/zephyrproject-rtos/mcuboot/main/scripts/requirements.txt \
-r https://raw.githubusercontent.com/zephyrproject-rtos/trusted-firmware-m/zephyr_tf-m_v2.2.2/tools/requirements.txt \
'esptool>=5.0.2' \
GitPython \
junitparser \
junit2html \
nrf-regtool~=9.0.1 \
numpy \
protobuf \
grpcio-tools \
PyGithub \
pylint \
sh \
statistics \
west
# Run pip check (x86 only for now because it fails on ARM)
if [ "${HOSTTYPE}" = "x86_64" ]; then
pip check
fi
EOF
# Make Zephyr Python virtual environment available globally
ENV PATH=${PYTHON_VENV_PATH}/bin:$PATH
# Install Kitware ninja
RUN <<EOF
NINJA_BASENAME=ninja-${KITWARE_NINJA_VERSION}_${HOSTTYPE}-linux-gnu
wget ${WGET_ARGS} https://github.com/Kitware/ninja/releases/download/v${KITWARE_NINJA_VERSION}/${NINJA_BASENAME}.tar.gz
tar xf ${NINJA_BASENAME}.tar.gz -C /opt
ln -s /opt/${NINJA_BASENAME}/ninja /usr/local/bin
rm ${NINJA_BASENAME}.tar.gz
EOF
# Install ccache
RUN <<EOF
CCACHE_BASENAME=ccache-${CCACHE_VERSION}-linux-${HOSTTYPE}-glibc
wget ${WGET_ARGS} https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/${CCACHE_BASENAME}.tar.xz
tar xf ${CCACHE_BASENAME}.tar.xz -C /opt
ln -s /opt/${CCACHE_BASENAME}/ccache /usr/local/bin
rm ${CCACHE_BASENAME}.tar.xz
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
ENV BSIM_OUT_PATH=/opt/bsim
ENV BSIM_COMPONENTS_PATH=/opt/bsim/components
# 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
# We're using the portable version of Renode, which is self-contained and includes dotnet
RUN <<EOF
[ "${HOSTTYPE}" = "aarch64" ] && ARCH_SUFFIX="-arm64"
RENODE_FILE=renode-${RENODE_VERSION}.linux${ARCH_SUFFIX}-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
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
# Corstone-1000-A320 uses a different URL pattern (not SSE)
echo "Downloading Corstone-1000-A320 ${FVP_CORSTONE1000_A320_VERSION}"
wget ${WGET_ARGS} -O- https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Corstone-IoT/Corstone-1000-with-Cortex-A320/FVP_Corstone_1000-A320_${FVP_CORSTONE1000_A320_VERSION}_Linux64${SUFFIX}.tgz | tar xz
./FVP_Corstone_1000-A320.sh --no-interactive --i-agree-to-the-contained-eula -d /opt/fvps/Corstone-1000-A320
rm FVP_Corstone_1000-A320.sh
ln -s /opt/fvps/Corstone-1000-A320/models/*/FVP_* /usr/local/bin
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
userdel -r ubuntu || true
# Create user group and user account
groupadd -g $GID -o $USERNAME
useradd -u $UID -m -g $USERNAME -G plugdev $USERNAME
# Add user account to sudoers
echo $USERNAME ' ALL = NOPASSWD: ALL' > /etc/sudoers.d/$USERNAME
chmod 0440 /etc/sudoers.d/$USERNAME
EOF
# Ensure that container runs in the 'root' user context
USER root