2021-03-15 17:19:01 +00:00
# SPDX-License-Identifier: GPL-2.0+
# This Dockerfile is used to build an image containing basic stuff to be used
# to build U-Boot and run our test suites.
2023-03-21 19:31:19 +00:00
FROM ubuntu:jammy-20230308
2021-03-15 17:19:01 +00:00
MAINTAINER Tom Rini <trini@konsulko.com>
LABEL Description = " This image is for building U-Boot inside a container"
# Make sure apt is happy
ENV DEBIAN_FRONTEND = noninteractive
# Add LLVM repository
RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib/apt/lists/*
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
2022-11-22 17:31:58 +00:00
RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main | tee /etc/apt/sources.list.d/llvm.list
2021-03-15 17:19:01 +00:00
2022-11-22 17:31:58 +00:00
# Manually install the kernel.org "Crosstool" based toolchains for gcc-12.2.0
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-aarch64-linux.tar.xz | tar -C /opt -xJ
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-m68k-linux.tar.xz | tar -C /opt -xJ
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-microblaze-linux.tar.xz | tar -C /opt -xJ
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-nios2-linux.tar.xz | tar -C /opt -xJ
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-riscv32-linux.tar.xz | tar -C /opt -xJ
RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ
2021-03-15 17:19:01 +00:00
# Manually install other toolchains
2021-07-02 14:41:58 +00:00
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
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
2021-03-15 17:19:01 +00:00
# Update and install things from apt now
RUN apt-get update && apt-get install -y \
automake \
autopoint \
bc \
binutils-dev \
bison \
build-essential \
2022-11-22 17:31:58 +00:00
clang-14 \
2021-03-15 17:19:01 +00:00
coreutils \
cpio \
cppcheck \
curl \
device-tree-compiler \
dosfstools \
e2fsprogs \
efitools \
2022-02-26 07:05:51 +00:00
erofs-utils \
2021-11-09 18:51:20 +00:00
expect \
2021-03-15 17:19:01 +00:00
fakeroot \
flex \
2021-11-09 18:51:20 +00:00
gawk \
2021-03-15 17:19:01 +00:00
gdisk \
git \
gnu-efi \
2021-11-09 18:51:20 +00:00
gnutls-dev \
2021-03-15 17:19:01 +00:00
graphviz \
grub-efi-amd64-bin \
grub-efi-ia32-bin \
help2man \
iasl \
imagemagick \
iputils-ping \
2023-01-11 17:24:57 +00:00
libc6-i386 \
2021-08-26 15:33:33 +00:00
libconfuse-dev \
2021-06-10 14:57:36 +00:00
libgit2-dev \
2021-11-09 18:51:20 +00:00
libjson-glib-dev \
2021-03-15 17:19:01 +00:00
libguestfs-tools \
2022-02-01 01:32:36 +00:00
libgnutls28-dev \
libgnutls30 \
2021-03-15 17:19:01 +00:00
liblz4-tool \
libpixman-1-dev \
2021-06-10 14:57:36 +00:00
libpython3-dev \
2021-03-15 17:19:01 +00:00
libsdl1.2-dev \
libsdl2-dev \
2021-11-09 18:51:20 +00:00
libseccomp-dev \
2021-03-15 17:19:01 +00:00
libssl-dev \
2021-11-09 18:51:20 +00:00
libtool \
2021-03-15 17:19:01 +00:00
libudev-dev \
libusb-1.0-0-dev \
2021-06-21 18:51:54 +00:00
linux-image-kvm \
2021-03-15 17:19:01 +00:00
lzma-alone \
lzop \
mount \
mtd-utils \
mtools \
2021-11-09 18:51:20 +00:00
net-tools \
2021-08-26 15:33:32 +00:00
ninja-build \
2021-03-15 17:19:01 +00:00
openssl \
picocom \
parted \
pkg-config \
2021-06-10 14:57:36 +00:00
python-is-python3 \
python2.7 \
python3 \
python3-dev \
2021-03-15 17:19:01 +00:00
python3-pip \
2022-10-13 12:25:57 +00:00
python3-pyelftools \
2021-03-15 17:19:01 +00:00
python3-sphinx \
2021-06-10 14:57:36 +00:00
python3-virtualenv \
2021-03-15 17:19:01 +00:00
rpm2cpio \
sbsigntool \
sloccount \
2021-11-09 18:51:20 +00:00
socat \
softhsm2 \
2021-03-15 17:19:01 +00:00
sparse \
srecord \
sudo \
swig \
2022-12-30 04:41:01 +00:00
texinfo \
2021-03-15 17:19:01 +00:00
util-linux \
uuid-dev \
virtualenv \
2021-07-02 14:41:58 +00:00
xxd \
2021-03-15 17:19:01 +00:00
zip \
&& rm -rf /var/lib/apt/lists/*
2021-06-21 18:51:54 +00:00
# Make kernels readable for libguestfs tools to work correctly
RUN chmod +r /boot/vmlinu*
2021-03-15 17:19:01 +00:00
# Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
cd /tmp/grub && \
2021-07-02 14:41:58 +00:00
git checkout grub-2.06 && \
2022-11-22 17:31:58 +00:00
git config --global user.name "GitLab CI Runner" && \
git config --global user.email trini@konsulko.com && \
git cherry-pick 049efdd72eb7baa7b2bf8884391ee7fe650da5a0 && \
2021-03-15 17:19:01 +00:00
./bootstrap && \
mkdir -p /opt/grub && \
./configure --target= aarch64 --with-platform= efi \
CC = gcc \
2022-11-22 17:31:58 +00:00
TARGET_CC = /opt/gcc-12.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
TARGET_OBJCOPY = /opt/gcc-12.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
TARGET_STRIP = /opt/gcc-12.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
TARGET_NM = /opt/gcc-12.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
TARGET_RANLIB = /opt/gcc-12.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
2021-03-15 17:19:01 +00:00
make && \
./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
grub-core cat chain configfile echo efinet ext2 fat halt help linux \
lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
search search_fs_file search_fs_uuid search_label serial sleep test \
true && \
make clean && \
./configure --target= arm --with-platform= efi \
CC = gcc \
2022-11-22 17:31:58 +00:00
TARGET_CC = /opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
TARGET_OBJCOPY = /opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
TARGET_STRIP = /opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
TARGET_NM = /opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
TARGET_RANLIB = /opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
2021-03-15 17:19:01 +00:00
make && \
./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
grub-core cat chain configfile echo efinet ext2 fat halt help linux \
lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
search search_fs_file search_fs_uuid search_label serial sleep test \
true && \
make clean && \
./configure --target= riscv64 --with-platform= efi \
CC = gcc \
2022-11-22 17:31:58 +00:00
TARGET_CC = /opt/gcc-12.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
TARGET_OBJCOPY = /opt/gcc-12.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
TARGET_STRIP = /opt/gcc-12.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
TARGET_NM = /opt/gcc-12.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
TARGET_RANLIB = /opt/gcc-12.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
2021-03-15 17:19:01 +00:00
make && \
./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
grub-core cat chain configfile echo efinet ext2 fat halt help linux \
lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
search search_fs_file search_fs_uuid search_label serial sleep test \
true && \
rm -rf /tmp/grub
2023-02-07 17:50:13 +00:00
RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
2021-03-15 17:19:01 +00:00
cd /tmp/qemu && \
git submodule update --init dtc && \
2021-08-26 15:33:32 +00:00
git checkout v6.1.0 && \
# config user.name and user.email to make 'git am' happy
git config user.name u-boot && \
git config user.email u-boot@denx.de && \
# manually apply the bug fix for QEMU 6.1.0 Xilinx Zynq UART emulation codes
wget -O - http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-bmeng.cn@gmail.com/mbox/ | git am && \
2023-03-21 19:28:00 +00:00
./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" && \
2021-03-15 17:19:01 +00:00
make -j$( nproc) all install && \
rm -rf /tmp/qemu
2023-01-13 19:31:33 +00:00
# Build QEMU supporting Nokia n900 emulation
RUN mkdir -p /opt/nokia && \
cd /tmp && \
git clone https://git.linaro.org/qemu/qemu-linaro.git && \
cd /tmp/qemu-linaro && \
git checkout 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1 && \
./configure --enable-system --target-list= arm-softmmu \
--python= /usr/bin/python2.7 --disable-sdl --disable-gtk \
--disable-curses --audio-drv-list= --audio-card-list= \
--disable-werror --disable-xen --disable-xen-pci-passthrough \
--disable-brlapi --disable-vnc --disable-curl --disable-slirp \
--disable-kvm --disable-user --disable-linux-user --disable-bsd-user \
--disable-guest-base --disable-uuid --disable-vde --disable-linux-aio \
--disable-cap-ng --disable-attr --disable-blobs --disable-docs \
--disable-spice --disable-libiscsi --disable-smartcard-nss \
--disable-usb-redir --disable-guest-agent --disable-seccomp \
--disable-glusterfs --disable-nptl --disable-fdt && \
make -j$( nproc) && \
cp /tmp/qemu-linaro/arm-softmmu/qemu-system-arm /opt/nokia && \
rm -rf /tmp/qemu-linaro
2021-08-26 15:33:33 +00:00
# Build genimage (required by some targets to generate disk images)
RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \
cd /tmp/genimage-14 && \
./configure && \
make -j$( nproc) && \
make install && \
rm -rf /tmp/genimage-14
2021-11-09 18:51:20 +00:00
# Build libtpms
RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \
cd /tmp/libtpms && \
./autogen.sh && \
./configure && \
make -j$( nproc) && \
make install && \
ldconfig && \
rm -rf /tmp/libtpms
# Build swtpm
RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \
cd /tmp/swtpm && \
./autogen.sh && \
./configure && \
make -j$( nproc) && \
make install && \
rm -rf /tmp/swtpm
2023-01-15 21:15:59 +00:00
# Build trace-cmd
RUN mkdir /tmp/trace && \
git clone https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git /tmp/trace/libtraceevent && \
cd /tmp/trace/libtraceevent && \
make -j$( nproc) && \
sudo make install && \
git clone https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git /tmp/trace/libtracefs && \
cd /tmp/trace/libtracefs && \
make -j$( nproc) && \
sudo make install && \
git clone https://github.com/rostedt/trace-cmd.git /tmp/trace/trace-cmd && \
cd /tmp/trace/trace-cmd && \
make -j$( nproc) && \
sudo make install && \
rm -rf /tmp/trace
2023-01-13 18:25:01 +00:00
# Files to run Nokia RX-51 (aka N900) tests
RUN mkdir -p /opt/nokia && \
cd /opt/nokia && \
wget https://raw.githubusercontent.com/pali/u-boot-maemo/master/debian/u-boot-gen-combined && \
2023-02-27 15:49:54 +00:00
chmod 0755 u-boot-gen-combined && \
2023-01-13 18:25:01 +00:00
wget http://repository.maemo.org/qemu-n900/qemu-n900.tar.gz && \
wget http://repository.maemo.org/pool/maemo5.0/free/k/kernel/kernel_2.6.28-20103103+0m5_armel.deb && \
wget http://repository.maemo.org/pool/maemo5.0/free/g/glibc/libc6_2.5.1-1eglibc27+0m5_armel.deb && \
wget http://repository.maemo.org/pool/maemo5.0/free/b/busybox/busybox_1.10.2.legal-1osso30+0m5_armel.deb
2021-03-15 17:19:01 +00:00
# Create our user/group
RUN echo uboot ALL = NOPASSWD: ALL > /etc/sudoers.d/uboot
RUN useradd -m -U uboot
USER uboot:uboot
# Create the buildman config file
RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
2022-11-22 17:31:58 +00:00
RUN /bin/echo -e "kernelorg = /opt/gcc-12.2.0-nolibc/*" >> ~/.buildman
2021-07-02 14:41:58 +00:00
RUN /bin/echo -e "arc = /opt/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
2021-03-15 17:19:01 +00:00
RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;