All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Davis Jr <vince@underview.tech>
To: openembedded-core@lists.openembedded.org
Cc: Vincent Davis Jr <vince@underview.tech>
Subject: [OE-core][PATCH v3 2/8] bootimg_efi: support grub hybrid boot
Date: Fri,  5 Sep 2025 12:41:30 -0400	[thread overview]
Message-ID: <20250905164136.2896809-2-vince@underview.tech> (raw)
In-Reply-To: <20250905164136.2896809-1-vince@underview.tech>

If bootimg_biosplusefi wics plugin is
used check for loader-bios in sourceparam.

The grub config is copied by the bootimg_pcbios
wic's plugin. The reason is it's autogenerated
grub config is generic enough to support both
legacy boot and hybrid boot. Thus, no need
to update it.

If partition type marked as EFI System only
copy in UEFI application boot*.efi (core.img).

It appears the EFI directory resides after
initial population of the EFI System partition.
If bootimg_efi called again and the partiton
type not marked as EFI System remove any
unwanted files.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
---
 scripts/lib/wic/plugins/source/bootimg_efi.py | 28 +++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/plugins/source/bootimg_efi.py b/scripts/lib/wic/plugins/source/bootimg_efi.py
index cf16705a28..98be12160c 100644
--- a/scripts/lib/wic/plugins/source/bootimg_efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg_efi.py
@@ -223,7 +223,13 @@ class BootimgEFIPlugin(SourcePlugin):
         exec_cmd(install_cmd)
 
         try:
-            if source_params['loader'] == 'grub-efi':
+            # In grub hybrid boot case bootimg_pcbios generates/copies the grub.cfg
+            # that will be stored on same partitions as the grub modules.
+            if 'loader-bios' in source_params and \
+               source_params['loader-bios'] == 'grub' and \
+               source_params['loader'] == 'grub-efi':
+                pass
+            elif source_params['loader'] == 'grub-efi':
                 cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params)
             elif source_params['loader'] == 'systemd-boot':
                 cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params)
@@ -328,7 +334,25 @@ class BootimgEFIPlugin(SourcePlugin):
                 logger.debug("Installed IMAGE_EFI_BOOT_FILES:\n%s" % out)
 
         try:
-            if source_params['loader'] == 'grub-efi':
+            if 'loader-bios' in source_params and \
+               source_params['loader-bios'] == 'grub' and \
+               source_params['loader'] == 'grub-efi':
+
+                # If partition type is Bios Boot return
+                if part.part_type == '21686148-6449-6E6F-744E-656564454649':
+                       return 0
+
+                # The grub config in the hybrid grub boot setup is
+                # copied by the bootimg_pcbios wics plugin.
+                if part.part_type == 'C12A7328-F81F-11D2-BA4B-00A0C93EC93B':
+                    for mod in [x for x in os.listdir(kernel_dir) if x.startswith("grub-efi-")]:
+                        cp_cmd = "cp -v -p %s/%s %s/EFI/BOOT/%s" % \
+                            (kernel_dir, mod, hdddir, mod[9:])
+                        exec_cmd(cp_cmd, True)
+                else:
+                    shutil.rmtree("%s/EFI" % hdddir)
+                    return 0
+            elif source_params['loader'] == 'grub-efi':
                 shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
                                 "%s/grub.cfg" % cr_workdir)
                 for mod in [x for x in os.listdir(kernel_dir) if x.startswith("grub-efi-")]:
-- 
2.43.0



  reply	other threads:[~2025-09-05 16:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05 16:41 [OE-core][PATCH v3 1/8] bootimg_pcbios: support grub hybrid boot Vincent Davis Jr
2025-09-05 16:41 ` Vincent Davis Jr [this message]
2025-09-05 16:41 ` [OE-core][PATCH v3 3/8] bootimg_efi: copy grub modules Vincent Davis Jr
2025-09-05 16:41 ` [OE-core][PATCH v3 4/8] bootimg_pcbios: update default boot timeout to zero Vincent Davis Jr
2025-09-05 16:41 ` [OE-core][PATCH v3 5/8] bootimg_biosplusefi: add grub only examples Vincent Davis Jr
2025-09-05 16:41 ` [OE-core][PATCH v3 6/8] grub-efi: support custom embedded grub configs Vincent Davis Jr
2025-09-05 16:41 ` [OE-core][PATCH v3 7/8] oe-selftest[wic]: add test_grub_install_biosplusefi Vincent Davis Jr
2025-09-05 16:41 ` [OE-core][PATCH v3 8/8] oe-selftest[wic]: add test_grub_install_biosplusefi_qemu Vincent Davis Jr
2025-09-07 14:02 ` [OE-core][PATCH v3 1/8] bootimg_pcbios: support grub hybrid boot Mathieu Dubois-Briand
2025-09-07 15:47   ` Vincent Davis
2025-09-08 12:25     ` Mathieu Dubois-Briand
2025-09-13  4:29       ` [PATCH " Vincent Davis Jr
2025-09-15 12:17         ` [OE-core] " Mathieu Dubois-Briand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250905164136.2896809-2-vince@underview.tech \
    --to=vince@underview.tech \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.