The Orange Pi Zero3 is not officially supported by the mainline U-Boot project yet. Luckily a patch has been released by github.com/Doct2O. I am able to build u-boot v2023.10 with ATF v2.9.0 and boot Fedora 39 Beta on my 4GiB variant. The upstream project has a prebuilt binary already, and the instruction is very easy follow, but unfortunately uses cross-compilers which I don’t use anymore. This post will show you how to build your own u-boot binary for the Orange Pi Zero3 with buildah.

Build process in general

  1. Build BL31 binary from ATF (ARM Trusted Firmware) project
  2. Clone mainline u-boot and apply the patch from github.com/Doct2O
  3. Build u-boot binary from the patched u-boot project

The build_u-boot_orangepi_zero3.sh script

# cat build_u-boot_orangepi_zero3.sh

# Set atf_ver and uboot_ver environment variables
export atf_ver="v2.9.0"
export uboot_ver="v2023.10"

export container=$(buildah from arm64v8/alpine:3.18)
buildah config --label maintainer=""github.com/deamen"" $container

# Set atf_ver environment variables in container
buildah config --env atf_ver=$atf_ver $container

#Set uboot_ver environment variables in container
buildah config --env uboot_ver=$uboot_ver $container

buildah run $container apk add git gcc make libc-dev bison flex openssl-dev python3 dtc gcc-arm-none-eabi py3-setuptools swig python3-dev py3-elftools patch
buildah run $container git clone https://github.com/ARM-software/arm-trusted-firmware.git --depth 1 --branch $atf_ver
buildah run $container git clone https://github.com/u-boot/u-boot.git --depth 1 --branch $uboot_ver
buildah run $container git clone https://github.com/Doct2O/orangepi-zero3-bl.git

buildah config --workingdir "/arm-trusted-firmware" $container
buildah run $container make -j$(nproc --ignore 1) PLAT=sun50i_h616 DEBUG=0 bl31
buildah config --env BL31="/arm-trusted-firmware/build/sun50i_h616/release/bl31.bin" $container

buildah config --workingdir "/u-boot" $container
buildah run $container git apply /orangepi-zero3-bl/0001-Defconfig-For-Orangepi-Zero3-PMIC-Env-From-Fat.patch

buildah run $container make -j$(nproc --ignore 1) orangepi_zero3_defconfig

buildah run $container make -j$(nproc --ignore 1) CONFIG_SPL_IMAGE_TYPE=sunxi_egon

copy_script="copy_u-boot.sh"
cat << 'EOF' >> $copy_script
#!/bin/sh
mnt=$(buildah mount $container)
cp $mnt/u-boot/u-boot-sunxi-with-spl.bin ./out/u-boot-orangepi-zero3-with-spl.bin
buildah umount $container
EOF
chmod a+x $copy_script
buildah unshare ./$copy_script
rm ./$copy_script
buildah rm $container

After running the script, you will have a u-boot binary in the out directory as u-boot-orangepi-zero3-with-spl.bin. You can flash this binary with the dd command:

sudo dd if=./out/u-boot-orangepi-zero3-with-spl.bin of=/dev/sda bs=1k seek=8