blob: 46dd0010a45f01d18b6b3bc68f6115ece3b896b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
META_SIFIVE="2024.03"
UBOOT_COMMIT="866ca972d6c3cabeaf6dbac431e8e08bb30b3c8e"
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\">"
}
|