2022-01-17 23:23:51 +01:00
# Copyright 1999-2022 Gentoo Authors
2021-12-11 19:14:30 +01:00
# Distributed under the terms of the GNU General Public License v2
EAPI = 8
inherit toolchain-funcs
PKGREL = "4"
2022-07-09 19:38:06 +02:00
FIRMWAREVERSION = "2.7.0"
2022-07-14 17:06:14 +02:00
COMMMIT = "e092e3250270a1016c877da7bdd9384f14b1321e"
2021-12-11 19:14:30 +01:00
MY_P = " u-boot- ${ COMMMIT } "
DESCRIPTION = "Das U-boot and utilities for working with Das U-Boot for the PinePhone Pro"
HOMEPAGE = "https://www.denx.de/wiki/U-Boot/WebHome"
SRC_URI = "
https://source.denx.de/u-boot/u-boot/-/archive/${ COMMMIT } /u-boot-${ COMMMIT } .tar.gz -> u-boot-${ PV } .tar.gz
https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/snapshot/trusted-firmware-a-${ FIRMWAREVERSION } .tar.gz
"
S = " ${ WORKDIR } / ${ MY_P } "
LICENSE = "GPL-2"
SLOT = "0"
KEYWORDS = "~arm64"
RDEPEND = "dev-libs/openssl:="
DEPEND = " ${ RDEPEND } "
BDEPEND = "
sys-apps/dtc
sys-devel/bison
sys-devel/flex
virtual/pkgconfig
2022-07-11 18:24:22 +02:00
sys-devel/crossdev
2022-07-14 22:09:12 +02:00
dev-embedded/u-boot-tools
2021-12-11 19:14:30 +01:00
"
src_prepare( ) {
default
2022-07-11 18:28:50 +02:00
2021-12-11 19:14:30 +01:00
sed -i 's:\bpkg-config\b:${PKG_CONFIG}:g' \
scripts/kconfig/{ g,m,n,q} conf-cfg.sh \
scripts/kconfig/Makefile \
tools/Makefile || die
2022-07-11 15:09:59 +02:00
#Apply PinePhone Pro patches
eapply " ${ FILESDIR } " /1001-Correct-boot-order-to-be-USB-SD-eMMC.patch
eapply " ${ FILESDIR } " /1002-rockchip-Add-initial-support-for-the-PinePhone-Pro.patch
2022-07-11 15:14:57 +02:00
#eapply "${FILESDIR}"/1003-Configure-USB-power-settings-for-PinePhone-Pro.patch
2022-07-11 15:09:59 +02:00
eapply " ${ FILESDIR } " /1004-mtd-spi-nor-ids-Add-GigaDevice-GD25LQ128E-entry.patch
eapply " ${ FILESDIR } " /1005-Reconfigure-GPIO4_D3-as-input-on-PinePhone-Pro.patch
eapply " ${ FILESDIR } " /2001-mmc-sdhci-allow-disabling-sdma-in-spl.patch
eapply " ${ FILESDIR } " /3001-pinephone-pro-Remove-cargo-culted-iodomain-config.patch
eapply " ${ FILESDIR } " /3002-pine64-pinephonePro-SPI-support.patch
2022-01-17 23:23:51 +01:00
}
2021-12-11 19:14:30 +01:00
src_configure( ) {
tc-export AR BUILD_CC CC PKG_CONFIG
}
src_compile( ) {
2022-07-14 17:06:14 +02:00
unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
2021-12-11 19:14:30 +01:00
cd ${ WORKDIR } /trusted-firmware-a-${ FIRMWAREVERSION }
2022-07-11 15:29:31 +02:00
emake " ${ myemakeargs [@] } " PLAT = rk3399
2021-12-11 19:14:30 +01:00
cp build/rk3399/release/bl31/bl31.elf ${ S }
2022-07-11 15:09:59 +02:00
cd ${ S }
2021-12-11 19:14:30 +01:00
# Unset a few KBUILD variables. Bug #540476
unset KBUILD_OUTPUT KBUILD_SRC
emake " ${ myemakeargs [@] } " pinephone-pro-rk3399_defconfig
2022-07-14 17:28:41 +02:00
local myemakeargs = (
V = 1
AR = " ${ AR } "
CC = " ${ CC } "
HOSTCC = " ${ BUILD_CC } "
HOSTCFLAGS = " ${ BUILD_CFLAGS } ${ BUILD_CPPFLAGS } " ' $(HOSTCPPFLAGS)'
HOSTLDFLAGS = " ${ BUILD_LDFLAGS } "
)
2022-07-11 15:24:44 +02:00
echo "CONFIG_IDENT_STRING=' Gentoo Linux'" >> .config
echo "CONFIG_BOOTDELAY'='0'" >> .config
echo "CONFIG_SPL_DM_SEQ_ALIAS='y'" >> .config
echo "CONFIG_SF_DEFAULT_BUS='1'" >> .config
echo "CONFIG_SPL_MMC_SDHCI_SDMA'='n'" >> .config
2022-01-17 23:23:51 +01:00
2022-07-14 17:31:12 +02:00
emake " ${ myemakeargs [@] } " EXTRAVERSION = -${ PKGREL }
}
2021-12-11 19:14:30 +01:00
src_test( ) { :; }
src_install( ) {
insinto /boot/
doins ${ S } /u-boot.itb
2022-07-14 17:28:41 +02:00
doins ${ S } /idbloader.img
2022-07-14 22:09:12 +02:00
doins ${ FILESDIR } /boot.txt
dobin ${ FILESDIR } /ppp-uboot-mkscr
2021-12-11 19:14:30 +01:00
}
pkg_postinst( ) {
2022-07-11 18:28:50 +02:00
einfo "In order to get the U-Boot to work you will need a crosscompiler for arm-none-eabi you can do this by running: crossdev --target arm-none-eabi (if not done allready) and then re-emerge this packages"
2021-12-11 19:14:30 +01:00
einfo "This U-Boot is only to be used for the PinePhone Pro."
2022-07-14 22:09:12 +02:00
einfo "Edit the /boot/boot.txt file with your uuid's and then run ppp-uboot-mkscr"
2022-01-01 18:04:48 +01:00
einfo "After compiling a new Gentoo kernel, copy the resulting Image from /usr/src/linux/arch/arm64/boot/Image to the boot partition (replacing the existing Image)."
2022-01-25 09:09:41 +01:00
einfo "New version of U-Boot firmware can be flashed to your microSD card or eMMc module."
2022-02-01 15:38:12 +01:00
einfo "You can do that by running:"
2022-01-01 18:04:48 +01:00
einfo "# dd if=/boot/idbloader.img of=/dev/mmcblkX seek=64 conv=notrunc,fsync"
einfo "# dd if=/boot/u-boot.itb of=/dev/mmcblkX seek=16384 conv=notrunc,fsync"
2022-02-01 15:38:12 +01:00
einfo "Due to the Boot Priority for the PPP it is HIGHLY recommended to not put U-Boot on the eMMc because there is no easy way to recover is something went wrong."
2021-12-11 19:14:30 +01:00
}