blob: 0f6890b782180566d11a7946c2f5633a81e4e4e3 [file] [log] [blame]
Tom Rini04549e92021-03-15 13:19:01 -04001# 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
Tom Rinie0c84c82024-08-21 09:41:20 -06005FROM ubuntu:jammy-20240808
Tom Rini92160da2024-08-19 15:07:19 -06006LABEL org.opencontainers.image.authors="Tom Rini <trini@konsulko.com>"
7LABEL org.opencontainers.image.description=" This image is for building U-Boot inside a container"
Tom Rini04549e92021-03-15 13:19:01 -04008
9# Make sure apt is happy
10ENV DEBIAN_FRONTEND=noninteractive
11
12# Add LLVM repository
13RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib/apt/lists/*
14RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
Tom Rinie752a3a2024-03-10 15:59:28 -040015RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main | tee /etc/apt/sources.list.d/llvm.list
Tom Rini04549e92021-03-15 13:19:01 -040016
Tom Rini3bd5ed72023-08-25 13:21:26 -040017# Manually install the kernel.org "Crosstool" based toolchains for gcc-13.2.0
18RUN 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
19RUN 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
20RUN 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
21RUN 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
22RUN 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
23RUN 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
24RUN 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
25RUN 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
26RUN 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
27RUN 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
28RUN 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
29RUN 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
Tom Rinif3fb9cd2024-11-27 11:17:21 -060030RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-x86_64-linux.tar.xz | tar -C /opt -xJ
Tom Rini04549e92021-03-15 13:19:01 -040031
32# Manually install other toolchains
Tom Rini0a78bc32021-07-02 10:41:58 -040033RUN 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
Tom Rini04549e92021-03-15 13:19:01 -040034
35# Update and install things from apt now
36RUN apt-get update && apt-get install -y \
37 automake \
38 autopoint \
39 bc \
40 binutils-dev \
41 bison \
42 build-essential \
Simon Glassbe17cb32023-08-24 13:55:46 -060043 cgpt \
Tom Rinie752a3a2024-03-10 15:59:28 -040044 clang-17 \
Tom Rini04549e92021-03-15 13:19:01 -040045 coreutils \
46 cpio \
Tom Rini04549e92021-03-15 13:19:01 -040047 curl \
48 device-tree-compiler \
49 dosfstools \
50 e2fsprogs \
51 efitools \
Huang Jianan11e04432022-02-26 15:05:51 +080052 erofs-utils \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010053 expect \
Tom Rini04549e92021-03-15 13:19:01 -040054 fakeroot \
55 flex \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010056 gawk \
Tom Rini04549e92021-03-15 13:19:01 -040057 gdisk \
58 git \
59 gnu-efi \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010060 gnutls-dev \
Tom Rini04549e92021-03-15 13:19:01 -040061 graphviz \
62 grub-efi-amd64-bin \
63 grub-efi-ia32-bin \
64 help2man \
65 iasl \
66 imagemagick \
67 iputils-ping \
Tom Riniac6c3332023-01-11 12:24:57 -050068 libc6-i386 \
Bin Mengf551a532021-08-26 23:33:33 +080069 libconfuse-dev \
Tom Rinic8982d22021-06-10 10:57:36 -040070 libgit2-dev \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010071 libjson-glib-dev \
Tom Rini04549e92021-03-15 13:19:01 -040072 libguestfs-tools \
AKASHI Takahiro3edc3472022-02-01 10:32:36 +090073 libgnutls28-dev \
74 libgnutls30 \
Tom Rini04549e92021-03-15 13:19:01 -040075 liblz4-tool \
76 libpixman-1-dev \
Tom Rinic8982d22021-06-10 10:57:36 -040077 libpython3-dev \
Tom Rini04549e92021-03-15 13:19:01 -040078 libsdl1.2-dev \
79 libsdl2-dev \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010080 libseccomp-dev \
Tom Rini83da2322023-07-13 10:16:28 -040081 libslirp-dev \
Tom Rini04549e92021-03-15 13:19:01 -040082 libssl-dev \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010083 libtool \
Tom Rini04549e92021-03-15 13:19:01 -040084 libudev-dev \
85 libusb-1.0-0-dev \
Alper Nebi Yasak5d249e92021-06-21 21:51:54 +030086 linux-image-kvm \
Tom Rini04549e92021-03-15 13:19:01 -040087 lzma-alone \
88 lzop \
89 mount \
90 mtd-utils \
91 mtools \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010092 net-tools \
Bin Meng00afccd2021-08-26 23:33:32 +080093 ninja-build \
Tom Rini04549e92021-03-15 13:19:01 -040094 openssl \
95 picocom \
96 parted \
97 pkg-config \
Tom Rinic8982d22021-06-10 10:57:36 -040098 python-is-python3 \
99 python2.7 \
100 python3 \
101 python3-dev \
Tom Rini04549e92021-03-15 13:19:01 -0400102 python3-pip \
Simon Glassb955cd22022-10-13 06:25:57 -0600103 python3-pyelftools \
Tom Rini04549e92021-03-15 13:19:01 -0400104 python3-sphinx \
Tom Rinic8982d22021-06-10 10:57:36 -0400105 python3-virtualenv \
Tom Rini04549e92021-03-15 13:19:01 -0400106 rpm2cpio \
107 sbsigntool \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +0100108 socat \
109 softhsm2 \
Tom Rini04549e92021-03-15 13:19:01 -0400110 sparse \
111 srecord \
112 sudo \
113 swig \
Heinrich Schuchardtc2c98ea2022-12-30 05:41:01 +0100114 texinfo \
Tom Rini04549e92021-03-15 13:19:01 -0400115 util-linux \
116 uuid-dev \
117 virtualenv \
Simon Glassbe17cb32023-08-24 13:55:46 -0600118 vboot-kernel-utils \
119 vboot-utils \
Heinrich Schuchardt905d0752024-02-28 08:23:09 +0100120 xilinx-bootgen \
Tom Rini0a78bc32021-07-02 10:41:58 -0400121 xxd \
Tom Rini04549e92021-03-15 13:19:01 -0400122 zip \
123 && rm -rf /var/lib/apt/lists/*
124
Alper Nebi Yasak5d249e92021-06-21 21:51:54 +0300125# Make kernels readable for libguestfs tools to work correctly
126RUN chmod +r /boot/vmlinu*
127
Tom Rini04549e92021-03-15 13:19:01 -0400128# Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
129RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
130 cd /tmp/grub && \
Tom Rini0a78bc32021-07-02 10:41:58 -0400131 git checkout grub-2.06 && \
Tom Rini77d48f12022-11-22 12:31:58 -0500132 git config --global user.name "GitLab CI Runner" && \
133 git config --global user.email trini@konsulko.com && \
134 git cherry-pick 049efdd72eb7baa7b2bf8884391ee7fe650da5a0 && \
Tom Rini619eb212023-07-13 20:37:35 -0400135 git cherry-pick 403d6540cd608b2706cfa0cb4713f7e4b490ff45 && \
Tom Rini04549e92021-03-15 13:19:01 -0400136 ./bootstrap && \
137 mkdir -p /opt/grub && \
138 ./configure --target=aarch64 --with-platform=efi \
139 CC=gcc \
Tom Rini3bd5ed72023-08-25 13:21:26 -0400140 TARGET_CC=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
141 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
142 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
143 TARGET_NM=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
144 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
Tom Rini04549e92021-03-15 13:19:01 -0400145 make && \
146 ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
147 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
148 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
149 search search_fs_file search_fs_uuid search_label serial sleep test \
150 true && \
151 make clean && \
152 ./configure --target=arm --with-platform=efi \
153 CC=gcc \
Tom Rini3bd5ed72023-08-25 13:21:26 -0400154 TARGET_CC=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
155 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
156 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
157 TARGET_NM=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
158 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
Tom Rini04549e92021-03-15 13:19:01 -0400159 make && \
160 ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
161 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
162 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
163 search search_fs_file search_fs_uuid search_label serial sleep test \
164 true && \
165 make clean && \
166 ./configure --target=riscv64 --with-platform=efi \
167 CC=gcc \
Tom Rini3bd5ed72023-08-25 13:21:26 -0400168 TARGET_CC=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
169 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
170 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
171 TARGET_NM=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
172 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
Tom Rini04549e92021-03-15 13:19:01 -0400173 make && \
174 ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
175 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
176 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
177 search search_fs_file search_fs_uuid search_label serial sleep test \
178 true && \
Tom Rini04549e92021-03-15 13:19:01 -0400179 rm -rf /tmp/grub
180
Tom Rinib60c1d72023-02-07 12:50:13 -0500181RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
Tom Rini04549e92021-03-15 13:19:01 -0400182 cd /tmp/qemu && \
Heinrich Schuchardt24069c22024-01-12 03:17:57 +0100183 git checkout v8.2.0 && \
Bin Meng00afccd2021-08-26 23:33:32 +0800184 # config user.name and user.email to make 'git am' happy
185 git config user.name u-boot && \
186 git config user.email u-boot@denx.de && \
Heinrich Schuchardt24069c22024-01-12 03:17:57 +0100187 git format-patch 0c7ffc977195~..0c7ffc977195 && \
188 git am 0001-hw-net-cadence_gem-Fix-MDIO_OP_xxx-values.patch && \
Tom Rini139e9952024-03-11 10:02:43 -0400189 git cherry-pick d3c79c3974 && \
Tom Rini26a41832023-03-21 15:28:00 -0400190 ./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" && \
Tom Rini04549e92021-03-15 13:19:01 -0400191 make -j$(nproc) all install && \
192 rm -rf /tmp/qemu
193
Heinrich Schuchardt2b4a6562024-02-28 08:43:11 +0100194# Build fiptool
195RUN git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git /tmp/tf-a && \
196 cd /tmp/tf-a/ && \
197 git checkout v2.10.0 && \
198 cd tools/fiptool && \
199 make && \
200 mkdir -p /usr/local/bin && \
201 cp fiptool /usr/local/bin && \
202 rm -rf /tmp/tf-a
203
Bin Mengf551a532021-08-26 23:33:33 +0800204# Build genimage (required by some targets to generate disk images)
205RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \
206 cd /tmp/genimage-14 && \
207 ./configure && \
208 make -j$(nproc) && \
209 make install && \
210 rm -rf /tmp/genimage-14
211
Heinrich Schuchardt4e202672021-11-09 19:51:20 +0100212# Build libtpms
213RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \
214 cd /tmp/libtpms && \
215 ./autogen.sh && \
216 ./configure && \
217 make -j$(nproc) && \
218 make install && \
219 ldconfig && \
220 rm -rf /tmp/libtpms
221
222# Build swtpm
223RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \
224 cd /tmp/swtpm && \
225 ./autogen.sh && \
226 ./configure && \
227 make -j$(nproc) && \
228 make install && \
229 rm -rf /tmp/swtpm
230
Simon Glass523cb6d2023-01-15 14:15:59 -0700231# Build trace-cmd
232RUN mkdir /tmp/trace && \
233 git clone https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git /tmp/trace/libtraceevent && \
234 cd /tmp/trace/libtraceevent && \
235 make -j$(nproc) && \
236 sudo make install && \
237 git clone https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git /tmp/trace/libtracefs && \
238 cd /tmp/trace/libtracefs && \
239 make -j$(nproc) && \
240 sudo make install && \
241 git clone https://github.com/rostedt/trace-cmd.git /tmp/trace/trace-cmd && \
242 cd /tmp/trace/trace-cmd && \
243 make -j$(nproc) && \
244 sudo make install && \
245 rm -rf /tmp/trace
246
Tom Rini9e2b09e2024-02-13 09:39:26 -0500247# Build coreboot
Simon Glass78b9c8a2024-10-14 16:32:05 -0600248RUN wget -O - https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C /tmp -xJ && \
249 cd /tmp/coreboot-24.08 && \
Tom Rini9e2b09e2024-02-13 09:39:26 -0500250 make crossgcc-i386 CPUS=$(nproc) && \
251 make -C payloads/coreinfo olddefconfig && \
252 make -C payloads/coreinfo && \
253 make olddefconfig && \
Simon Glass78b9c8a2024-10-14 16:32:05 -0600254 echo CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y | tee -a .config && \
255 echo CONFIG_USE_OPTION_TABLE=y | tee -a .config && \
256 make olddefconfig && \
Tom Rini9e2b09e2024-02-13 09:39:26 -0500257 make -j $(nproc) && \
258 sudo mkdir /opt/coreboot && \
259 sudo cp build/coreboot.rom build/cbfstool /opt/coreboot/
260
Tom Rini04549e92021-03-15 13:19:01 -0400261# Create our user/group
262RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
263RUN useradd -m -U uboot
264USER uboot:uboot
265
Tom Rini54573e02023-03-23 14:57:58 -0400266# Populate the cache for pip to use. Get these via wget as the
267# COPY / ADD directives don't work as we need them to.
268RUN wget -O /tmp/pytest-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/test/py/requirements.txt
269RUN wget -O /tmp/sphinx-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/doc/sphinx/requirements.txt
Tom Rini763160f2024-01-18 12:10:07 -0500270RUN wget -O /tmp/buildman-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/tools/buildman/requirements.txt
Tom Rini54573e02023-03-23 14:57:58 -0400271RUN virtualenv -p /usr/bin/python3 /tmp/venv && \
272 . /tmp/venv/bin/activate && \
273 pip install -r /tmp/pytest-requirements.txt \
Tom Rini763160f2024-01-18 12:10:07 -0500274 -r /tmp/sphinx-requirements.txt \
275 -r /tmp/buildman-requirements.txt && \
Tom Rini54573e02023-03-23 14:57:58 -0400276 deactivate && \
Tom Rini763160f2024-01-18 12:10:07 -0500277 rm -rf /tmp/venv /tmp/*-requirements.txt
Tom Rini54573e02023-03-23 14:57:58 -0400278
Tom Rini04549e92021-03-15 13:19:01 -0400279# Create the buildman config file
280RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
Tom Rini3bd5ed72023-08-25 13:21:26 -0400281RUN /bin/echo -e "kernelorg = /opt/gcc-13.2.0-nolibc/*" >> ~/.buildman
Tom Rini0a78bc32021-07-02 10:41:58 -0400282RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
Tom Rini04549e92021-03-15 13:19:01 -0400283RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
Tom Rini04549e92021-03-15 13:19:01 -0400284RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;
Safae Ouajihaaa366f2023-02-06 00:50:21 +0100285
286# Add mkbootimg tool
287RUN git clone https://android.googlesource.com/platform/system/tools/mkbootimg /home/uboot/mkbootimg
288ENV PYTHONPATH "${PYTHONPATH}:/home/uboot/mkbootimg"