aboutsummaryrefslogtreecommitdiffstats
path: root/sys-boot/u-boot/u-boot-2022.06.ebuild
diff options
context:
space:
mode:
Diffstat (limited to 'sys-boot/u-boot/u-boot-2022.06.ebuild')
-rw-r--r--sys-boot/u-boot/u-boot-2022.06.ebuild89
1 files changed, 89 insertions, 0 deletions
diff --git a/sys-boot/u-boot/u-boot-2022.06.ebuild b/sys-boot/u-boot/u-boot-2022.06.ebuild
new file mode 100644
index 0000000..5a5942a
--- /dev/null
+++ b/sys-boot/u-boot/u-boot-2022.06.ebuild
@@ -0,0 +1,89 @@
+# Copyright 2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+META_SIFIVE="2022.06"
+UBOOT_COMMIT="e4b6ebd3de982ae7185dbf689a030e73fd06e0d2"
+
+DESCRIPTION="U-Boot with meta-sifive-${META_SIFIVE} patches"
+HOMEPAGE="https://source.denx.de/u-boot/u-boot"
+SRC_URI="https://source.denx.de/u-boot/u-boot/-/archive/${UBOOT_COMMIT}/u-boot-${UBOOT_COMMIT}.tar.gz -> ${P}.tar.gz
+ https://github.com/sifive/meta-sifive/archive/refs/heads/${META_SIFIVE}.zip -> meta-sifive-${META_SIFIVE}.zip"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~riscv"
+
+DEPEND="sys-boot/opensbi sys-apps/dtc dev-lang/swig"
+RDEPEND="${DEPEND}"
+BDEPEND=""
+
+IUSE="-1000 -1100 +1200 -1300 -1400 -1500 -1600 -1700 efi-priority"
+REQUIRED_USE="^^ ( 1000 1100 1200 1300 1400 1500 1600 1700 )"
+
+src_unpack() {
+ unpack ${P}.tar.gz
+ unpack meta-sifive-${META_SIFIVE}.zip
+ mv "${WORKDIR}/u-boot-${UBOOT_COMMIT}" "${WORKDIR}/${P}"
+}
+
+src_prepare() {
+ eapply "${WORKDIR}/meta-sifive-${META_SIFIVE}/recipes-bsp/u-boot/files/riscv64"
+
+ # A default, just to be sure
+ CONFIG_SPEED=1200000000
+
+ # Check use flags
+ use 1000 && CONFIG_SPEED=1000000000
+ use 1100 && CONFIG_SPEED=1100000000
+ use 1200 && CONFIG_SPEED=1200000000
+ use 1300 && CONFIG_SPEED=1300000000
+ use 1400 && CONFIG_SPEED=1400000000
+ use 1500 && CONFIG_SPEED=1500000000
+ use 1600 && CONFIG_SPEED=1600000000
+ use 1700 && CONFIG_SPEED=1700000000
+
+ # Actually modify the dtsi file
+ sed -i -E -e "/cpus/,/cpu0/ s/assigned-clock-rates = <[0-9]+>/assigned-clock-rates = <${CONFIG_SPEED}>/" "${WORKDIR}/${P}/arch/riscv/dts/fu740-c000-u-boot.dtsi"
+ elog "Set CPU frquency to $((CONFIG_SPEED/1000000)) Mhz"
+
+ if use efi-priority; then
+ eapply "${FILESDIR}/efi-priority.patch"
+ fi
+
+ eapply_user
+}
+
+src_configure()
+{
+ # Apply Unmatched defconfig
+ emake sifive_unmatched_defconfig
+}
+
+src_compile() {
+ # Find opensbi
+ export OPENSBI=`find /usr/share/opensbi-* -name fw_dynamic.bin | sort | tail -n 1`
+ if [ -z "$OPENSBI" ]; then
+ die "Can't find OpenSBI, is sys-boot/opensbi installed?"
+ fi
+ elog "Using OpenSBI at ${OPENSBI}"
+
+ # Start the build
+ emake
+}
+
+src_install() {
+ mkdir -p "${D}/usr/share/${P}"
+ cp "${WORKDIR}/${P}/u-boot.itb" "${D}/usr/share/${P}"
+ cp "${WORKDIR}/${P}/spl/u-boot-spl.bin" "${D}/usr/share/${P}"
+}
+
+pkg_postinst()
+{
+ einfo "U-Boot files have been installed in /usr/share/${P}. In order"
+ einfo "to boot with this U-Boot you need to install it to the correct partitions"
+ einfo "with dd. For example:"
+ einfo "dd if=/usr/share/${P}/u-boot-spl.bin of=<partition with type \"HiFive Unleashed FSBL\">"
+ einfo "dd if=/usr/share/${P}/u-boot.itb of=<partition with type \"HiFive Unleashed BBL\">"
+}