blob: c51e343013747618ae083fb30a9fedf14106666f [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 Rinif69f6bb2022-03-15 16:18:16 -04005FROM ubuntu:focal-20220302
Tom Rini04549e92021-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 Rini4d4251b2021-10-05 13:51:38 -040015RUN echo deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main | tee /etc/apt/sources.list.d/llvm.list
Tom Rini04549e92021-03-15 13:19:01 -040016
Tom Rini0a78bc32021-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
27RUN 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 Rini04549e92021-03-15 13:19:01 -040028
29# Manually install other toolchains
Tom Rini0a78bc32021-07-02 10:41:58 -040030RUN 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
31RUN 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 Rini04549e92021-03-15 13:19:01 -040032RUN wget -O - https://github.com/vincentzwc/prebuilt-nds32-toolchain/releases/download/20180521/nds32le-linux-glibc-v3-upstream.tar.gz | tar -C /opt -xz
33
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 Rini4d4251b2021-10-05 13:51:38 -040042 clang-13 \
Tom Rini04549e92021-03-15 13:19:01 -040043 coreutils \
44 cpio \
45 cppcheck \
46 curl \
47 device-tree-compiler \
48 dosfstools \
49 e2fsprogs \
50 efitools \
Huang Jianan11e04432022-02-26 15:05:51 +080051 erofs-utils \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010052 expect \
Tom Rini04549e92021-03-15 13:19:01 -040053 fakeroot \
54 flex \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010055 gawk \
Tom Rini04549e92021-03-15 13:19:01 -040056 gdisk \
57 git \
58 gnu-efi \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010059 gnutls-dev \
Tom Rini04549e92021-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 Mengf551a532021-08-26 23:33:33 +080067 libconfuse-dev \
Tom Rinic8982d22021-06-10 10:57:36 -040068 libgit2-dev \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010069 libjson-glib-dev \
Tom Rini04549e92021-03-15 13:19:01 -040070 libguestfs-tools \
AKASHI Takahiro3edc3472022-02-01 10:32:36 +090071 libgnutls28-dev \
72 libgnutls30 \
Tom Rini04549e92021-03-15 13:19:01 -040073 liblz4-tool \
74 libpixman-1-dev \
Tom Rinic8982d22021-06-10 10:57:36 -040075 libpython3-dev \
Tom Rini04549e92021-03-15 13:19:01 -040076 libsdl1.2-dev \
77 libsdl2-dev \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010078 libseccomp-dev \
Tom Rini04549e92021-03-15 13:19:01 -040079 libssl-dev \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010080 libtool \
Tom Rini04549e92021-03-15 13:19:01 -040081 libudev-dev \
82 libusb-1.0-0-dev \
Alper Nebi Yasak5d249e92021-06-21 21:51:54 +030083 linux-image-kvm \
Tom Rini04549e92021-03-15 13:19:01 -040084 lzma-alone \
85 lzop \
86 mount \
87 mtd-utils \
88 mtools \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010089 net-tools \
Bin Meng00afccd2021-08-26 23:33:32 +080090 ninja-build \
Tom Rini04549e92021-03-15 13:19:01 -040091 openssl \
92 picocom \
93 parted \
94 pkg-config \
Tom Rinic8982d22021-06-10 10:57:36 -040095 python-is-python3 \
96 python2.7 \
97 python3 \
98 python3-dev \
Tom Rini04549e92021-03-15 13:19:01 -040099 python3-pip \
100 python3-sphinx \
Tom Rinic8982d22021-06-10 10:57:36 -0400101 python3-virtualenv \
Tom Rini04549e92021-03-15 13:19:01 -0400102 rpm2cpio \
103 sbsigntool \
104 sloccount \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +0100105 socat \
106 softhsm2 \
Tom Rini04549e92021-03-15 13:19:01 -0400107 sparse \
108 srecord \
109 sudo \
110 swig \
111 util-linux \
112 uuid-dev \
113 virtualenv \
Tom Rini0a78bc32021-07-02 10:41:58 -0400114 xxd \
Tom Rini04549e92021-03-15 13:19:01 -0400115 zip \
116 && rm -rf /var/lib/apt/lists/*
117
Alper Nebi Yasak5d249e92021-06-21 21:51:54 +0300118# Make kernels readable for libguestfs tools to work correctly
119RUN chmod +r /boot/vmlinu*
120
Tom Rini04549e92021-03-15 13:19:01 -0400121# Manually install a new enough version of sbsigntools (must be v0.9.4 or later)
122RUN git clone https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git /tmp/sbsigntools && \
123 cd /tmp/sbsigntools && \
124 git checkout -b latest v0.9.4 && \
125 ./autogen.sh && \
126 ./configure && \
127 make && \
128 make install && \
129 rm -rf /tmp/sbsigntools
130
131# Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
132RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
133 cd /tmp/grub && \
Tom Rini0a78bc32021-07-02 10:41:58 -0400134 git checkout grub-2.06 && \
Tom Rini04549e92021-03-15 13:19:01 -0400135 ./bootstrap && \
136 mkdir -p /opt/grub && \
137 ./configure --target=aarch64 --with-platform=efi \
138 CC=gcc \
Tom Rini0a78bc32021-07-02 10:41:58 -0400139 TARGET_CC=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
140 TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
141 TARGET_STRIP=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
142 TARGET_NM=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
143 TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
Tom Rini04549e92021-03-15 13:19:01 -0400144 make && \
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 \
149 true && \
150 make clean && \
151 ./configure --target=arm --with-platform=efi \
152 CC=gcc \
Tom Rini0a78bc32021-07-02 10:41:58 -0400153 TARGET_CC=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
154 TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
155 TARGET_STRIP=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
156 TARGET_NM=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
157 TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
Tom Rini04549e92021-03-15 13:19:01 -0400158 make && \
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 \
163 true && \
164 make clean && \
165 ./configure --target=riscv64 --with-platform=efi \
166 CC=gcc \
Tom Rini0a78bc32021-07-02 10:41:58 -0400167 TARGET_CC=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
168 TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
169 TARGET_STRIP=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
170 TARGET_NM=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
171 TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
Tom Rini04549e92021-03-15 13:19:01 -0400172 make && \
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 \
177 true && \
Tom Rini04549e92021-03-15 13:19:01 -0400178 rm -rf /tmp/grub
179
180RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \
181 cd /tmp/qemu && \
182 git submodule update --init dtc && \
Bin Meng00afccd2021-08-26 23:33:32 +0800183 git checkout v6.1.0 && \
184 # 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 && \
187 # manually apply the bug fix for QEMU 6.1.0 Xilinx Zynq UART emulation codes
188 wget -O - http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-bmeng.cn@gmail.com/mbox/ | git am && \
Tom Rini04549e92021-03-15 13:19:01 -0400189 ./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" && \
190 make -j$(nproc) all install && \
191 rm -rf /tmp/qemu
192
Bin Mengf551a532021-08-26 23:33:33 +0800193# Build genimage (required by some targets to generate disk images)
194RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \
195 cd /tmp/genimage-14 && \
196 ./configure && \
197 make -j$(nproc) && \
198 make install && \
199 rm -rf /tmp/genimage-14
200
Heinrich Schuchardt4e202672021-11-09 19:51:20 +0100201# Build libtpms
202RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \
203 cd /tmp/libtpms && \
204 ./autogen.sh && \
205 ./configure && \
206 make -j$(nproc) && \
207 make install && \
208 ldconfig && \
209 rm -rf /tmp/libtpms
210
211# Build swtpm
212RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \
213 cd /tmp/swtpm && \
214 ./autogen.sh && \
215 ./configure && \
216 make -j$(nproc) && \
217 make install && \
218 rm -rf /tmp/swtpm
219
Tom Rini04549e92021-03-15 13:19:01 -0400220# Create our user/group
221RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
222RUN useradd -m -U uboot
223USER uboot:uboot
224
225# Create the buildman config file
226RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
Tom Rini0a78bc32021-07-02 10:41:58 -0400227RUN /bin/echo -e "kernelorg = /opt/gcc-11.1.0-nolibc/*" >> ~/.buildman
228RUN /bin/echo -e "arc = /opt/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
229RUN /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 -0400230RUN /bin/echo -e "\nnds32 = /opt/nds32le-linux-glibc-v3-upstream/bin/nds32le-linux-" >> ~/.buildman;
231RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
232RUN /bin/echo -e "\nriscv = riscv64" >> ~/.buildman
233RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
234RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;