templates: allow loading a Device Tree file from user conf
PATCH 1/1 templates: allow loading a Device Tree file from user conf
From: Matteo Croce <[email protected]>
Some machines rely on Device Tree for hardware discovery, so a .dtb file must be passed to the kernel.
GRUB can do this via the devicetree command, but it's not possible to do this from the user configuration.
Add a GRUB_DEVICETREE_FILE variable which holds the path of the .dtb file relative to the boot partition and, if present, adds the devicetree command to the menuentry.
--- util/grub-mkconfig.in | 1 + util/grub.d/10_linux.in | 5 +++++ 2 files changed, 6 insertions(+)
util/grub-mkconfig.in +1 -0
@@ -228,6 +228,7 @@ export GRUB_DEFAULT \ GRUB_CMDLINE_NETBSD \ GRUB_CMDLINE_NETBSD_DEFAULT \ GRUB_CMDLINE_GNUMACH \ + GRUB_DEVICETREE_FILE \ GRUB_EARLY_INITRD_LINUX_CUSTOM \ GRUB_EARLY_INITRD_LINUX_STOCK \ GRUB_TERMINAL_INPUT \
util/grub.d/10_linux.in +5 -0
@@ -143,6 +143,11 @@ linux_entry () echo '$(echo "$message" | grub_quote)' linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} EOF + if [ -n "${GRUB_DEVICETREE_FILE}" ] && test -e "${dirname}/${GRUB_DEVICETREE_FILE}"; then + sed "s/^/$submenu_indentation/" << EOF + devicetree ${rel_dirname}/${GRUB_DEVICETREE_FILE} +EOF + fi if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")"
Signature · 1 line
2.28.0
Quoted 48 lines · Matteo Croce
From: Matteo Croce <[email protected]>
Some machines rely on Device Tree for hardware discovery, so a .dtb file must be passed to the kernel.
GRUB can do this via the
devicetreecommand, but it's not possible to do this from the user configuration.Add a
GRUB_DEVICETREE_FILEvariable which holds the path of the .dtb file relative to the boot partition and, if present, adds the devicetree command to the menuentry.Signed-off-by Matteo Croce <[email protected]>--- util/grub-mkconfig.in | 1 + util/grub.d/10_linux.in | 5 +++++ 2 files changed, 6 insertions(+)util/grub-mkconfig.in +1
-0@@ -228,6 +228,7 @@ export GRUB_DEFAULT \ GRUB_CMDLINE_NETBSD \ GRUB_CMDLINE_NETBSD_DEFAULT \ GRUB_CMDLINE_GNUMACH \ + GRUB_DEVICETREE_FILE \ GRUB_EARLY_INITRD_LINUX_CUSTOM \ GRUB_EARLY_INITRD_LINUX_STOCK \ GRUB_TERMINAL_INPUT \util/grub.d/10_linux.in +5
-1@@ -143,6 +143,11 @@ linux_entry () echo '$(echo "$message" | grub_quote)' linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} EOF + if [ -n "${GRUB_DEVICETREE_FILE}" ] && test -e "${dirname}/${GRUB_DEVICETREE_FILE}"; then + sed "s/^/$submenu_indentation/" << EOF + devicetree ${rel_dirname}/${GRUB_DEVICETREE_FILE} +EOF + fi if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" --
Quoted 2 lines
2.28.0
Hi,
any update on this?
Regards,
Signature · 1 line
per aspera ad upstream
Hi,
I have proposed a more generic patch to handle devicetree stanaza before see https://lists.gnu.org/archive/html/grub-devel/2019-05/msg00121.html
Fedora separately ships a similarish patch as well
I have no idea why many distributions ship integration to generate devicetree commands in grub.cfg and yet such patch is not yet in upstream grub.
I recommend you to look at Ubuntu or Fedora patches to handle devicetree command generation.
Quoted 55 lines · Matteo Croce
From: Matteo Croce <[email protected]>
Some machines rely on Device Tree for hardware discovery, so a .dtb file must be passed to the kernel.
GRUB can do this via the
devicetreecommand, but it's not possible to do this from the user configuration.Add a
GRUB_DEVICETREE_FILEvariable which holds the path of the .dtb file relative to the boot partition and, if present, adds the devicetree command to the menuentry.Signed-off-by Matteo Croce <[email protected]>--- util/grub-mkconfig.in | 1 + util/grub.d/10_linux.in | 5 +++++ 2 files changed, 6 insertions(+)util/grub-mkconfig.in +1
-0@@ -228,6 +228,7 @@ export GRUB_DEFAULT \ GRUB_CMDLINE_NETBSD \ GRUB_CMDLINE_NETBSD_DEFAULT \ GRUB_CMDLINE_GNUMACH \ + GRUB_DEVICETREE_FILE \ GRUB_EARLY_INITRD_LINUX_CUSTOM \ GRUB_EARLY_INITRD_LINUX_STOCK \ GRUB_TERMINAL_INPUT \util/grub.d/10_linux.in +5
-1@@ -143,6 +143,11 @@ linux_entry () echo '$(echo "$message" | grub_quote)' linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} EOF + if [ -n "${GRUB_DEVICETREE_FILE}" ] && test -e "${dirname}/${GRUB_DEVICETREE_FILE}"; then + sed "s/^/$submenu_indentation/" << EOF + devicetree ${rel_dirname}/${GRUB_DEVICETREE_FILE} +EOF + fi if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" --2.28.0
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 3 lines
Regards, Dimitri.