Skip to content

Instantly share code, notes, and snippets.

@nuumio
Created February 2, 2021 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuumio/4dde0b8133c3a5bcf552d43fd06d04f9 to your computer and use it in GitHub Desktop.
Save nuumio/4dde0b8133c3a5bcf552d43fd06d04f9 to your computer and use it in GitHub Desktop.
Container for building U-Boot (at least for RK3399, BSP & mainline)

Container for U-Boot building

At least this was working with Docker. Currently working with Podman.

Really short instructions for building U-Boot

Run something like this:

$ mkdir ~/uboot-workarea && cd ~/uboot-workarea
$ git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/
$ git clone https://gitlab.denx.de/u-boot/u-boot.git/
$ uboot-builder
$ cd trusted-firmware-a/
$ git checkout v2.4
$ make PLAT=rk3399 CROSS_COMPILE=aarch64-linux-gnu- -j24
$ export BL31="$(find ${PWD} -name bl31.elf)" && echo "BL31=${BL31}"
$ cd ../u-boot/
$ git checkout v2021.01
$ make CROSS_COMPILE=aarch64-linux-gnu- rockpro64-rk3399_defconfig
$ make CROSS_COMPILE=aarch64-linux-gnu- all u-boot.itb -j24

That's for RockPro64. Use pinebook-pro-rk3399_defconfig for PBP.

Extremely short instructions for building container image

$ ./build-image.sh
$ mkdir -p ~/bin
$ ln -s "${PWD}/run-image.sh" ~/bin/uboot-builder
#!/bin/bash
set -e
podman build -t uboot-builder -f ./Dockerfile
FROM ubuntu:focal
LABEL author="Jari Hämäläinen <nuum.io.fi@gmail.com>"
ENV DEBIAN_FRONTEND 'noninteractive'
ENV XZ_DEFAULTS '-T0'
# Basic setup, install tools etc.
# Some packages are just from my previous tools containers.
# Some packages just grabbed from: https://wiki.radxa.com/Rockpi4/dev/u-boot
# Added gcc-arm-none-eabi, rename, bison, git, python3 and python-pyelftools.
# Should be able to build both BSP and mainline uboot for RK3399 devices.
# And TFA too.
RUN set -ex \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
less \
locales \
nano \
sed \
tar \
gcc-aarch64-linux-gnu \
device-tree-compiler \
libncurses5 \
libncurses5-dev \
bc \
python \
dosfstools \
flex \
build-essential \
libssl-dev \
mtools \
gcc-arm-none-eabi \
rename \
bison \
git \
python-pyelftools \
python3 \
&& locale-gen en_US.utf8
# Clean up apt
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/*
CMD ["/bin/bash"]
#!/bin/bash
set -e
# Use host timezone if available.
if [ -f /etc/timezone ]; then
HOSTTZ="-v /etc/timezone:/etc/timezone:ro"
else
HOSTTZ=""
fi
podman run -ti --rm \
-w "${PWD}" \
-v "${PWD}:${PWD}" \
${HOSTTZ} \
--tmpfs /tmp:exec \
uboot-builder \
${@}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment