]> Git Repo - J-u-boot.git/blob - tools/docker/Dockerfile
Merge patch series "J721S2: Enable ESMs and related PMIC"
[J-u-boot.git] / tools / docker / Dockerfile
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
5 FROM ubuntu:jammy-20240808
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"
8
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
16 # Make sure apt is happy
17 ENV DEBIAN_FRONTEND=noninteractive
18
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
28 RUN echo "Building on $BUILDPLATFORM, for target $TARGETPLATFORM"
29
30 # Add LLVM repository
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
34 RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
35 RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main | tee /etc/apt/sources.list.d/llvm.list
36
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
51
52 # Manually install other toolchains
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
56
57 # Update and install things from apt now
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 \
61         automake \
62         autopoint \
63         bc \
64         binutils-dev \
65         bison \
66         build-essential \
67         cgpt \
68         clang-17 \
69         coreutils \
70         cpio \
71         curl \
72         device-tree-compiler \
73         dosfstools \
74         e2fsprogs \
75         efitools \
76         erofs-utils \
77         expect \
78         fakeroot \
79         flex \
80         gawk \
81         gdisk \
82         gettext \
83         git \
84         gnu-efi \
85         gnutls-dev \
86         graphviz \
87         help2man \
88         iasl \
89         imagemagick \
90         iputils-ping \
91         libconfuse-dev \
92         libgit2-dev \
93         libjson-glib-dev \
94         libguestfs-tools \
95         libgnutls28-dev \
96         libgnutls30 \
97         liblz4-tool \
98         libpixman-1-dev \
99         libpython3-dev \
100         libsdl1.2-dev \
101         libsdl2-dev \
102         libseccomp-dev \
103         libslirp-dev \
104         libssl-dev \
105         libtool \
106         libudev-dev \
107         libusb-1.0-0-dev \
108         linux-image-generic \
109         lzma-alone \
110         lzop \
111         mount \
112         mtd-utils \
113         mtools \
114         net-tools \
115         ninja-build \
116         openssl \
117         picocom \
118         parted \
119         pkg-config \
120         python-is-python3 \
121         python2.7 \
122         python3 \
123         python3-dev \
124         python3-pip \
125         python3-pyelftools \
126         python3-sphinx \
127         python3-virtualenv \
128         rpm2cpio \
129         sbsigntool \
130         socat \
131         softhsm2 \
132         sparse \
133         srecord \
134         sudo \
135         swig \
136         texinfo \
137         util-linux \
138         uuid-dev \
139         virtualenv \
140         vboot-kernel-utils \
141         vboot-utils \
142         xilinx-bootgen \
143         xxd \
144         zip
145
146 # Make kernels readable for libguestfs tools to work correctly
147 RUN chmod +r /boot/vmlinu*
148
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 && \
152         git checkout grub-2.12 && \
153         git config --global user.name "GitLab CI Runner" && \
154         git config --global user.email [email protected] && \
155         ./bootstrap && \
156         mkdir -p /opt/grub && \
157         ./configure --target=aarch64 --with-platform=efi \
158         CC=gcc \
159         TARGET_CC=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
160         TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
161         TARGET_STRIP=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
162         TARGET_NM=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
163         TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
164         make -j$(nproc) && \
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 \
173         TARGET_CC=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
174         TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
175         TARGET_STRIP=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
176         TARGET_NM=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
177         TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
178         make -j$(nproc) && \
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 \
187         TARGET_CC=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
188         TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
189         TARGET_STRIP=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
190         TARGET_NM=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
191         TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
192         make -j$(nproc) && \
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 && \
198         make clean && \
199         ./configure --target=i386 --with-platform=efi \
200         CC=gcc \
201         TARGET_CC=/opt/gcc-13.2.0-nolibc/i386-linux/bin/i386-linux-gcc \
202         TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/i386-linux/bin/i386-linux-objcopy \
203         TARGET_STRIP=/opt/gcc-13.2.0-nolibc/i386-linux/bin/i386-linux-strip \
204         TARGET_NM=/opt/gcc-13.2.0-nolibc/i386-linux/bin/i386-linux-nm \
205         TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/i386-linux/bin/i386-linux-ranlib && \
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 \
212         TARGET_CC=/opt/gcc-13.2.0-nolibc/x86_64-linux/bin/x86_64-linux-gcc \
213         TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/x86_64-linux/bin/x86_64-linux-objcopy \
214         TARGET_STRIP=/opt/gcc-13.2.0-nolibc/x86_64-linux/bin/x86_64-linux-strip \
215         TARGET_NM=/opt/gcc-13.2.0-nolibc/x86_64-linux/bin/x86_64-linux-nm \
216         TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/x86_64-linux/bin/x86_64-linux-ranlib && \
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 && \
220         rm -rf /tmp/grub
221
222 RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
223         cd /tmp/qemu && \
224         git checkout v8.2.0 && \
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] && \
228         git format-patch 0c7ffc977195~..0c7ffc977195 && \
229         git am 0001-hw-net-cadence_gem-Fix-MDIO_OP_xxx-values.patch && \
230         git cherry-pick d3c79c3974 && \
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" && \
232         make -j$(nproc) all install && \
233         rm -rf /tmp/qemu
234
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 && \
240         make -j$(nproc) && \
241         mkdir -p /usr/local/bin && \
242         cp fiptool /usr/local/bin && \
243         rm -rf /tmp/tf-a
244
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
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
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
288 # Build coreboot
289 RUN wget -O - https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C /tmp -xJ && \
290     cd /tmp/coreboot-24.08 && \
291     make crossgcc-i386 CPUS=$(nproc) && \
292     make -C payloads/coreinfo olddefconfig && \
293     make -C payloads/coreinfo && \
294     make olddefconfig && \
295     echo CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y | tee -a .config && \
296     echo CONFIG_USE_OPTION_TABLE=y | tee -a .config && \
297     make olddefconfig && \
298     make -j $(nproc) && \
299     sudo mkdir /opt/coreboot && \
300     sudo cp build/coreboot.rom build/cbfstool /opt/coreboot/
301
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
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
311 RUN wget -O /tmp/buildman-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/tools/buildman/requirements.txt
312 RUN virtualenv -p /usr/bin/python3 /tmp/venv && \
313         . /tmp/venv/bin/activate && \
314         pip install -r /tmp/pytest-requirements.txt \
315                 -r /tmp/sphinx-requirements.txt \
316                 -r /tmp/buildman-requirements.txt && \
317         deactivate && \
318         rm -rf /tmp/venv /tmp/*-requirements.txt
319
320 # Create the buildman config file
321 RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
322 RUN /bin/echo -e "kernelorg = /opt/gcc-13.2.0-nolibc/*" >> ~/.buildman
323 RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
324 RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
325 RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;
326
327 # Add mkbootimg tool
328 RUN git clone https://android.googlesource.com/platform/system/tools/mkbootimg /home/uboot/mkbootimg
329 ENV PYTHONPATH="${PYTHONPATH}:/home/uboot/mkbootimg"
This page took 0.039646 seconds and 4 git commands to generate.