The Orange Pi Zero3 has been supported by the mainline Linux kernel since v6.6, but the NIC is not stable yet. Until this patch shows up in the mailing list: https://lore.kernel.org/lkml/20231029074009.7820-2-amadeus@jmu.edu.cn/T/. This post will show you how to build the DTB for the Orange Pi Zero3 with buildah from the mainline Linux kernel source.

The build_dtb_orangepi_zero3.sh script

# cat build_dtb_orangepi_zero3.sh

# Set kernel_ver environment variables
export kernel_ver="v6.6"

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

# Set kernel_ver environment variables in container
buildah config --env kernel_ver=$kernel_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/torvalds/linux.git --depth 1 --branch $kernel_ver

buildah copy $container orangepi_zero3/0001-orangepi-zero3-dts-linux-6.6.patch /tmp/

buildah config --workingdir "/linux" $container
buildah run $container git apply /tmp/0001-orangepi-zero3-dts-linux-6.6.patch
buildah run $container make defconfig
buildah run $container make -j$(nproc --ignore 1) allwinner/sun50i-h618-orangepi-zero3.dtb

copy_script="copy_artifacts.sh"
cat << 'EOF' >> $copy_script
#!/bin/sh
mnt=$(buildah mount $container)
cp $mnt/$1 ./out/$2
buildah umount $container
EOF
chmod a+x $copy_script
buildah unshare ./$copy_script linux/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dtb dtb_orangepi_zero3.dtb
rm ./$copy_script
buildah rm $container

After running the script, you will have a DTB binary in the out directory as dtb_orangepi_zero3.dtb. You can use this DTB binary to boot your Orange Pi Zero3 with the mainline Linux kernel, but you will need at least v6.5 to boot the board.

Build DTB on x86_64

I am using the arm64 container to build the DTBs but it is not necessary, you can build on an x86_64 with the following commands:

ARCH="arm64" make defconfig
ARCH="arm64"  make -j$(nproc --ignore 1) allwinner/sun50i-h618-orangepi-zero3.dtb