blob: 42ab81283d273e71460c1c0fa3808c5c4c8f4672 [file] [log] [blame]
Tom Rinia6432252021-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
Heinrich Schuchardte2ce13c2022-10-03 18:07:52 +02005FROM ubuntu:jammy-20221003
Tom Rinia6432252021-03-15 13:19:01 -04006MAINTAINER Tom Rini <trini@konsulko.com>
7LABEL Description=" This image is for building U-Boot inside a container"
8
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 Rinib6d4e082022-08-09 21:08:54 -040015RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-13 main | tee /etc/apt/sources.list.d/llvm.list
Tom Rinia6432252021-03-15 13:19:01 -040016
Tom Rini7bb1cc32021-07-02 10:41:58 -040017# Manually install the kernel.org "Crosstool" based toolchains for gcc-11.1.0
18RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.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/11.1.0/x86_64-gcc-11.1.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ
20RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ
21RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-m68k-linux.tar.xz | tar -C /opt -xJ
22RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ
23RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-microblaze-linux.tar.xz | tar -C /opt -xJ
24RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-nios2-linux.tar.xz | tar -C /opt -xJ
25RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ
26RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ
Heinrich Schuchardte2ce13c2022-10-03 18:07:52 +020027RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-riscv32-linux.tar.xz | tar -C /opt -xJ
Tom Rini7bb1cc32021-07-02 10:41:58 -040028RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ
Tom Rinia6432252021-03-15 13:19:01 -040029
30# Manually install other toolchains
Tom Rini7bb1cc32021-07-02 10:41:58 -040031RUN 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
32RUN wget -O - https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2021.03-release/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install.tar.gz | tar --no-same-owner -C /opt -xz
Tom Rinia6432252021-03-15 13:19:01 -040033
34# Update and install things from apt now
35RUN apt-get update && apt-get install -y \
36 automake \
37 autopoint \
38 bc \
39 binutils-dev \
40 bison \
41 build-essential \
Tom Rini927e0ee2021-10-05 13:51:38 -040042 clang-13 \
Tom Rinia6432252021-03-15 13:19:01 -040043 coreutils \
44 cpio \
45 cppcheck \
46 curl \
47 device-tree-compiler \
48 dosfstools \
49 e2fsprogs \
50 efitools \
Huang Jianan2c30aa32022-02-26 15:05:51 +080051 erofs-utils \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010052 expect \
Tom Rinia6432252021-03-15 13:19:01 -040053 fakeroot \
54 flex \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010055 gawk \
Tom Rinia6432252021-03-15 13:19:01 -040056 gdisk \
57 git \
58 gnu-efi \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010059 gnutls-dev \
Tom Rinia6432252021-03-15 13:19:01 -040060 graphviz \
61 grub-efi-amd64-bin \
62 grub-efi-ia32-bin \
63 help2man \
64 iasl \
65 imagemagick \
66 iputils-ping \
Bin Meng3283a052021-08-26 23:33:33 +080067 libconfuse-dev \
Tom Rinib1c21022021-06-10 10:57:36 -040068 libgit2-dev \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010069 libjson-glib-dev \
Tom Rinia6432252021-03-15 13:19:01 -040070 libguestfs-tools \
AKASHI Takahiroad3616e2022-02-01 10:32:36 +090071 libgnutls28-dev \
72 libgnutls30 \
Tom Rinia6432252021-03-15 13:19:01 -040073 liblz4-tool \
74 libpixman-1-dev \
Tom Rinib1c21022021-06-10 10:57:36 -040075 libpython3-dev \
Tom Rinia6432252021-03-15 13:19:01 -040076 libsdl1.2-dev \
77 libsdl2-dev \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010078 libseccomp-dev \
Tom Rinia6432252021-03-15 13:19:01 -040079 libssl-dev \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010080 libtool \
Tom Rinia6432252021-03-15 13:19:01 -040081 libudev-dev \
82 libusb-1.0-0-dev \
Alper Nebi Yasakf9abaa52021-06-21 21:51:54 +030083 linux-image-kvm \
Tom Rinia6432252021-03-15 13:19:01 -040084 lzma-alone \
85 lzop \
86 mount \
87 mtd-utils \
88 mtools \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010089 net-tools \
Bin Menga30e53c2021-08-26 23:33:32 +080090 ninja-build \
Tom Rinia6432252021-03-15 13:19:01 -040091 openssl \
92 picocom \
93 parted \
94 pkg-config \
Tom Rinib1c21022021-06-10 10:57:36 -040095 python-is-python3 \
96 python2.7 \
97 python3 \
98 python3-dev \
Tom Rinia6432252021-03-15 13:19:01 -040099 python3-pip \
Simon Glass33799262022-10-13 06:25:57 -0600100 python3-pyelftools \
Tom Rinia6432252021-03-15 13:19:01 -0400101 python3-sphinx \
Tom Rinib1c21022021-06-10 10:57:36 -0400102 python3-virtualenv \
Tom Rinia6432252021-03-15 13:19:01 -0400103 rpm2cpio \
104 sbsigntool \
105 sloccount \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +0100106 socat \
107 softhsm2 \
Tom Rinia6432252021-03-15 13:19:01 -0400108 sparse \
109 srecord \
110 sudo \
111 swig \
112 util-linux \
113 uuid-dev \
114 virtualenv \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400115 xxd \
Tom Rinia6432252021-03-15 13:19:01 -0400116 zip \
117 && rm -rf /var/lib/apt/lists/*
118
Alper Nebi Yasakf9abaa52021-06-21 21:51:54 +0300119# Make kernels readable for libguestfs tools to work correctly
120RUN chmod +r /boot/vmlinu*
121
Tom Rinia6432252021-03-15 13:19:01 -0400122# Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
123RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
124 cd /tmp/grub && \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400125 git checkout grub-2.06 && \
Tom Rinia6432252021-03-15 13:19:01 -0400126 ./bootstrap && \
127 mkdir -p /opt/grub && \
128 ./configure --target=aarch64 --with-platform=efi \
129 CC=gcc \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400130 TARGET_CC=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
131 TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
132 TARGET_STRIP=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
133 TARGET_NM=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
134 TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
Tom Rinia6432252021-03-15 13:19:01 -0400135 make && \
136 ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
137 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
138 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
139 search search_fs_file search_fs_uuid search_label serial sleep test \
140 true && \
141 make clean && \
142 ./configure --target=arm --with-platform=efi \
143 CC=gcc \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400144 TARGET_CC=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
145 TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
146 TARGET_STRIP=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
147 TARGET_NM=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
148 TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
Tom Rinia6432252021-03-15 13:19:01 -0400149 make && \
150 ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
151 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
152 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
153 search search_fs_file search_fs_uuid search_label serial sleep test \
154 true && \
155 make clean && \
156 ./configure --target=riscv64 --with-platform=efi \
157 CC=gcc \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400158 TARGET_CC=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
159 TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
160 TARGET_STRIP=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
161 TARGET_NM=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
162 TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
Tom Rinia6432252021-03-15 13:19:01 -0400163 make && \
164 ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
165 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
166 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
167 search search_fs_file search_fs_uuid search_label serial sleep test \
168 true && \
Tom Rinia6432252021-03-15 13:19:01 -0400169 rm -rf /tmp/grub
170
171RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \
172 cd /tmp/qemu && \
173 git submodule update --init dtc && \
Bin Menga30e53c2021-08-26 23:33:32 +0800174 git checkout v6.1.0 && \
175 # config user.name and user.email to make 'git am' happy
176 git config user.name u-boot && \
177 git config user.email u-boot@denx.de && \
178 # manually apply the bug fix for QEMU 6.1.0 Xilinx Zynq UART emulation codes
179 wget -O - http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-bmeng.cn@gmail.com/mbox/ | git am && \
Tom Rinia6432252021-03-15 13:19:01 -0400180 ./configure --prefix=/opt/qemu --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu" && \
181 make -j$(nproc) all install && \
182 rm -rf /tmp/qemu
183
Bin Meng3283a052021-08-26 23:33:33 +0800184# Build genimage (required by some targets to generate disk images)
185RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \
186 cd /tmp/genimage-14 && \
187 ./configure && \
188 make -j$(nproc) && \
189 make install && \
190 rm -rf /tmp/genimage-14
191
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +0100192# Build libtpms
193RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \
194 cd /tmp/libtpms && \
195 ./autogen.sh && \
196 ./configure && \
197 make -j$(nproc) && \
198 make install && \
199 ldconfig && \
200 rm -rf /tmp/libtpms
201
202# Build swtpm
203RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \
204 cd /tmp/swtpm && \
205 ./autogen.sh && \
206 ./configure && \
207 make -j$(nproc) && \
208 make install && \
209 rm -rf /tmp/swtpm
210
Tom Rinia6432252021-03-15 13:19:01 -0400211# Create our user/group
212RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
213RUN useradd -m -U uboot
214USER uboot:uboot
215
216# Create the buildman config file
217RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
Tom Rini7bb1cc32021-07-02 10:41:58 -0400218RUN /bin/echo -e "kernelorg = /opt/gcc-11.1.0-nolibc/*" >> ~/.buildman
219RUN /bin/echo -e "arc = /opt/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
220RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
Tom Rinia6432252021-03-15 13:19:01 -0400221RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
Tom Rinia6432252021-03-15 13:19:01 -0400222RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
223RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;