grub: support loading devicetrees

This commit is contained in:
classabbyamp 2024-05-05 10:06:58 -04:00 committed by classabbyamp
parent 7ce98f1c52
commit 8d1eb24d50
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,50 @@
support loading a devicetree based on GRUB_DEFAULT_DTB in /etc/default/grub
looks in /boot/dtbs/dtbs-${version}/${GRUB_DEFAULT_DTB}
based on https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/0022-Add-devicetree-loading.patch
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -255,7 +255,8 @@
GRUB_ENABLE_CRYPTODISK \
GRUB_BADRAM \
GRUB_OS_PROBER_SKIP_LIST \
- GRUB_DISABLE_SUBMENU
+ GRUB_DISABLE_SUBMENU \
+ GRUB_DEFAULT_DTB
if test "x${grub_cfg}" != "x"; then
rm -f "${grub_cfg}.new"
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -129,6 +129,14 @@
echo " insmod gzio" | sed "s/^/$submenu_indentation/"
+ if test -n "${dtb}" ; then
+ message="$(gettext_printf "Loading devicetree ...")"
+ sed "s/^/$submenu_indentation/" << EOF
+ echo '$(echo "$message" | grub_quote)'
+ devicetree ${rel_dirname}/${dtb}
+EOF
+ fi
+
if [ x$dirname = x/ ]; then
if [ -z "${prepare_root_cache}" ]; then
prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)"
@@ -250,6 +258,14 @@
gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
fi
+ dtb=
+ for i in "dtbs-${version}" "dtbs-${alt_version}"; do
+ if test -f "${dirname}/dtbs/${i}/${GRUB_DEFAULT_DTB}" ; then
+ dtb="dtbs/${i}/${GRUB_DEFAULT_DTB}"
+ break
+ fi
+ done
+
config=
for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
if test -e "${i}" ; then

View File

@ -1,7 +1,7 @@
# Template file for 'grub'
pkgname=grub
version=2.12
revision=1
revision=2
hostmakedepends="python3 pkg-config flex freetype-devel font-unifont-bdf help2man
automake gettext-devel-tools"
makedepends="libusb-compat-devel ncurses-devel freetype-devel liblzma-devel