Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 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 | |
Tom Rini | 5c1ed64 | 2021-09-11 10:36:48 -0400 | [diff] [blame] | 5 | FROM ubuntu:focal-20210827 |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 6 | MAINTAINER Tom Rini <trini@konsulko.com> |
| 7 | LABEL Description=" This image is for building U-Boot inside a container" |
| 8 | |
| 9 | # Make sure apt is happy |
| 10 | ENV DEBIAN_FRONTEND=noninteractive |
| 11 | |
| 12 | # Add LLVM repository |
| 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 - |
Tom Rini | 6621722 | 2021-07-15 14:24:25 -0400 | [diff] [blame] | 15 | RUN echo deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main | tee /etc/apt/sources.list.d/llvm.list |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 16 | |
Tom Rini | 7bb1cc3 | 2021-07-02 10:41:58 -0400 | [diff] [blame] | 17 | # Manually install the kernel.org "Crosstool" based toolchains for gcc-11.1.0 |
| 18 | RUN 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 |
| 19 | RUN 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 |
| 20 | RUN 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 |
| 21 | RUN 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 |
| 22 | RUN 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 |
| 23 | RUN 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 |
| 24 | RUN 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 |
| 25 | RUN 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 |
| 26 | RUN 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 |
| 27 | RUN 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 Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 28 | |
| 29 | # Manually install other toolchains |
Tom Rini | 7bb1cc3 | 2021-07-02 10:41:58 -0400 | [diff] [blame] | 30 | 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 |
| 31 | RUN 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 Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 32 | RUN 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 |
| 35 | RUN apt-get update && apt-get install -y \ |
| 36 | automake \ |
| 37 | autopoint \ |
| 38 | bc \ |
| 39 | binutils-dev \ |
| 40 | bison \ |
| 41 | build-essential \ |
Tom Rini | 6621722 | 2021-07-15 14:24:25 -0400 | [diff] [blame] | 42 | clang-12 \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 43 | coreutils \ |
| 44 | cpio \ |
| 45 | cppcheck \ |
| 46 | curl \ |
| 47 | device-tree-compiler \ |
| 48 | dosfstools \ |
| 49 | e2fsprogs \ |
| 50 | efitools \ |
| 51 | fakeroot \ |
| 52 | flex \ |
| 53 | gdisk \ |
| 54 | git \ |
| 55 | gnu-efi \ |
| 56 | graphviz \ |
| 57 | grub-efi-amd64-bin \ |
| 58 | grub-efi-ia32-bin \ |
| 59 | help2man \ |
| 60 | iasl \ |
| 61 | imagemagick \ |
| 62 | iputils-ping \ |
Bin Meng | 3283a05 | 2021-08-26 23:33:33 +0800 | [diff] [blame] | 63 | libconfuse-dev \ |
Tom Rini | b1c2102 | 2021-06-10 10:57:36 -0400 | [diff] [blame] | 64 | libgit2-dev \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 65 | libguestfs-tools \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 66 | liblz4-tool \ |
| 67 | libpixman-1-dev \ |
Tom Rini | b1c2102 | 2021-06-10 10:57:36 -0400 | [diff] [blame] | 68 | libpython3-dev \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 69 | libsdl1.2-dev \ |
| 70 | libsdl2-dev \ |
| 71 | libssl-dev \ |
| 72 | libudev-dev \ |
| 73 | libusb-1.0-0-dev \ |
Alper Nebi Yasak | f9abaa5 | 2021-06-21 21:51:54 +0300 | [diff] [blame] | 74 | linux-image-kvm \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 75 | lzma-alone \ |
| 76 | lzop \ |
| 77 | mount \ |
| 78 | mtd-utils \ |
| 79 | mtools \ |
Bin Meng | a30e53c | 2021-08-26 23:33:32 +0800 | [diff] [blame] | 80 | ninja-build \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 81 | openssl \ |
| 82 | picocom \ |
| 83 | parted \ |
| 84 | pkg-config \ |
Tom Rini | b1c2102 | 2021-06-10 10:57:36 -0400 | [diff] [blame] | 85 | python-is-python3 \ |
| 86 | python2.7 \ |
| 87 | python3 \ |
| 88 | python3-dev \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 89 | python3-pip \ |
| 90 | python3-sphinx \ |
Tom Rini | b1c2102 | 2021-06-10 10:57:36 -0400 | [diff] [blame] | 91 | python3-virtualenv \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 92 | rpm2cpio \ |
| 93 | sbsigntool \ |
| 94 | sloccount \ |
| 95 | sparse \ |
| 96 | srecord \ |
| 97 | sudo \ |
| 98 | swig \ |
| 99 | util-linux \ |
| 100 | uuid-dev \ |
| 101 | virtualenv \ |
Tom Rini | 7bb1cc3 | 2021-07-02 10:41:58 -0400 | [diff] [blame] | 102 | xxd \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 103 | zip \ |
| 104 | && rm -rf /var/lib/apt/lists/* |
| 105 | |
Alper Nebi Yasak | f9abaa5 | 2021-06-21 21:51:54 +0300 | [diff] [blame] | 106 | # Make kernels readable for libguestfs tools to work correctly |
| 107 | RUN chmod +r /boot/vmlinu* |
| 108 | |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 109 | # Manually install a new enough version of sbsigntools (must be v0.9.4 or later) |
| 110 | RUN git clone https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git /tmp/sbsigntools && \ |
| 111 | cd /tmp/sbsigntools && \ |
| 112 | git checkout -b latest v0.9.4 && \ |
| 113 | ./autogen.sh && \ |
| 114 | ./configure && \ |
| 115 | make && \ |
| 116 | make install && \ |
| 117 | rm -rf /tmp/sbsigntools |
| 118 | |
| 119 | # Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit |
| 120 | RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \ |
| 121 | cd /tmp/grub && \ |
Tom Rini | 7bb1cc3 | 2021-07-02 10:41:58 -0400 | [diff] [blame] | 122 | git checkout grub-2.06 && \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 123 | ./bootstrap && \ |
| 124 | mkdir -p /opt/grub && \ |
| 125 | ./configure --target=aarch64 --with-platform=efi \ |
| 126 | CC=gcc \ |
Tom Rini | 7bb1cc3 | 2021-07-02 10:41:58 -0400 | [diff] [blame] | 127 | TARGET_CC=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \ |
| 128 | TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \ |
| 129 | TARGET_STRIP=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \ |
| 130 | TARGET_NM=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \ |
| 131 | TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 132 | make && \ |
| 133 | ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \ |
| 134 | grub-core cat chain configfile echo efinet ext2 fat halt help linux \ |
| 135 | lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \ |
| 136 | search search_fs_file search_fs_uuid search_label serial sleep test \ |
| 137 | true && \ |
| 138 | make clean && \ |
| 139 | ./configure --target=arm --with-platform=efi \ |
| 140 | CC=gcc \ |
Tom Rini | 7bb1cc3 | 2021-07-02 10:41:58 -0400 | [diff] [blame] | 141 | TARGET_CC=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \ |
| 142 | TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \ |
| 143 | TARGET_STRIP=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \ |
| 144 | TARGET_NM=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \ |
| 145 | TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 146 | make && \ |
| 147 | ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \ |
| 148 | grub-core cat chain configfile echo efinet ext2 fat halt help linux \ |
| 149 | lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \ |
| 150 | search search_fs_file search_fs_uuid search_label serial sleep test \ |
| 151 | true && \ |
| 152 | make clean && \ |
| 153 | ./configure --target=riscv64 --with-platform=efi \ |
| 154 | CC=gcc \ |
Tom Rini | 7bb1cc3 | 2021-07-02 10:41:58 -0400 | [diff] [blame] | 155 | TARGET_CC=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \ |
| 156 | TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \ |
| 157 | TARGET_STRIP=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \ |
| 158 | TARGET_NM=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \ |
| 159 | TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 160 | make && \ |
| 161 | ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \ |
| 162 | grub-core cat chain configfile echo efinet ext2 fat halt help linux \ |
| 163 | lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \ |
| 164 | search search_fs_file search_fs_uuid search_label serial sleep test \ |
| 165 | true && \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 166 | rm -rf /tmp/grub |
| 167 | |
| 168 | RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \ |
| 169 | cd /tmp/qemu && \ |
| 170 | git submodule update --init dtc && \ |
Bin Meng | a30e53c | 2021-08-26 23:33:32 +0800 | [diff] [blame] | 171 | git checkout v6.1.0 && \ |
| 172 | # config user.name and user.email to make 'git am' happy |
| 173 | git config user.name u-boot && \ |
| 174 | git config user.email u-boot@denx.de && \ |
| 175 | # manually apply the bug fix for QEMU 6.1.0 Xilinx Zynq UART emulation codes |
| 176 | wget -O - http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-bmeng.cn@gmail.com/mbox/ | git am && \ |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 177 | ./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" && \ |
| 178 | make -j$(nproc) all install && \ |
| 179 | rm -rf /tmp/qemu |
| 180 | |
Bin Meng | 3283a05 | 2021-08-26 23:33:33 +0800 | [diff] [blame] | 181 | # Build genimage (required by some targets to generate disk images) |
| 182 | RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \ |
| 183 | cd /tmp/genimage-14 && \ |
| 184 | ./configure && \ |
| 185 | make -j$(nproc) && \ |
| 186 | make install && \ |
| 187 | rm -rf /tmp/genimage-14 |
| 188 | |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 189 | # Create our user/group |
| 190 | RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot |
| 191 | RUN useradd -m -U uboot |
| 192 | USER uboot:uboot |
| 193 | |
| 194 | # Create the buildman config file |
| 195 | RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman |
Tom Rini | 7bb1cc3 | 2021-07-02 10:41:58 -0400 | [diff] [blame] | 196 | RUN /bin/echo -e "kernelorg = /opt/gcc-11.1.0-nolibc/*" >> ~/.buildman |
| 197 | RUN /bin/echo -e "arc = /opt/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman |
| 198 | RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman; |
Tom Rini | a643225 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 199 | RUN /bin/echo -e "\nnds32 = /opt/nds32le-linux-glibc-v3-upstream/bin/nds32le-linux-" >> ~/.buildman; |
| 200 | RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman |
| 201 | RUN /bin/echo -e "\nriscv = riscv64" >> ~/.buildman |
| 202 | RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman |
| 203 | RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman; |