Newer
Older
# Contributor: Dan Johansen <strit@manjaro.org>
# Contributor: Dragan Simic <dsimic@buserror.io>
_tfanon=rk3399_ddr_933MHz_v1.30.bin
_tfanonc=851d6dcb793ef83f625f51fb5fecee93f86f3149
_bl31non=rk3399_bl31_v1.36.elf
_bl31nonc=1d47b8d9369522dfc2c5af420b6e41a9993ddd78
pkgdesc="U-Boot for Pine64 PinePhone Pro"
url='https://source.denx.de/u-boot/u-boot'
[[ $_nonfoss == yes ]] && license=('GPL' 'Custom')
[[ $_nonfoss != yes ]] && license=('GPL')
makedepends=('git' 'arm-none-eabi-gcc' 'dtc' 'bc' 'swig' 'python-setuptools' 'python-pyelftools')
provides=('uboot')
conflicts=('uboot')
install=${pkgname}.install
source=("git+https://xff.cz/git/u-boot#commit=$_commit"
"arm-trusted-firmware-${_tfaver}.tar.gz::https://github.com/ARM-software/arm-trusted-firmware/archive/refs/tags/${_tfaver}.tar.gz"
"https://github.com/rockchip-linux/rkbin/raw/$_bl31nonc/bin/rk33/$_bl31non"
"https://github.com/rockchip-linux/rkbin/raw/$_tfanonc/bin/rk33/$_tfanon"
"LICENSE.TXT"
"boot.txt"
"ppp-uboot-flash"
"ppp-uboot-mkscr"
"ppp-prepare-fstab"
"ppp-prepare-fstab.service")
'9887ca101cfa2d4efe2af9d2671aa64b9ba82a7f28409e5854696a7778b35225'
'3be6cdf32462d7f676d109bb2a97af9a1f469f058674ef0a5cb20941af2923d5'
'aab3b04166c098c8ba1d9a734c509cdf75b47b64c37c49196c7242526ce32179'
'0b37e1522c36cf4579c45dfb138798c3cb5665fcf6302b95377179fbed38e35c'
'12311da7e1a8d7bf19ddf78568e58da0888b0ca89e937aecccae4d896d20b7e2'
'e4c7f9320432cada1af9a2cbf3143f296b0762812099dda3d03368a3277a16b4'
'4bdcf15b540feb4529cbcac0e72dce444049bb33dff8dcd94e06d4f6aa477684'
'de7e36cdc7ed2fb5abb9155c97f87926361aa5be87d794c9016776160f3430ec'
'e55fb02dfb6213eabbb899b468dc5f68d36a11c05feda4c14e80282415222fea')
apply_patches() {
local PATCH
for PATCH in "${source[@]}"; do
PATCH="${PATCH%%::*}"
PATCH="${PATCH##*/}"
[[ ${PATCH} = $1*.patch ]] || continue
msg2 "Applying patch: ${PATCH}..."
# NOTE: Patch "1012-Configure-USB-power-settings-for-PinePhone-Pro.patch"
# is disabled temporarily because it's currently not in usable state,
# but it will be reworked later
apply_patches 1
# Patches from the U-Boot repository or mailing list
apply_patches 2
# Temporary patches that will be folded into the first patch group later,
# together with updating the device tree for the PinePhone Pro
# TODO: While folding, also remove the now unused "pmugrf" variable in
# board/pine64/pinephone-pro-rk3399/pinephone-pro-rk3399.c
apply_patches 3
# Avoid build warnings by editing a .config option in place instead of
# appending an option to .config, if an option is already present
update_config() {
if ! grep -q "^$1=$2$" .config; then
if grep -q "^# $1 is not set$" .config; then
sed -i -e "s/^# $1 is not set$/$1=$2/g" .config
elif grep -q "^$1=" .config; then
sed -i -e "s/^$1=.*/$1=$2/g" .config
else
echo "$1=$2" >> .config
fi
fi
}
cd arm-trusted-firmware-${_tfaver}
echo -e "\nBuilding FOSS TF-A for Pine64 PinePhone Pro...\n"
make PLAT=rk3399
export BL31=../arm-trusted-firmware-${_tfaver}/build/rk3399/release/bl31/bl31.elf
echo -e "\nusing Binary TF-A for Pine64 PinePhone Pro...\n"
export BL31=../rk3399_bl31_v1.35.elf
export ROCKCHIP_TPL=../rk3399_ddr_933MHz_v1.30.bin
echo -e "\nBuilding U-Boot for Pine64 PinePhone Pro...\n"
update_config 'CONFIG_IDENT_STRING' '" Manjaro Linux ARM"'
update_config 'CONFIG_BOOTDELAY' '0'
# Some DDR4 RAMs need training at 400 MHz to successfully boot
update_config 'CONFIG_RAM_RK3399_LPDDR4' 'y'
# Try a couple of SPI tweaks; if actually needed, these options
# will be propely moved to a PinePhone Pro configuration patch later
update_config 'CONFIG_SPL_DM_SEQ_ALIAS' 'y'
update_config 'CONFIG_SF_DEFAULT_BUS' '1'
# Disable DMA for eMMC, to make suspend/resume work; this option
# will be propely moved to a PinePhone Pro configuration patch later
update_config 'CONFIG_SPL_MMC_SDHCI_SDMA' 'n'
[[ $_nonfoss != yes ]] && update_config 'CONFIG_ROCKCHIP_EXTERNAL_TPL' 'n'
update_config 'CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS' '2'
install -D -m 0644 idbloader.img u-boot.itb -t "${pkgdir}/boot"
install -D -m 0644 "${srcdir}/boot.txt" -t "${pkgdir}/boot"
install -D -m 0755 "${srcdir}/ppp-uboot-mkscr" -t "${pkgdir}/usr/bin"
install -D -m 0755 "${srcdir}/ppp-prepare-fstab" -t "${pkgdir}/usr/bin"
install -D -m 0644 "${srcdir}/ppp-prepare-fstab.service" -t "${pkgdir}/usr/lib/systemd/system"
install -D -m 0755 "${srcdir}/ppp-uboot-flash" -t "${pkgdir}/usr/bin"
[[ $_nonfoss == yes ]] && install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" \