Dockerfile 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. FROM ubuntu:focal-20210723
  5. MAINTAINER Tom Rini <trini@konsulko.com>
  6. LABEL Description=" This image is for building U-Boot inside a container"
  7. # Make sure apt is happy
  8. ENV DEBIAN_FRONTEND=noninteractive
  9. # Add LLVM repository
  10. RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib/apt/lists/*
  11. RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
  12. RUN echo deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main | tee /etc/apt/sources.list.d/llvm.list
  13. # Manually install the kernel.org "Crosstool" based toolchains for gcc-11.1.0
  14. 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
  15. 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
  16. 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
  17. 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
  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-mips-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-microblaze-linux.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-nios2-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-powerpc-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-riscv64-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-sh2-linux.tar.xz | tar -C /opt -xJ
  24. # Manually install other toolchains
  25. 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
  26. 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
  27. RUN wget -O - https://github.com/vincentzwc/prebuilt-nds32-toolchain/releases/download/20180521/nds32le-linux-glibc-v3-upstream.tar.gz | tar -C /opt -xz
  28. # Update and install things from apt now
  29. RUN apt-get update && apt-get install -y \
  30. automake \
  31. autopoint \
  32. bc \
  33. binutils-dev \
  34. bison \
  35. build-essential \
  36. clang-12 \
  37. coreutils \
  38. cpio \
  39. cppcheck \
  40. curl \
  41. device-tree-compiler \
  42. dosfstools \
  43. e2fsprogs \
  44. efitools \
  45. fakeroot \
  46. flex \
  47. gdisk \
  48. git \
  49. gnu-efi \
  50. graphviz \
  51. grub-efi-amd64-bin \
  52. grub-efi-ia32-bin \
  53. help2man \
  54. iasl \
  55. imagemagick \
  56. iputils-ping \
  57. libgit2-dev \
  58. libguestfs-tools \
  59. liblz4-tool \
  60. libpixman-1-dev \
  61. libpython3-dev \
  62. libsdl1.2-dev \
  63. libsdl2-dev \
  64. libssl-dev \
  65. libudev-dev \
  66. libusb-1.0-0-dev \
  67. linux-image-kvm \
  68. lzma-alone \
  69. lzop \
  70. mount \
  71. mtd-utils \
  72. mtools \
  73. openssl \
  74. picocom \
  75. parted \
  76. pkg-config \
  77. python-is-python3 \
  78. python2.7 \
  79. python3 \
  80. python3-dev \
  81. python3-pip \
  82. python3-sphinx \
  83. python3-virtualenv \
  84. rpm2cpio \
  85. sbsigntool \
  86. sloccount \
  87. sparse \
  88. srecord \
  89. sudo \
  90. swig \
  91. util-linux \
  92. uuid-dev \
  93. virtualenv \
  94. xxd \
  95. zip \
  96. && rm -rf /var/lib/apt/lists/*
  97. # Make kernels readable for libguestfs tools to work correctly
  98. RUN chmod +r /boot/vmlinu*
  99. # Manually install a new enough version of sbsigntools (must be v0.9.4 or later)
  100. RUN git clone https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git /tmp/sbsigntools && \
  101. cd /tmp/sbsigntools && \
  102. git checkout -b latest v0.9.4 && \
  103. ./autogen.sh && \
  104. ./configure && \
  105. make && \
  106. make install && \
  107. rm -rf /tmp/sbsigntools
  108. # Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
  109. RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
  110. cd /tmp/grub && \
  111. git checkout grub-2.06 && \
  112. ./bootstrap && \
  113. mkdir -p /opt/grub && \
  114. ./configure --target=aarch64 --with-platform=efi \
  115. CC=gcc \
  116. TARGET_CC=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
  117. TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
  118. TARGET_STRIP=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
  119. TARGET_NM=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
  120. TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
  121. make && \
  122. ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
  123. grub-core cat chain configfile echo efinet ext2 fat halt help linux \
  124. lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
  125. search search_fs_file search_fs_uuid search_label serial sleep test \
  126. true && \
  127. make clean && \
  128. ./configure --target=arm --with-platform=efi \
  129. CC=gcc \
  130. TARGET_CC=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
  131. TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
  132. TARGET_STRIP=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
  133. TARGET_NM=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
  134. TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
  135. make && \
  136. ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.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=riscv64 --with-platform=efi \
  143. CC=gcc \
  144. TARGET_CC=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
  145. TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
  146. TARGET_STRIP=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
  147. TARGET_NM=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
  148. TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
  149. make && \
  150. ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.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. rm -rf /tmp/grub
  156. RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \
  157. cd /tmp/qemu && \
  158. git submodule update --init dtc && \
  159. git checkout v4.2.0 && \
  160. ./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" && \
  161. make -j$(nproc) all install && \
  162. rm -rf /tmp/qemu
  163. # Create our user/group
  164. RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
  165. RUN useradd -m -U uboot
  166. USER uboot:uboot
  167. # Create the buildman config file
  168. RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
  169. RUN /bin/echo -e "kernelorg = /opt/gcc-11.1.0-nolibc/*" >> ~/.buildman
  170. RUN /bin/echo -e "arc = /opt/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
  171. RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
  172. RUN /bin/echo -e "\nnds32 = /opt/nds32le-linux-glibc-v3-upstream/bin/nds32le-linux-" >> ~/.buildman;
  173. RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
  174. RUN /bin/echo -e "\nriscv = riscv64" >> ~/.buildman
  175. RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
  176. RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;