]>
Commit | Line | Data |
---|---|---|
a6432254 TR |
1 | # SPDX-License-Identifier: GPL-2.0+ |
2 | # This Dockerfile is used to build an image containing basic stuff to be used | |
3 | # to build U-Boot and run our test suites. | |
4 | ||
b0f5ae8e | 5 | FROM ubuntu:jammy-20240911.1 |
bcdd782d TR |
6 | LABEL org.opencontainers.image.authors="Tom Rini <[email protected]>" |
7 | LABEL org.opencontainers.image.description=" This image is for building U-Boot inside a container" | |
a6432254 | 8 | |
45b2f9d4 SG |
9 | # Used by docker to set the target platform: valid values are linux/arm64/v8 |
10 | # and linux/amd64 | |
11 | ARG TARGETPLATFORM | |
12 | ||
13 | # Used by docker to set the build platform: the only valid value is linux/amd64 | |
14 | ARG BUILDPLATFORM | |
15 | ||
a6432254 TR |
16 | # Make sure apt is happy |
17 | ENV DEBIAN_FRONTEND=noninteractive | |
18 | ||
939b29e5 SG |
19 | # Set architectures to build for (leaving out ARM which is an exception) |
20 | ENV ARCHS="aarch64 arc i386 m68k mips microblaze nios2 powerpc riscv64 riscv32 sh2 x86_64" | |
21 | ||
22 | # Mirror containing the toolchains | |
23 | ENV MIRROR=https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin | |
24 | ||
25 | # Toolchain version | |
26 | ENV TCVER=13.2.0 | |
27 | ||
45b2f9d4 SG |
28 | RUN echo "Building on $BUILDPLATFORM, for target $TARGETPLATFORM" |
29 | ||
a6432254 | 30 | # Add LLVM repository |
191e1454 TR |
31 | RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
32 | --mount=type=cache,target=/var/lib/apt,sharing=locked \ | |
33 | apt-get update && apt-get install -y gnupg2 wget xz-utils | |
a6432254 | 34 | RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - |
96afd8a3 | 35 | RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main | tee /etc/apt/sources.list.d/llvm.list |
a6432254 | 36 | |
939b29e5 SG |
37 | # Create a list of URLs to process, then pass them into a 'while read' loop |
38 | RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then HOSTARCH=x86_64; else HOSTARCH=arm64; fi; ( \ | |
39 | # Manually install the kernel.org "Crosstool"-based toolchains | |
40 | for arch in $ARCHS; do \ | |
41 | echo $MIRROR/$HOSTARCH/$TCVER/${HOSTARCH}-gcc-$TCVER-nolibc-${arch}-linux.tar.xz; \ | |
42 | done; \ | |
43 | \ | |
44 | # Deal with ARM, which has a 'gnueabi' suffix | |
45 | echo $MIRROR/${HOSTARCH}/$TCVER/${HOSTARCH}-gcc-$TCVER-nolibc-arm-linux-gnueabi.tar.xz; \ | |
46 | \ | |
47 | ) | while read url; do \ | |
48 | # Read the URL and unpack it into /opt | |
49 | wget -O - $url | tar -C /opt -xJ; \ | |
50 | done | |
a6432254 TR |
51 | |
52 | # Manually install other toolchains | |
939b29e5 SG |
53 | RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ |
54 | wget -O - https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz | tar -C /opt -xz; \ | |
55 | fi | |
a6432254 TR |
56 | |
57 | # Update and install things from apt now | |
191e1454 TR |
58 | RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
59 | --mount=type=cache,target=/var/lib/apt,sharing=locked \ | |
60 | apt-get update && apt-get install -y \ | |
a6432254 TR |
61 | automake \ |
62 | autopoint \ | |
63 | bc \ | |
64 | binutils-dev \ | |
65 | bison \ | |
66 | build-essential \ | |
f25820b1 | 67 | cgpt \ |
96afd8a3 | 68 | clang-17 \ |
a6432254 TR |
69 | coreutils \ |
70 | cpio \ | |
a6432254 TR |
71 | curl \ |
72 | device-tree-compiler \ | |
73 | dosfstools \ | |
74 | e2fsprogs \ | |
75 | efitools \ | |
2c30aa3d | 76 | erofs-utils \ |
8a87d1ae | 77 | expect \ |
a6432254 TR |
78 | fakeroot \ |
79 | flex \ | |
8a87d1ae | 80 | gawk \ |
a6432254 | 81 | gdisk \ |
70712a6a | 82 | gettext \ |
a6432254 TR |
83 | git \ |
84 | gnu-efi \ | |
8a87d1ae | 85 | gnutls-dev \ |
a6432254 | 86 | graphviz \ |
a6432254 TR |
87 | help2man \ |
88 | iasl \ | |
89 | imagemagick \ | |
90 | iputils-ping \ | |
3283a052 | 91 | libconfuse-dev \ |
b1c2102d | 92 | libgit2-dev \ |
8a87d1ae | 93 | libjson-glib-dev \ |
a6432254 | 94 | libguestfs-tools \ |
ad3616ed AT |
95 | libgnutls28-dev \ |
96 | libgnutls30 \ | |
a6432254 TR |
97 | liblz4-tool \ |
98 | libpixman-1-dev \ | |
b1c2102d | 99 | libpython3-dev \ |
a6432254 TR |
100 | libsdl1.2-dev \ |
101 | libsdl2-dev \ | |
8a87d1ae | 102 | libseccomp-dev \ |
b45ab9ca | 103 | libslirp-dev \ |
a6432254 | 104 | libssl-dev \ |
8a87d1ae | 105 | libtool \ |
a6432254 TR |
106 | libudev-dev \ |
107 | libusb-1.0-0-dev \ | |
6e510606 | 108 | linux-image-generic \ |
a6432254 TR |
109 | lzma-alone \ |
110 | lzop \ | |
111 | mount \ | |
112 | mtd-utils \ | |
113 | mtools \ | |
8a87d1ae | 114 | net-tools \ |
a30e53cc | 115 | ninja-build \ |
a6432254 TR |
116 | openssl \ |
117 | picocom \ | |
118 | parted \ | |
119 | pkg-config \ | |
b1c2102d TR |
120 | python-is-python3 \ |
121 | python2.7 \ | |
122 | python3 \ | |
123 | python3-dev \ | |
a6432254 | 124 | python3-pip \ |
33799266 | 125 | python3-pyelftools \ |
a6432254 | 126 | python3-sphinx \ |
b1c2102d | 127 | python3-virtualenv \ |
a6432254 TR |
128 | rpm2cpio \ |
129 | sbsigntool \ | |
8a87d1ae HS |
130 | socat \ |
131 | softhsm2 \ | |
a6432254 TR |
132 | sparse \ |
133 | srecord \ | |
134 | sudo \ | |
135 | swig \ | |
5f7a507e | 136 | texinfo \ |
a6432254 TR |
137 | util-linux \ |
138 | uuid-dev \ | |
139 | virtualenv \ | |
f25820b1 SG |
140 | vboot-kernel-utils \ |
141 | vboot-utils \ | |
d3f9078b | 142 | xilinx-bootgen \ |
7bb1cc3b | 143 | xxd \ |
191e1454 | 144 | zip |
a6432254 | 145 | |
f9abaa53 ANY |
146 | # Make kernels readable for libguestfs tools to work correctly |
147 | RUN chmod +r /boot/vmlinu* | |
148 | ||
a6432254 TR |
149 | # Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit |
150 | RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \ | |
151 | cd /tmp/grub && \ | |
70712a6a | 152 | git checkout grub-2.12 && \ |
09ed7e62 TR |
153 | git config --global user.name "GitLab CI Runner" && \ |
154 | git config --global user.email [email protected] && \ | |
a6432254 TR |
155 | ./bootstrap && \ |
156 | mkdir -p /opt/grub && \ | |
157 | ./configure --target=aarch64 --with-platform=efi \ | |
158 | CC=gcc \ | |
e54796e6 TR |
159 | TARGET_CC=/opt/gcc-${TCVER}-nolibc/aarch64-linux/bin/aarch64-linux-gcc \ |
160 | TARGET_OBJCOPY=/opt/gcc-${TCVER}-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \ | |
161 | TARGET_STRIP=/opt/gcc-${TCVER}-nolibc/aarch64-linux/bin/aarch64-linux-strip \ | |
162 | TARGET_NM=/opt/gcc-${TCVER}-nolibc/aarch64-linux/bin/aarch64-linux-nm \ | |
163 | TARGET_RANLIB=/opt/gcc-${TCVER}-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \ | |
2fc92695 | 164 | make -j$(nproc) && \ |
a6432254 TR |
165 | ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \ |
166 | grub-core cat chain configfile echo efinet ext2 fat halt help linux \ | |
167 | lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \ | |
168 | search search_fs_file search_fs_uuid search_label serial sleep test \ | |
169 | true && \ | |
170 | make clean && \ | |
171 | ./configure --target=arm --with-platform=efi \ | |
172 | CC=gcc \ | |
e54796e6 TR |
173 | TARGET_CC=/opt/gcc-${TCVER}-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \ |
174 | TARGET_OBJCOPY=/opt/gcc-${TCVER}-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \ | |
175 | TARGET_STRIP=/opt/gcc-${TCVER}-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \ | |
176 | TARGET_NM=/opt/gcc-${TCVER}-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \ | |
177 | TARGET_RANLIB=/opt/gcc-${TCVER}-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \ | |
2fc92695 | 178 | make -j$(nproc) && \ |
a6432254 TR |
179 | ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \ |
180 | grub-core cat chain configfile echo efinet ext2 fat halt help linux \ | |
181 | lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \ | |
182 | search search_fs_file search_fs_uuid search_label serial sleep test \ | |
183 | true && \ | |
184 | make clean && \ | |
185 | ./configure --target=riscv64 --with-platform=efi \ | |
186 | CC=gcc \ | |
e54796e6 TR |
187 | TARGET_CC=/opt/gcc-${TCVER}-nolibc/riscv64-linux/bin/riscv64-linux-gcc \ |
188 | TARGET_OBJCOPY=/opt/gcc-${TCVER}-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \ | |
189 | TARGET_STRIP=/opt/gcc-${TCVER}-nolibc/riscv64-linux/bin/riscv64-linux-strip \ | |
190 | TARGET_NM=/opt/gcc-${TCVER}-nolibc/riscv64-linux/bin/riscv64-linux-nm \ | |
191 | TARGET_RANLIB=/opt/gcc-${TCVER}-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \ | |
2fc92695 | 192 | make -j$(nproc) && \ |
a6432254 TR |
193 | ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \ |
194 | grub-core cat chain configfile echo efinet ext2 fat halt help linux \ | |
195 | lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \ | |
196 | search search_fs_file search_fs_uuid search_label serial sleep test \ | |
197 | true && \ | |
5fb78e0e TR |
198 | make clean && \ |
199 | ./configure --target=i386 --with-platform=efi \ | |
200 | CC=gcc \ | |
e54796e6 TR |
201 | TARGET_CC=/opt/gcc-${TCVER}-nolibc/i386-linux/bin/i386-linux-gcc \ |
202 | TARGET_OBJCOPY=/opt/gcc-${TCVER}-nolibc/i386-linux/bin/i386-linux-objcopy \ | |
203 | TARGET_STRIP=/opt/gcc-${TCVER}-nolibc/i386-linux/bin/i386-linux-strip \ | |
204 | TARGET_NM=/opt/gcc-${TCVER}-nolibc/i386-linux/bin/i386-linux-nm \ | |
205 | TARGET_RANLIB=/opt/gcc-${TCVER}-nolibc/i386-linux/bin/i386-linux-ranlib && \ | |
5fb78e0e TR |
206 | make -j$(nproc) && \ |
207 | ./grub-mkimage -O i386-efi -o /opt/grub/grub_x86.efi --prefix= -d \ | |
208 | grub-core normal echo lsefimmap lsefi lsefisystab efinet tftp minicmd && \ | |
209 | make clean && \ | |
210 | ./configure --target=x86_64 --with-platform=efi \ | |
211 | CC=gcc \ | |
e54796e6 TR |
212 | TARGET_CC=/opt/gcc-${TCVER}-nolibc/x86_64-linux/bin/x86_64-linux-gcc \ |
213 | TARGET_OBJCOPY=/opt/gcc-${TCVER}-nolibc/x86_64-linux/bin/x86_64-linux-objcopy \ | |
214 | TARGET_STRIP=/opt/gcc-${TCVER}-nolibc/x86_64-linux/bin/x86_64-linux-strip \ | |
215 | TARGET_NM=/opt/gcc-${TCVER}-nolibc/x86_64-linux/bin/x86_64-linux-nm \ | |
216 | TARGET_RANLIB=/opt/gcc-${TCVER}-nolibc/x86_64-linux/bin/x86_64-linux-ranlib && \ | |
5fb78e0e TR |
217 | make -j$(nproc) && \ |
218 | ./grub-mkimage -O x86_64-efi -o /opt/grub/grub_x64.efi --prefix= -d \ | |
219 | grub-core normal echo lsefimmap lsefi lsefisystab efinet tftp minicmd && \ | |
a6432254 TR |
220 | rm -rf /tmp/grub |
221 | ||
e38cdc68 | 222 | RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \ |
a6432254 | 223 | cd /tmp/qemu && \ |
50a907ed | 224 | git checkout v8.2.0 && \ |
a30e53cc BM |
225 | # config user.name and user.email to make 'git am' happy |
226 | git config user.name u-boot && \ | |
227 | git config user.email [email protected] && \ | |
50a907ed HS |
228 | git format-patch 0c7ffc977195~..0c7ffc977195 && \ |
229 | git am 0001-hw-net-cadence_gem-Fix-MDIO_OP_xxx-values.patch && \ | |
074bfab5 | 230 | git cherry-pick d3c79c3974 && \ |
3854706f | 231 | ./configure --prefix=/opt/qemu --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,m68k-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu" && \ |
a6432254 TR |
232 | make -j$(nproc) all install && \ |
233 | rm -rf /tmp/qemu | |
234 | ||
25296cf3 HS |
235 | # Build fiptool |
236 | RUN git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git /tmp/tf-a && \ | |
237 | cd /tmp/tf-a/ && \ | |
238 | git checkout v2.10.0 && \ | |
239 | cd tools/fiptool && \ | |
2fc92695 | 240 | make -j$(nproc) && \ |
25296cf3 HS |
241 | mkdir -p /usr/local/bin && \ |
242 | cp fiptool /usr/local/bin && \ | |
243 | rm -rf /tmp/tf-a | |
244 | ||
3283a052 BM |
245 | # Build genimage (required by some targets to generate disk images) |
246 | RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \ | |
247 | cd /tmp/genimage-14 && \ | |
248 | ./configure && \ | |
249 | make -j$(nproc) && \ | |
250 | make install && \ | |
251 | rm -rf /tmp/genimage-14 | |
252 | ||
8a87d1ae HS |
253 | # Build libtpms |
254 | RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \ | |
255 | cd /tmp/libtpms && \ | |
256 | ./autogen.sh && \ | |
257 | ./configure && \ | |
258 | make -j$(nproc) && \ | |
259 | make install && \ | |
260 | ldconfig && \ | |
261 | rm -rf /tmp/libtpms | |
262 | ||
263 | # Build swtpm | |
264 | RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \ | |
265 | cd /tmp/swtpm && \ | |
266 | ./autogen.sh && \ | |
267 | ./configure && \ | |
268 | make -j$(nproc) && \ | |
269 | make install && \ | |
270 | rm -rf /tmp/swtpm | |
271 | ||
71d3e794 SG |
272 | # Build trace-cmd |
273 | RUN mkdir /tmp/trace && \ | |
274 | git clone https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git /tmp/trace/libtraceevent && \ | |
275 | cd /tmp/trace/libtraceevent && \ | |
276 | make -j$(nproc) && \ | |
277 | sudo make install && \ | |
278 | git clone https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git /tmp/trace/libtracefs && \ | |
279 | cd /tmp/trace/libtracefs && \ | |
280 | make -j$(nproc) && \ | |
281 | sudo make install && \ | |
282 | git clone https://github.com/rostedt/trace-cmd.git /tmp/trace/trace-cmd && \ | |
283 | cd /tmp/trace/trace-cmd && \ | |
284 | make -j$(nproc) && \ | |
285 | sudo make install && \ | |
286 | rm -rf /tmp/trace | |
287 | ||
f3820508 | 288 | # Build coreboot |
1903aa72 SG |
289 | RUN wget -O - https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C /tmp -xJ && \ |
290 | cd /tmp/coreboot-24.08 && \ | |
f3820508 TR |
291 | make crossgcc-i386 CPUS=$(nproc) && \ |
292 | make -C payloads/coreinfo olddefconfig && \ | |
293 | make -C payloads/coreinfo && \ | |
294 | make olddefconfig && \ | |
1903aa72 SG |
295 | echo CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y | tee -a .config && \ |
296 | echo CONFIG_USE_OPTION_TABLE=y | tee -a .config && \ | |
297 | make olddefconfig && \ | |
f3820508 TR |
298 | make -j $(nproc) && \ |
299 | sudo mkdir /opt/coreboot && \ | |
300 | sudo cp build/coreboot.rom build/cbfstool /opt/coreboot/ | |
301 | ||
a6432254 TR |
302 | # Create our user/group |
303 | RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot | |
304 | RUN useradd -m -U uboot | |
305 | USER uboot:uboot | |
306 | ||
866f3020 TR |
307 | # Populate the cache for pip to use. Get these via wget as the |
308 | # COPY / ADD directives don't work as we need them to. | |
309 | RUN wget -O /tmp/pytest-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/test/py/requirements.txt | |
310 | RUN wget -O /tmp/sphinx-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/doc/sphinx/requirements.txt | |
3d878b83 | 311 | RUN wget -O /tmp/buildman-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/tools/buildman/requirements.txt |
866f3020 TR |
312 | RUN virtualenv -p /usr/bin/python3 /tmp/venv && \ |
313 | . /tmp/venv/bin/activate && \ | |
314 | pip install -r /tmp/pytest-requirements.txt \ | |
3d878b83 TR |
315 | -r /tmp/sphinx-requirements.txt \ |
316 | -r /tmp/buildman-requirements.txt && \ | |
866f3020 | 317 | deactivate && \ |
3d878b83 | 318 | rm -rf /tmp/venv /tmp/*-requirements.txt |
866f3020 | 319 | |
a6432254 | 320 | # Create the buildman config file |
9a873629 TR |
321 | RUN /bin/echo -e "[toolchain]\nkernelorg = /opt/gcc-${TCVER}-nolibc/*" > ~/.buildman |
322 | RUN /bin/echo -e "root = /usr" >> ~/.buildman | |
12d7be49 TR |
323 | RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ |
324 | /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman; \ | |
325 | fi | |
a18235dd TR |
326 | RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ |
327 | /bin/echo -e "\n[toolchain-prefix]\naarch64 = /opt/gcc-${TCVER}-nolibc/aarch64-linux/bin/aarch64-linux-" >> ~/.buildman; \ | |
328 | fi | |
a6432254 | 329 | RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman |
a6432254 | 330 | RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman; |
f4449397 SO |
331 | |
332 | # Add mkbootimg tool | |
333 | RUN git clone https://android.googlesource.com/platform/system/tools/mkbootimg /home/uboot/mkbootimg | |
ffbaa645 | 334 | ENV PYTHONPATH="${PYTHONPATH}:/home/uboot/mkbootimg" |