From b6795c93ead221ce723238d8bcc94cb6621c8867 Mon Sep 17 00:00:00 2001 From: Ricardo Salveti Date: Mon, 17 Dec 2018 16:17:51 -0200 Subject: [PATCH] grub2: add support for devicetree Similar as available for u-boot (ce2995e1dc1557c4d97ef5af807eacf3ef4a22d8) and syslinux (c5112c25e4519835c4cd53f4350c1b2f2a477746), enable parsing and writing devicetree filename into grub.cfg. This is required by arm64-based devices running edk2 instead of u-boot as the main bootloader (e.g. 96boards HiKey and HiKey960). Signed-off-by: Ricardo Salveti Closes: #1790 Approved by: cgwalters --- src/boot/grub2/ostree-grub-generator | 7 +++++++ src/libostree/ostree-bootloader-grub2.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/boot/grub2/ostree-grub-generator b/src/boot/grub2/ostree-grub-generator index 2208c1bf..10645c74 100644 --- a/src/boot/grub2/ostree-grub-generator +++ b/src/boot/grub2/ostree-grub-generator @@ -33,6 +33,7 @@ read_config() initrd="" options="" linux="" + devicetree="" while read -r line do @@ -48,6 +49,9 @@ read_config() "linux") linux=${value} ;; + "devicetree") + devicetree=${value} + ;; "options") options=${value} ;; @@ -74,6 +78,9 @@ populate_menu() if [ -n "${initrd}" ] ; then menu="${menu}\t initrd ${boot_prefix}${initrd}\n" fi + if [ -n "${devicetree}" ] ; then + menu="${menu}\t devicetree ${boot_prefix}${devicetree}\n" + fi menu="${menu}}\n\n" done # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c index 6831382c..57673c7d 100644 --- a/src/libostree/ostree-bootloader-grub2.c +++ b/src/libostree/ostree-bootloader-grub2.c @@ -191,6 +191,7 @@ _ostree_bootloader_grub2_generate_config (OstreeSysroot *sysroot const char *options; const char *kernel; const char *initrd; + const char *devicetree; char *quoted_title = NULL; char *uuid = NULL; char *quoted_uuid = NULL; @@ -246,6 +247,15 @@ _ostree_bootloader_grub2_generate_config (OstreeSysroot *sysroot g_string_append_c (output, '\n'); } + devicetree = ostree_bootconfig_parser_get (config, "devicetree"); + if (devicetree) + { + g_string_append (output, "devicetree"); + g_string_append_c (output, ' '); + g_string_append (output, devicetree); + g_string_append_c (output, '\n'); + } + g_string_append (output, "}\n"); }