maintainer=""
pkgname=u-boot-dongshanpi-nezhastu
pkgver=2022.10_git20221101
pkgrel=0
pkgdesc="U-Boot for DongshanPi NeZhaSTU"
url="https://github.com/smaeul/u-boot/tree/d1-wip"
arch="riscv64"
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"
makedepends="$depends_dev py3-setuptools bc dtc python3-dev swig bison flex openssl-dev opensbi"
options="!check"
# d1-wip branch
_commit="528ae9bc6c55edd3ffe642734b4132a8246ea777"
source="u-boot-$_commit.tar.gz::https://github.com/smaeul/u-boot/archive/$_commit.tar.gz
	update-u-boot
	"
builddir="$srcdir"/u-boot-$_commit

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 OPENSBI="/usr/share/opensbi/generic/firmware/fw_dynamic.bin"
	export BUILD_DIR="$builddir"/build
	mkdir -p "$BUILD_DIR"
	make O="$BUILD_DIR" dongshan_nezha_stu_defconfig
	make O="$BUILD_DIR" all
}

package() {
	install -Dm644 build/u-boot-sunxi-with-spl.bin \
		"$pkgdir"/usr/share/u-boot/dongshan_nezha_stu/u-boot-sunxi-with-spl.bin
	install -Dm755 "$srcdir"/update-u-boot "$pkgdir"/usr/sbin/update-u-boot
}

sha512sums="
41cac25c10c6a1ac951a10af336df96ad77283b036cf17d7aca64bf81bc7e04b8c145778fb250b429cae71ac3350e1ba42ef8d9604d52d03c5fe8715901994b3  u-boot-528ae9bc6c55edd3ffe642734b4132a8246ea777.tar.gz
5e3473031bacf6443fb476373f5f40d01f63a0369f0c93814421b6937db15baa7b20dc9ecfac0cc9f8e43491b1e61d581bf9542e215368c537c365aa388de711  update-u-boot
"
