# Archived: unmaintained
maintainer=""
pkgname=u-boot-xunlong-orangepi-zero3
pkgver=2025.04
pkgrel=1
pkgdesc="U-Boot bootloader for the Xunlong Orage Pi Zero 3"
url="https://source.denx.de/u-boot"
arch="aarch64"
license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause eCos-2.0 IBM-pibs
	ISC LGPL-2.0-only LGPL-2.1-only X11"
depends="linux-postmarketos-allwinner"
replaces="u-boot-sunxi"
makedepends="$depends_dev
	arm-trusted-firmware>=2.12.8-r1
	bc
	bison
	dtc
	flex
	openssl-dev
	py3-setuptools
	python3-dev
	swig
	gnutls
	gnutls-dev
	"
options="!check"
source="https://source.denx.de/u-boot/u-boot/-/archive/v$pkgver/u-boot-v$pkgver.tar.gz
	0001-sunxi-h616-dram-Rework-size-detection.patch
	0002-sunxi-H616-dram-Improve-address-wrapping-detection.patch
	0003-sunxi-mmc-Improve-reset-procedure.patch
	0004-Add-MACH_SUN8I_A83T-to-can-calibrate.patch
	0005-board-sunxi-The-prefix-is-missing-if-we-use-OF_UPSTREAM.patch
	0006-dts-upstream-arm64-sun50i-h616-sync-with-sunxi-6.12-kernel.patch
	0007-dts-upstream-arm64-Add-sun50i-h618-bananapi-m4-berry.dts.patch
	0008-u-boot-configs-Add-sun50i-h618-bananapi-m4berry-defconfig.patch
	0009-sunxi-h616-dram-support-1.5GB-RAM-size-pmos.patch
	0010-python-3.13-binman-migrate-from-pkg_resources-to-imp.patch
	update-u-boot
	"
builddir="$srcdir/u-boot-v$pkgver"

build() {
	touch include/config.h
	LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > include/timestamp_autogenerated.h
	LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> include/timestamp_autogenerated.h

	export BL31="/usr/share/arm-trusted-firmware/sun50i_h616/bl31.bin"
	export BUILD_DIR="$builddir"/build

	make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm orangepi_zero3_defconfig
	make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm all
	sha512sum -b "$BUILD_DIR/u-boot-sunxi-with-spl.bin" > "$BUILD_DIR/u-boot-sunxi-with-spl.bin.sha512"
}

package() {
	install -D -m644 "build/u-boot-sunxi-with-spl.bin" \
		"$pkgdir/usr/share/u-boot/orangepi_zero3/u-boot-sunxi-with-spl.bin"
	install -D -m644 "build/u-boot-sunxi-with-spl.bin.sha512" \
		"$pkgdir/usr/share/u-boot/orangepi_zero3/u-boot-sunxi-with-spl.bin.sha512"
	install -D -m 755 "$srcdir"/update-u-boot "$pkgdir"/usr/sbin/update-u-boot
}

sha512sums="
5b6759bccffd586f8d79dc8ab286f0f98c46bb99a1c4250b6626b1bcd03ba287fd8a48b47667b53627435e8012a083150546825a303145b0163872ad918a4652  u-boot-v2025.04.tar.gz
f909011abe0dbb103502107ff1117a20ef527454743dc23b09cf8d158d228fd4265b8a961084a6813e90407e69776ea8a823c1400740a59fedf19a084f4120c3  0001-sunxi-h616-dram-Rework-size-detection.patch
7fc447ab96ac9681cf2e91d5dae14070bfb6723dfd6d2cb2d335d7524a3b6cf614d167ed479d149cee8aa3689bcd1984f1d3281d01dd7d077702e040326c8194  0002-sunxi-H616-dram-Improve-address-wrapping-detection.patch
10b4026461fb4df0e9538db8591d76138c397e6e18621f9f3265ea8f5fbade23d1710c18346928b925390f988c1bea5b8e0663076c00bd83261c40bc27f44f7c  0003-sunxi-mmc-Improve-reset-procedure.patch
99df087471645d5824a52fd2d594eacbdb5e3ea6f6bfed0a46eb2bf0c51155bf628daf25449b6d8b9d0dddc11933041e20eb1bfde69bd4bae3f7c7ea56ac30cf  0004-Add-MACH_SUN8I_A83T-to-can-calibrate.patch
5593bfebee96437807a27970e413506e35b308540923770737e6dc058e8e5720e0a07619849f9845d57b01c126d9fc9134f52d0c7ae9ff245af7c7ddd8ee14c2  0005-board-sunxi-The-prefix-is-missing-if-we-use-OF_UPSTREAM.patch
8cc29615d4c47bec4fb0ef9d576398554f8441b307ac44ab950ac549115d795d1cfbaacfbf8400815f1b36b191bcb5465b9732ed468b7cb9ca209fd84d7ffe91  0006-dts-upstream-arm64-sun50i-h616-sync-with-sunxi-6.12-kernel.patch
db734ef264b8bfa6eaabad946f049c790cd8f4970111b7e30d63c04450d93d17e39cabfb67817fef0fd22553c0780c174f0e11a847e7e7edc3140b5b4f084afd  0007-dts-upstream-arm64-Add-sun50i-h618-bananapi-m4-berry.dts.patch
4ea374c133a9ac274aec67cb2530e03eef019e9a6be5989d633525c58ab3900e38eb675777df84bbd7bd0345ec6e204c52c90b33d2dbc65474af0ee8b43d55d7  0008-u-boot-configs-Add-sun50i-h618-bananapi-m4berry-defconfig.patch
f967471c779b852a0db6dd7ebc200a936d8a2fe29d903c34f0735f7fb771dbed175db27e9c5b20f37855ed68ad72bb7d7a6eda4d6ad2dd8dfe434e70448b4d8e  0009-sunxi-h616-dram-support-1.5GB-RAM-size-pmos.patch
c0545c6a1d17507f7e4bc337200fa3a4a1a89d62122cc6599ea00f27187b85f3e322d945683a84cdff98d981cf604187ded05d7b93bb5fae5a3fe7f9751077a2  0010-python-3.13-binman-migrate-from-pkg_resources-to-imp.patch
6c4cb066b1ec19b762ccbfbe906492afb4cf32cd1ffadc22ce4cfe254245d5b971f2cabb8a336585366bd329cdeab8b27e96d3bee40aa14ef72cc9ecf49a61c3  update-u-boot
"
