forked from apache/nuttx
/
Dockerfile
378 lines (333 loc) · 16.8 KB
/
Dockerfile
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
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
FROM ubuntu:20.04 AS builder-base
# NOTE WE ARE NOT REMOVEING APT CACHE.
# This should only be used for temp build images that artifacts will be copied from
RUN apt-get update -qq && apt-get install -y -qq \
curl \
patch \
xz-utils
###############################################################################
# Base image that should be used to prepare tools from nuttx-tools
###############################################################################
FROM builder-base AS nuttx-tools
RUN apt-get update -qq && DEBIAN_FRONTEND="noninteractive" apt-get install -y -qq \
bison \
cmake \
flex \
g++ \
gawk \
git \
gperf \
libncurses5-dev \
make
RUN mkdir /tools
WORKDIR /tools
RUN mkdir -p /tools/nuttx-tools
RUN curl -s -L https://bitbucket.org/nuttx/tools/get/9ad3e1ee75c7.tar.gz \
| tar -C nuttx-tools --strip-components=1 -xz
RUN mkdir bloaty -p \
&& git clone --depth 1 --branch v1.1 https://github.com/google/bloaty bloaty \
&& cd bloaty \
&& cmake -DCMAKE_SYSTEM_PREFIX_PATH=/tools/bloaty \
&& make install
RUN cd nuttx-tools/kconfig-frontends \
&& ./configure --enable-mconf --disable-gconf --disable-qconf --enable-static --prefix=/tools/kconfig-frontends \
&& make install
# Install Rust and targets supported from NuttX
ENV RUST_HOME=/tools/rust
ENV CARGO_HOME=$RUST_HOME/cargo
ENV RUSTUP_HOME=$RUST_HOME/rustup
RUN mkdir -p $CARGO_HOME \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& $CARGO_HOME/bin/rustup target add thumbv6m-none-eabi \
&& $CARGO_HOME/bin/rustup target add thumbv7m-none-eabi
CMD [ "/bin/bash" ]
###############################################################################
# Base image that should be used to prepare arch build images
###############################################################################
FROM builder-base AS nuttx-toolchain-base
RUN mkdir /tools
WORKDIR /tools
###############################################################################
# Build image for tool required by ARM builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-arm
# Download the latest ARM clang toolchain prebuilt by ARM
RUN mkdir clang-arm-none-eabi && \
curl -s -L "https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-14.0.0/LLVMEmbeddedToolchainForArm-14.0.0-linux.tar.gz" \
| tar -C clang-arm-none-eabi --strip-components 1 -xz
# Download the latest ARM GCC toolchain prebuilt by ARM
RUN mkdir gcc-arm-none-eabi && \
curl -s -L "https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz" \
| tar -C gcc-arm-none-eabi --strip-components 1 -xJ
###############################################################################
# Build image for tool required by ARM64 builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-arm64
# Download the latest ARM64 GCC toolchain prebuilt by ARM
RUN mkdir gcc-aarch64-none-elf && \
curl -s -L "https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar.xz" \
| tar -C gcc-aarch64-none-elf --strip-components 1 -xJ
###############################################################################
# Build image for tool required by Pinguino builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-pinguino
# Download the pinguino compilers. Note this includes both 8bit and 32bit
# toolchains and builds for multiple host systems. Only copy what is needed.
RUN mkdir pinguino-compilers && \
curl -s -L "https://github.com/PinguinoIDE/pinguino-compilers/archive/62db5158d7f6d41c6fadb05de81cc31dd81a1958.tar.gz" \
| tar -C pinguino-compilers --strip-components=2 --wildcards -xz */linux64
###############################################################################
# Build image for tool required by Renesas builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-renesas
# Build Renesas RX GCC toolchain
RUN apt-get update -qq && DEBIAN_FRONTEND="noninteractive" apt-get install -y -qq \
bison \
flex \
g++ \
gcc \
libncurses5-dev \
m4 \
make \
texinfo \
wget
# Download toolchain source code
RUN mkdir -p /tools/renesas-tools/source/binutils && \
curl -s -L "https://gcc-renesas.com/downloads/d.php?f=rx/binutils/4.8.4.201803-gnurx/rx_binutils2.24_2018Q3.tar.gz" \
| tar -C renesas-tools/source/binutils --strip-components=1 -xz
RUN mkdir -p /tools/renesas-tools/source/gcc && \
curl -s -L "https://gcc-renesas.com/downloads/d.php?f=rx/gcc/4.8.4.201803-gnurx/rx_gcc_4.8.4_2018Q3.tar.gz" \
| tar -C renesas-tools/source/gcc --strip-components=1 -xz
RUN mkdir -p /tools/renesas-tools/source/newlib && \
curl -s -L "https://gcc-renesas.com/downloads/d.php?f=rx/newlib/4.8.4.201803-gnurx/rx_newlib2.2.0_2018Q3.tar.gz" \
| tar -C renesas-tools/source/newlib --strip-components=1 -xz
# Install binutils
RUN cd renesas-tools/source/binutils && \
chmod +x ./configure ./mkinstalldirs && \
mkdir -p /tools/renesas-tools/build/binutils && cd /tools/renesas-tools/build/binutils && \
/tools/renesas-tools/source/binutils/configure --target=rx-elf --prefix=/tools/renesas-toolchain/rx-elf-gcc --disable-werror &&\
make && make install
ENV PATH="/tools/renesas-toolchain/rx-elf-gcc/bin:$PATH"
# Install gcc
RUN cd renesas-tools/source/gcc && \
chmod +x ./contrib/download_prerequisites ./configure ./move-if-change ./libgcc/mkheader.sh && \
./contrib/download_prerequisites && \
sed -i '1s/^/@documentencoding ISO-8859-1\n/' ./gcc/doc/gcc.texi && \
sed -i 's/@tex/\n&/g' ./gcc/doc/gcc.texi && sed -i 's/@end tex/\n&/g' ./gcc/doc/gcc.texi && \
mkdir -p /tools/renesas-tools/build/gcc && cd /tools/renesas-tools/build/gcc && \
/tools/renesas-tools/source/gcc/configure --target=rx-elf --prefix=/tools/renesas-toolchain/rx-elf-gcc \
--disable-shared --disable-multilib --disable-libssp --disable-libstdcxx-pch --disable-werror --enable-lto \
--enable-gold --with-pkgversion=GCC_Build_1.02 --with-newlib --enable-languages=c && \
make && make install
ENV PATH="/tools/renesas-toolchain/rx-elf-gcc/bin:$PATH"
# Install newlib
RUN cd renesas-tools/source/newlib && \
chmod +x ./configure && \
mkdir -p /tools/renesas-tools/build/newlib && cd /tools/renesas-tools/build/newlib && \
/tools/renesas-tools/source/newlib/configure --target=rx-elf --prefix=/tools/renesas-toolchain/rx-elf-gcc && \
make && make install
RUN cd /tools/renesas-tools/build/gcc && \
make && make install
###############################################################################
# Build image for tool required by RISCV builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-riscv
# Download the latest RISCV GCC toolchain prebuilt by SiFive
RUN mkdir riscv64-unknown-elf-gcc && \
curl -s -L "https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.12/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz" \
| tar -C riscv64-unknown-elf-gcc --strip-components 1 -xz
###############################################################################
# Build image for tool required by SPARC builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-sparc
# Download the SPARC GCC toolchain prebuilt by Gaisler
RUN mkdir sparc-gaisler-elf-gcc && \
curl -s -L "https://www.gaisler.com/anonftp/bcc2/bin/bcc-2.1.0-gcc-linux64.tar.xz" \
| tar -C sparc-gaisler-elf-gcc --strip-components 1 -xJ
###############################################################################
# Build image for tool required by ESP32 builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-esp32
# Download the latest ESP32 GCC toolchain prebuilt by Espressif
RUN mkdir -p xtensa-esp32-elf-gcc && \
curl -s -L "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32-elf-gcc8_4_0-esp-2021r1-linux-amd64.tar.gz" \
| tar -C xtensa-esp32-elf-gcc --strip-components 1 -xz
RUN mkdir -p xtensa-esp32s2-elf-gcc && \
curl -s -L "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1-linux-amd64.tar.gz" \
| tar -C xtensa-esp32s2-elf-gcc --strip-components 1 -xz
RUN mkdir -p xtensa-esp32s3-elf-gcc && \
curl -s -L "https://github.com/espressif/crosstool-NG/releases/download/esp-2021r1/xtensa-esp32s3-elf-gcc8_4_0-esp-2021r1-linux-amd64.tar.gz" \
| tar -C xtensa-esp32s3-elf-gcc --strip-components 1 -xz
RUN echo "ESP Binaries: 2022/01/26"
RUN mkdir -p /tools/blobs && cd /tools/blobs \
&& curl -s -L "https://github.com/espressif/esp-nuttx-bootloader/releases/download/latest/bootloader-esp32.bin" -o bootloader-esp32.bin \
&& curl -s -L "https://github.com/espressif/esp-nuttx-bootloader/releases/download/latest/bootloader-esp32c3.bin" -o bootloader-esp32c3.bin \
&& curl -s -L "https://github.com/espressif/esp-nuttx-bootloader/releases/download/latest/bootloader-esp32s2.bin" -o bootloader-esp32s2.bin \
&& curl -s -L "https://github.com/espressif/esp-nuttx-bootloader/releases/download/latest/bootloader-esp32s3.bin" -o bootloader-esp32s3.bin \
&& curl -s -L "https://github.com/espressif/esp-nuttx-bootloader/releases/download/latest/partition-table-esp32.bin" -o partition-table-esp32.bin \
&& curl -s -L "https://github.com/espressif/esp-nuttx-bootloader/releases/download/latest/partition-table-esp32c3.bin" -o partition-table-esp32c3.bin \
&& curl -s -L "https://github.com/espressif/esp-nuttx-bootloader/releases/download/latest/partition-table-esp32s2.bin" -o partition-table-esp32s2.bin \
&& curl -s -L "https://github.com/espressif/esp-nuttx-bootloader/releases/download/latest/partition-table-esp32s3.bin" -o partition-table-esp32s3.bin
###############################################################################
# Final Docker image used for running CI system. This includes all toolchains
# supported by the CI system.
###############################################################################
FROM ubuntu:20.04
LABEL maintainer="dev@nuttx.apache.org"
RUN dpkg --add-architecture i386
# This is used for the final images so make sure to not store apt cache
# Note: xtensa-esp32-elf-gdb is linked to libpython2.7
RUN apt-get update -qq && DEBIAN_FRONTEND="noninteractive" apt-get install -y -qq --no-install-recommends \
-o APT::Immediate-Configure=0 \
avr-libc \
build-essential \
ccache \
clang \
clang-tidy \
cmake \
curl \
gcc \
gcc-avr \
gcc-multilib \
genromfs \
gettext \
git \
lib32z1-dev \
libasound2-dev libasound2-dev:i386 \
libc6-dev-i386 \
libcurl4-openssl-dev \
libmp3lame-dev:i386 \
libmad0-dev:i386 \
libncurses5-dev \
libpulse-dev libpulse-dev:i386 \
libpython2.7 \
libtinfo5 \
libv4l-dev libv4l-dev:i386 \
libx11-dev libx11-dev:i386 \
libxext-dev libxext-dev:i386 \
linux-headers-generic \
linux-libc-dev:i386 \
ninja-build \
qemu-system-arm \
qemu-system-misc \
python3 \
python3-pip \
python-is-python3 \
u-boot-tools \
unzip \
wget \
xxd \
&& rm -rf /var/lib/apt/lists/*
# Configure out base setup for adding python packages
ENV PIP_DISABLE_PIP_VERSION_CHECK=true
# This disables the cache with value 0. We do not want caching as it
# increases the images size.
ENV PIP_NO_CACHE_DIR=0
# We are using the minimal python installation from the system so include
# setuptools and also wheel so we can use the binary releases of packages
# instead of requiring them to be compiled.
RUN pip3 install setuptools
RUN pip3 install wheel
# Install CodeChecker and use it to statically analyze the code.
RUN pip3 install CodeChecker
# Install cvt2utf to check for non-UTF characters.
RUN pip3 install cvt2utf
# Install pytest
RUN pip3 install cxxfilt
RUN pip3 install esptool
RUN pip3 install imgtool
RUN pip3 install kconfiglib
RUN pip3 install pexpect==4.8.0
RUN pip3 install pyelftools
RUN pip3 install pyserial==3.5
RUN pip3 install pytest==6.2.5
RUN pip3 install pytest-json==0.4.0
RUN pip3 install pytest-ordering==0.6
RUN pip3 install pytest-repeat==0.9.1
# Used to generate symbol table files
RUN mkdir /tools
WORKDIR /tools
# Pull in the tools we just built for nuttx
COPY --from=nuttx-tools /tools/bloaty/ bloaty/
ENV PATH="/tools/bloaty/bin:$PATH"
COPY --from=nuttx-tools /tools/kconfig-frontends/ kconfig-frontends/
ENV PATH="/tools/kconfig-frontends/bin:$PATH"
# Pull in the Rust toolchain including supported targets
COPY --from=nuttx-tools /tools/rust/ /tools/rust/
ENV CARGO_HOME=/tools/rust/cargo
ENV RUSTUP_HOME=/tools/rust/rustup
ENV PATH="/tools/rust/cargo/bin:$PATH"
# ARM toolchain
COPY --from=nuttx-toolchain-arm /tools/clang-arm-none-eabi/ clang-arm-none-eabi/
RUN cp /usr/bin/clang-extdef-mapping-10 clang-arm-none-eabi/bin/clang-extdef-mapping
ENV PATH="/tools/clang-arm-none-eabi/bin:$PATH"
COPY --from=nuttx-toolchain-arm /tools/gcc-arm-none-eabi/ gcc-arm-none-eabi/
ENV PATH="/tools/gcc-arm-none-eabi/bin:$PATH"
# ARM64 toolchain
COPY --from=nuttx-toolchain-arm64 /tools/gcc-aarch64-none-elf/ gcc-aarch64-none-elf/
ENV PATH="/tools/gcc-aarch64-none-elf/bin:$PATH"
# MIPS toolchain
COPY --from=nuttx-toolchain-pinguino /tools/pinguino-compilers/p32/ pinguino-compilers/p32/
ENV PATH="/tools/pinguino-compilers/p32/bin:$PATH"
# Renesas toolchain
COPY --from=nuttx-toolchain-renesas /tools/renesas-toolchain/rx-elf-gcc/ renesas-toolchain/rx-elf-gcc/
ENV PATH="/tools/renesas-toolchain/rx-elf-gcc/bin:$PATH"
# RISCV toolchain
COPY --from=nuttx-toolchain-riscv /tools/riscv64-unknown-elf-gcc/ riscv64-unknown-elf-gcc/
ENV PATH="/tools/riscv64-unknown-elf-gcc/bin:$PATH"
# SPARC toolchain
COPY --from=nuttx-toolchain-sparc /tools/sparc-gaisler-elf-gcc/ sparc-gaisler-elf-gcc/
ENV PATH="/tools/sparc-gaisler-elf-gcc/bin:$PATH"
# ESP32 toolchain
COPY --from=nuttx-toolchain-esp32 /tools/xtensa-esp32-elf-gcc/ xtensa-esp32-elf-gcc/
ENV PATH="/tools/xtensa-esp32-elf-gcc/bin:$PATH"
# ESP32-S2 toolchain
COPY --from=nuttx-toolchain-esp32 /tools/xtensa-esp32s2-elf-gcc/ xtensa-esp32s2-elf-gcc/
ENV PATH="/tools/xtensa-esp32s2-elf-gcc/bin:$PATH"
# ESP32-S3 toolchain
COPY --from=nuttx-toolchain-esp32 /tools/xtensa-esp32s3-elf-gcc/ xtensa-esp32s3-elf-gcc/
ENV PATH="/tools/xtensa-esp32s3-elf-gcc/bin:$PATH"
RUN mkdir -p /tools/blobs/esp-bins
COPY --from=nuttx-toolchain-esp32 /tools/blobs/* /tools/blobs/esp-bins/
# Configure ccache
RUN mkdir -p /tools/ccache/bin && \
ln -sf `which ccache` /tools/ccache/bin/aarch64-none-elf-gcc && \
ln -sf `which ccache` /tools/ccache/bin/aarch64-none-elf-g++ && \
ln -sf `which ccache` /tools/ccache/bin/arm-none-eabi-gcc && \
ln -sf `which ccache` /tools/ccache/bin/arm-none-eabi-g++ && \
ln -sf `which ccache` /tools/ccache/bin/avr-gcc && \
ln -sf `which ccache` /tools/ccache/bin/avr-g++ && \
ln -sf `which ccache` /tools/ccache/bin/cc && \
ln -sf `which ccache` /tools/ccache/bin/c++ && \
ln -sf `which ccache` /tools/ccache/bin/clang && \
ln -sf `which ccache` /tools/ccache/bin/clang++ && \
ln -sf `which ccache` /tools/ccache/bin/gcc && \
ln -sf `which ccache` /tools/ccache/bin/g++ && \
ln -sf `which ccache` /tools/ccache/bin/p32-gcc && \
ln -sf `which ccache` /tools/ccache/bin/rx-elf-gcc && \
ln -sf `which ccache` /tools/ccache/bin/riscv64-unknown-elf-gcc && \
ln -sf `which ccache` /tools/ccache/bin/riscv64-unknown-elf-g++ && \
ln -sf `which ccache` /tools/ccache/bin/sparc-gaisler-elf-gcc && \
ln -sf `which ccache` /tools/ccache/bin/sparc-gaisler-elf-g++ && \
ln -sf `which ccache` /tools/ccache/bin/xtensa-esp32-elf-gcc && \
ln -sf `which ccache` /tools/ccache/bin/xtensa-esp32-elf-g++ && \
ln -sf `which ccache` /tools/ccache/bin/xtensa-esp32s2-elf-gcc && \
ln -sf `which ccache` /tools/ccache/bin/xtensa-esp32s2-elf-g++ && \
ln -sf `which ccache` /tools/ccache/bin/xtensa-esp32s3-elf-gcc && \
ln -sf `which ccache` /tools/ccache/bin/xtensa-esp32s3-elf-g++
ENV PATH="/tools/ccache/bin:$PATH"
CMD [ "/bin/bash" ]