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.
5 FROM ubuntu:jammy-20240808
7 LABEL org.opencontainers.image.description=" This image is for building U-Boot inside a container"
9 # Make sure apt is happy
10 ENV DEBIAN_FRONTEND=noninteractive
13 RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib/apt/lists/*
14 RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
15 RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main | tee /etc/apt/sources.list.d/llvm.list
17 # Manually install the kernel.org "Crosstool" based toolchains for gcc-13.2.0
18 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-aarch64-linux.tar.xz | tar -C /opt -xJ
19 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-arc-linux.tar.xz | tar -C /opt -xJ
20 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ
21 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ
22 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-m68k-linux.tar.xz | tar -C /opt -xJ
23 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ
24 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-microblaze-linux.tar.xz | tar -C /opt -xJ
25 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-nios2-linux.tar.xz | tar -C /opt -xJ
26 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ
27 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ
28 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv32-linux.tar.xz | tar -C /opt -xJ
29 RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ
31 # Manually install other toolchains
32 RUN 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
34 # Update and install things from apt now
35 RUN apt-get update && apt-get install -y \
47 device-tree-compiler \
122 && rm -rf /var/lib/apt/lists/*
124 # Make kernels readable for libguestfs tools to work correctly
125 RUN chmod +r /boot/vmlinu*
127 # Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
128 RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
130 git checkout grub-2.06 && \
131 git config --global user.name "GitLab CI Runner" && \
133 git cherry-pick 049efdd72eb7baa7b2bf8884391ee7fe650da5a0 && \
134 git cherry-pick 403d6540cd608b2706cfa0cb4713f7e4b490ff45 && \
136 mkdir -p /opt/grub && \
137 ./configure --target=aarch64 --with-platform=efi \
139 TARGET_CC=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
140 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
141 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
142 TARGET_NM=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
143 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
145 ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
146 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
147 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
148 search search_fs_file search_fs_uuid search_label serial sleep test \
151 ./configure --target=arm --with-platform=efi \
153 TARGET_CC=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
154 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
155 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
156 TARGET_NM=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
157 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
159 ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
160 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
161 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
162 search search_fs_file search_fs_uuid search_label serial sleep test \
165 ./configure --target=riscv64 --with-platform=efi \
167 TARGET_CC=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
168 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
169 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
170 TARGET_NM=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
171 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
173 ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
174 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
175 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
176 search search_fs_file search_fs_uuid search_label serial sleep test \
180 RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
182 git checkout v8.2.0 && \
183 # config user.name and user.email to make 'git am' happy
184 git config user.name u-boot && \
186 git format-patch 0c7ffc977195~..0c7ffc977195 && \
187 git am 0001-hw-net-cadence_gem-Fix-MDIO_OP_xxx-values.patch && \
188 git cherry-pick d3c79c3974 && \
189 ./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" && \
190 make -j$(nproc) all install && \
194 RUN git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git /tmp/tf-a && \
196 git checkout v2.10.0 && \
197 cd tools/fiptool && \
199 mkdir -p /usr/local/bin && \
200 cp fiptool /usr/local/bin && \
203 # Build genimage (required by some targets to generate disk images)
204 RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \
205 cd /tmp/genimage-14 && \
209 rm -rf /tmp/genimage-14
212 RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \
222 RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \
231 RUN mkdir /tmp/trace && \
232 git clone https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git /tmp/trace/libtraceevent && \
233 cd /tmp/trace/libtraceevent && \
235 sudo make install && \
236 git clone https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git /tmp/trace/libtracefs && \
237 cd /tmp/trace/libtracefs && \
239 sudo make install && \
240 git clone https://github.com/rostedt/trace-cmd.git /tmp/trace/trace-cmd && \
241 cd /tmp/trace/trace-cmd && \
243 sudo make install && \
247 RUN wget -O - https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C /tmp -xJ && \
248 cd /tmp/coreboot-24.08 && \
249 make crossgcc-i386 CPUS=$(nproc) && \
250 make -C payloads/coreinfo olddefconfig && \
251 make -C payloads/coreinfo && \
252 make olddefconfig && \
253 echo CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y | tee -a .config && \
254 echo CONFIG_USE_OPTION_TABLE=y | tee -a .config && \
255 make olddefconfig && \
256 make -j $(nproc) && \
257 sudo mkdir /opt/coreboot && \
258 sudo cp build/coreboot.rom build/cbfstool /opt/coreboot/
260 # Create our user/group
261 RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
262 RUN useradd -m -U uboot
265 # Populate the cache for pip to use. Get these via wget as the
266 # COPY / ADD directives don't work as we need them to.
267 RUN wget -O /tmp/pytest-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/test/py/requirements.txt
268 RUN wget -O /tmp/sphinx-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/doc/sphinx/requirements.txt
269 RUN wget -O /tmp/buildman-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/tools/buildman/requirements.txt
270 RUN virtualenv -p /usr/bin/python3 /tmp/venv && \
271 . /tmp/venv/bin/activate && \
272 pip install -r /tmp/pytest-requirements.txt \
273 -r /tmp/sphinx-requirements.txt \
274 -r /tmp/buildman-requirements.txt && \
276 rm -rf /tmp/venv /tmp/*-requirements.txt
278 # Create the buildman config file
279 RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
280 RUN /bin/echo -e "kernelorg = /opt/gcc-13.2.0-nolibc/*" >> ~/.buildman
281 RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
282 RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
283 RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
284 RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;
287 RUN git clone https://android.googlesource.com/platform/system/tools/mkbootimg /home/uboot/mkbootimg
288 ENV PYTHONPATH "${PYTHONPATH}:/home/uboot/mkbootimg"