# U-boot with patches to make the PinePhone boot faster and have control over the ddr clock speed

pkgname=u-boot-pinephone
pkgver=2020.04_git20200228
pkgrel=0
_commit="ec643935990b517e96ba9676eb0093b9bec96189"
pkgdesc="u-boot bootloader for the PINE64 PinePhone"
url="https://gitlab.com/pine64-org/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"
makedepends="$depends_dev bc dtc python3-dev swig bison flex openssl-dev arm-trusted-firmware-sun50i"
options="!check"
source="
	$pkgname-$_commit.tar.gz::https://gitlab.com/pine64-org/u-boot/-/archive/$_commit/u-boot-$_commit.tar.gz
	dram-speed.patch
	"
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 BL31="/usr/share/arm-trusted-firmware-sun50i/bl31.bin"
	export BUILD_DIR="$builddir"/build
	mkdir -p "$BUILD_DIR"
	make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm pinephone_defconfig
	make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm all
}

package() {
	cd "$builddir"/build
	install -D -m644 "u-boot-sunxi-with-spl.bin" \
		"$pkgdir"/usr/share/u-boot/pine64-pinephone/u-boot-sunxi-with-spl.bin
}


sha512sums="3fec7e60b04539ddab241920a8e691acf2695e049fa726f52de632b40828a6f9db51c4b260364bb41dad9878d771b6024d6733d8957abbcee805049e3905d933  u-boot-pinephone-ec643935990b517e96ba9676eb0093b9bec96189.tar.gz
0331e05f9077eb4c8219b5fa804a8372a0ca20957cacfdff618d2045f64949581418aef4dfef2e87c31ca218c9ac22e20cf8021b679c5fa7cfb9f89876da02fa  dram-speed.patch"
