From patchwork Tue Sep 2 01:58:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Davis Jr X-Patchwork-Id: 69362 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55474CA1007 for ; Tue, 2 Sep 2025 01:58:34 +0000 (UTC) Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by mx.groups.io with SMTP id smtpd.web10.68011.1756778312942056368 for ; Mon, 01 Sep 2025 18:58:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=DQ9R3d8B; spf=pass (domain: underview.tech, ip: 209.85.219.43, mailfrom: vince@underview.tech) Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-71a2d730d03so11389066d6.3 for ; Mon, 01 Sep 2025 18:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1756778311; x=1757383111; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=erDmI44TaPwCg8OY7OyOsBj1dsMGf9ZjmAhlCNcV5/s=; b=DQ9R3d8BTGeVQy8TxIYP+XWKnqNcZTQcrOxat2wQF6GXq120e/PPJoa7l4q2ZJMGpp Me292umbnBqk/9OnHG0ZohilwUtvdx2grjEUlHW6TqTYoReL+70Dp0B0IttujEBO1Ycs 9N/Vm1yjZDIadbAOdvN9hjnRD2uouUSVqf+PT7qoXl7bHTVhYLJuf02yLLMaz2KF/+a0 cWCGq2V+4lzsX3CJKr/bvxsFI14Pj174Lt67aW5xcJMM3akcSt25liGs/vCidopwWeVt AAATGLgCqQ6CRb9YTmouUiqmD9QiEpe7Hlx6wV/oUo3bXg41GUhUWgJZX+uTGx3UlV1n lQHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756778311; x=1757383111; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=erDmI44TaPwCg8OY7OyOsBj1dsMGf9ZjmAhlCNcV5/s=; b=faY+Tp2G8gSasWIwUgs3wpBzfYcOOaxefbALxNVlJaEzVRI/qmlG05+GnNEkBf6vEu 4Nykw02OJFlrenSTU/W6wPjW7W+HEgR4bQkyvLgv2RbxBOFfwVJmP1qSKS8vcSbHcPXE si3auWqfWHD2Cz/EaELKbyK8wxS2dNxkk6jBgc39omUHDqm9qcT4dQByzaJyf+RVKNbr gVUFTe2rJGJF0n+CnsCLB0kLWOGEuZeZH0qRGcYhJrS0lVCTZET587Kt58KJhVaQbYVm j/3rDl6iiz5a3YuYgHcLNA+n2BhR6fioP0Q+RGk21VCDBgx8Xl7aURJWPoeq1p+fs6ze 6adg== X-Gm-Message-State: AOJu0Yzxkv+OFmFY9NnG6RNBAHZqcDnxYC0dNmILTHKGf06Wi9jdIVae Qk5gi3IlWcoMQVWUsuZAillYoWWPx9o0+6DbHhb3YI1B9L9Px+EU/tXANwxrJA9Ix4MJe6HV1hU oXHjbOyc= X-Gm-Gg: ASbGncsxPAURFSBsDszSnfQP1F0JWqTt0iOXQxxh6Ol2yOTzRZLJaDmusYvekeBKeSe CstprppmLF+l+9eUtb+52N/M90EN77AqT3SDy7DDvQ3CCn1gexCeVh/UdKqE98MZNPuAhNWu9Yt OieCvsnILgyWoimcJxFbYeR0df8fg3ybEjyHLskiPPtqGo1VB8gIyaqkJpj/8tJ+tZsGAYWOr8f uwo3VS2q5crbn/aO3J3pYXfUls4dmLl4h/Ev4F3DyBSyKhPfo45A3TZuubDYxGO9I362oY9Vfm2 hAWpHSQXc2i9sgUvsWSAkO9SLphT/QEwa7wMnYtZcQJzCn3ItXCz29HJlzyoLJ84JHPQMCtSbLi OTkoDymwEhuc= X-Google-Smtp-Source: AGHT+IGmcwoS55qKkUt+jnmafPgR3vo+0c/xcrOTtSM+/IOnANUIZpJiH6BlL4Ax4uTaQwuqy36TzA== X-Received: by 2002:ad4:5a07:0:b0:70f:b283:77e8 with SMTP id 6a1803df08f44-70fb2837f6dmr65574406d6.3.1756778311464; Mon, 01 Sep 2025 18:58:31 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::7efe]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-720a30b79aesm4284666d6.0.2025.09.01.18.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 18:58:31 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH 1/7] bootimg_pcbios: support grub hybrid boot Date: Mon, 1 Sep 2025 21:58:19 -0400 Message-ID: <20250902015825.2785789-1-vince@underview.tech> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 02 Sep 2025 01:58:34 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/222683 If caller wants to primarily leverage grub as the primary boot loader current oe-core doesn't support booting grub when the boot firmware is legacy BIOS based and the partition table format is GPT based. Issue GPT header reside where core.img should be located (at byte 512). To navigate around issue core.img was moved to a seperate partition. If disk is a GPT disk caller must specify the file system type as none and set the partition type as BIOS boot. No filesystem will be created on partition. This also allows wic plugin to know where to dd core.img. Unfortunately No deep dive into grub-install was perform to know the exact bytes changed in hybrid boot case. To see the change in bytes generated boot.img + core.img was compared to boot.img + core.img after grub-install was executed using the xxd command. Signed-off-by: Vincent Davis Jr --- .../lib/wic/plugins/source/bootimg_pcbios.py | 55 ++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index caabda6318..a7fb2eca4e 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -101,7 +101,7 @@ class BootimgPcbiosPlugin(SourcePlugin): disk_name, full_path, disk.min_size) if cls.loader == 'grub': - cls._do_install_grub(creator, kernel_dir, + cls._do_install_grub(disk, creator, kernel_dir, native_sysroot, full_path) elif cls.loader == 'syslinux': cls._do_install_syslinux(creator, bootimg_dir, @@ -340,6 +340,12 @@ class BootimgPcbiosPlugin(SourcePlugin): @classmethod def _do_configure_grub(cls, part, creator, cr_workdir): + # If partition type is either EFI System or + # BIOS boot no need to generate/copy grub config. + if part.part_type == '21686148-6449-6E6F-744E-656564454649' or \ + part.part_type == 'C12A7328-F81F-11D2-BA4B-00A0C93EC93B': + return 0 + hdddir = "%s/hdd" % cr_workdir bootloader = creator.ks.bootloader @@ -438,6 +444,12 @@ class BootimgPcbiosPlugin(SourcePlugin): grub_mods_path, core_img, builtin_modules) exec_native_cmd(grub_mkimage, native_sysroot) + # If partition type is either EFI System or + # BIOS boot no need to copy in grub modules. + if part.part_type == '21686148-6449-6E6F-744E-656564454649' or \ + part.part_type == 'C12A7328-F81F-11D2-BA4B-00A0C93EC93B': + return 0 + # Copy grub modules install_dir = '%s/%s/%s' % (hdddir, grub_prefix_path, grub_format) os.makedirs(install_dir, exist_ok=True) @@ -454,7 +466,7 @@ class BootimgPcbiosPlugin(SourcePlugin): native_sysroot, False) @classmethod - def _do_install_grub(cls, creator, kernel_dir, + def _do_install_grub(cls, disk, creator, kernel_dir, native_sysroot, full_path): core_img = '%s/grub-bios-core.img' % (kernel_dir) @@ -478,6 +490,45 @@ class BootimgPcbiosPlugin(SourcePlugin): # Install core.img or grub stage 1.5 dd_cmd = "dd if=%s of=%s conv=notrunc bs=1 seek=512" % (core_img, full_path) exec_cmd(dd_cmd, native_sysroot) + elif creator.ptable_format == 'gpt': + # Issue GPT headers reside where core.img should be (at byte 512). + # To navigate around issue core.img was moved to a seperate partition. + # + # If disk is a GPT disk caller must specify the file system + # type as none. As no filesystem may be created. Caller must + # also set the partition type to BIOS boot. So, the plugin + # may embed core.img there. + + # Replicates what grub-install does to boot.img + # Found by comparing xxd output of generated boot.img + # to boot.img after grub-install. + dd_cmd = "echo -ne '\\x00\\x08' | dd of=%s conv=notrunc bs=1 count=2 seek=92" % (full_path) + exec_native_cmd(dd_cmd, native_sysroot) + + dd_cmd = "echo -ne '\\x90\\x90' | dd of=%s conv=notrunc bs=1 count=2 seek=102" % (full_path) + exec_native_cmd(dd_cmd, native_sysroot) + + for part in creator.parts: + if part.part_type == '21686148-6449-6E6F-744E-656564454649': + part_start_byte = part.start * disk.sector_size + + # Install core.img or grub stage 1.5 + dd_cmd = "dd if=%s of=%s conv=notrunc bs=1 seek=%s" % \ + (core_img, full_path, part_start_byte) + exec_cmd(dd_cmd, native_sysroot) + + # Replicates what grub-install does to core.img + # Found by comparing xxd output of generated + # core.img to core.img ater grub install. + dd_cmd = "echo -ne '\\x01\\x08' | dd of=%s conv=notrunc bs=1 count=2 seek=%d" % \ + (full_path, part_start_byte + 500) + exec_native_cmd(dd_cmd, native_sysroot) + + dd_cmd = "echo -ne '\\x2f\\x02' | dd of=%s conv=notrunc bs=1 count=2 seek=%d" % \ + (full_path, part_start_byte + 508) + exec_native_cmd(dd_cmd, native_sysroot) + + break else: raise WicError("Unsupported partition table: %s" % creator.ptable_format) From patchwork Tue Sep 2 01:58:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Davis Jr X-Patchwork-Id: 69364 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E4FBCA1002 for ; Tue, 2 Sep 2025 01:58:44 +0000 (UTC) Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by mx.groups.io with SMTP id smtpd.web11.67782.1756778315921740057 for ; Mon, 01 Sep 2025 18:58:36 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=AGE+YUcG; spf=pass (domain: underview.tech, ip: 209.85.219.46, mailfrom: vince@underview.tech) Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-71a7108d992so10504146d6.3 for ; Mon, 01 Sep 2025 18:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1756778314; x=1757383114; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fgqK7w5ur3QXMrtpVRzJI/TyAhGTkklkIlH3sCinApo=; b=AGE+YUcGsk8ZAKc+Qs/4AhmgB0e37eYOPxdIdzeoHPb+pHvfEetVw/gVLjtzeSpZph A+PQ3UFcdt6vvmLDS4s6dpQXW8vrH64abMG5cjtVso8Zi6QoIth+uHZ0GBBX5g0D2vZS gt/3IbRipy7L/GdhmoFdKZQK/8vCQbiV4ijgRNFvqjSL8k1xpES/790VvQjZf1y/Orwy 4vqaHSGQj9QNriSkp+c/c5QQr8k2gzcv5ZFa7FNlP0FOW4Xx6U8r3XX7WbBg9axkEaXc LsT8Z+NCPwht96HCQsKjSmHIL9kWapy79qOIVyFA7/EczoAeeDv0ZCDPbQ6TfV7IXU1M e0Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756778314; x=1757383114; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fgqK7w5ur3QXMrtpVRzJI/TyAhGTkklkIlH3sCinApo=; b=eJPizughk/CMHCWix8bozlT0fa8EAdw/4qL3nZHLMdk+vVMh1AMwc8S3zvNSYfPRvU gZilxIiXce9WD4xbrbBPovBCATRA78/xwCGNR0emKevZJ274gRR+bZ4+kL/qc2LARmVl cONjXsb+3j1lqEV/rI9bDnfeyUyaXcvClqAhFRShIpfNqviYbpBaxPYyR7Dj+N28pDnQ I/Z8u7et8D5rYEEi2X9zUqhRXbC6l+FZZWIA+vQbanfE9kOy2Xgw3ONZ66R3XbY1oeO1 WHjIdiglneMVR3dwfUQPsjrD3FiNPAhwFrhdmyD7OJaAcNGL69ITXR/Q/l0wRBy18vuK J2Kw== X-Gm-Message-State: AOJu0Yxym2Z4iwkjDGVn43h+Rb+7RbY+H0uFQs5vzw8gw/SAxMMcktF5 yRMQMvE3RaQCKBHvDXWCXPATHdkSs/69FVFuZPp3p+tRZUvQFFSw398iNjhjuzfmDu40SbheyQS eltJkq0U= X-Gm-Gg: ASbGncswAsQEeKMwGwlLjrggbp85fv806RtUT1I94S9S4ZoA+VrAE2Da9w6tGXiwyzl shVXFSbbmwoSFdp5G8LlXnB9Uxr920yrG0qLDgVlDud2GUAQBK69XU7WJ6qcj1H/E26F4GXfsBb 0dNtOQReS5eX4PCK5wwTXwKR3sRG3yMhGTbrnFWOyvDfXrF3ifUraxpQIZkv8gx7BIgDH1eDHvK 5A0T7yg/pct4cbk5TCyNS7wowAYQS1Pl/vkHwHcHd4DffA2KNw57kCYdGKKG/qhdv1co3PYvOaK PrlckrTqIYW1dRZgStMGT7gKAJENDoEhuulp4mP3MbiRdszrxBvl3Ry72iZ9zZpaBdL86zJ4q7I zghjB8Pg0+EI= X-Google-Smtp-Source: AGHT+IF4ehGgBiS7u9HV0Td3YTY1ppP7w8bzQf2jMHBs6igqZyQg9Sg1+a+xw4GR4bx/82Xw86Jq0Q== X-Received: by 2002:ad4:5ae3:0:b0:720:4a66:d3df with SMTP id 6a1803df08f44-7204a66e19amr16240056d6.16.1756778314364; Mon, 01 Sep 2025 18:58:34 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::7efe]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-720a30b79aesm4284666d6.0.2025.09.01.18.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 18:58:34 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH 2/7] bootimg_efi: support grub hybrid boot Date: Mon, 1 Sep 2025 21:58:20 -0400 Message-ID: <20250902015825.2785789-2-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250902015825.2785789-1-vince@underview.tech> References: <20250902015825.2785789-1-vince@underview.tech> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 02 Sep 2025 01:58:44 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/222684 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 --- 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-")]: From patchwork Tue Sep 2 01:58:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Davis Jr X-Patchwork-Id: 69366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C230CA1009 for ; Tue, 2 Sep 2025 01:58:44 +0000 (UTC) Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by mx.groups.io with SMTP id smtpd.web10.68012.1756778318234973582 for ; Mon, 01 Sep 2025 18:58:38 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=Z1L4n4cK; spf=pass (domain: underview.tech, ip: 209.85.219.41, mailfrom: vince@underview.tech) Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-70fa0e941a9so29252366d6.0 for ; Mon, 01 Sep 2025 18:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1756778317; x=1757383117; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FXzuSotpMMnOjSPlL3MDTuoRfm/HOvDccvynxqGewg4=; b=Z1L4n4cKpD5TBdg/SmJ11CAn6TBXIvStyDhplhZdNi/49c1meURE/uX91sNpBJcQm/ HnjxzavoUkOfhhvReZhUmDcRwmkBMI32oZhVD/AyfE8Jh81Cy4wDq9zS80WkCsLhTncI RQIifdmPspLq4kbo8f8cTw0hB9mcSFydcFqsfyPFWqwr2umQn+mnvXN/dMdGU68fvCCa pp/6eTlxOU7B7cpxU4H3WVhZTrOhwD5Z/61ev+tfkyxU1QLOMJhJAQF3G2sfW6qLTue8 H4c1yEsmEo5PvyY5QuNyK8wVQoZmaeVA8EJnrFcniMvtF/XNMM9M7hOlbrpHzB2aPt6U IXvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756778317; x=1757383117; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FXzuSotpMMnOjSPlL3MDTuoRfm/HOvDccvynxqGewg4=; b=FSEdV2LN2wCsXyEkvAv356HjaWrsqIa5qVHb1chmL/p38pVgcZQ9Iu3VfUfFET8URd IUq5Ey9UY548/6W6xzF6rd9p5x4UmO8xhDBxOe+cY183ZMhFcdc7OrCLRFxyF6MSGsjy iSV9u1PJUomesJaRe019AukdZ3mMYR4ejWv9MhDJYPjN79th1cqjEabGJUqCkQ1Rlz02 XMDzx+xAw/6p6ILxXEvO+EG0sSv50THFxW4+LRdrkDJwxDSWms22/4bZ1oPIuLq4pyxV M/MRcH6o2GygVGn7orClCD0U09vbeFmux1mnTlI5Gnf3DjMd24q1eQxxYeVxAzV9U4JK mTgQ== X-Gm-Message-State: AOJu0YzNiANidzDGHGAMom5kY4lLI4GZZwyMaX9Mnggmkcoqe4mKYKP7 NsccoJmJGE+x6Up4fw6VeqH4YDxzMxZ9HAx87iM/ewmS7iOmCsFgDrm0PENk9dZl6mKDvk362/m Ig/949Vk= X-Gm-Gg: ASbGnctwFBfYPTeOpVxRwhzjfxvZWguMjRMlwOFdq4Tga+Ei5/wiD4qpHQSrLcda+6f yuT3yse3ijU0scuoSs3PEq7NZXNhXKQtiKJc6Mg08Xh074/FLhsUTo+FbRzX5ExxdXq6cCikaHh aepm1t+rS1sj6/Ag307dGSf/NbZrQ+3oFI3Hk7E8pMjYGpjR16BMbeJ0f28g72SroxLx06uLX3f BOXit98W9ODi0NM2FGF5xpKTYlPYYXRaV7X1ERqOYJh+zj+zCzXPoum+DNLm0oApGOt0cBj5Bn9 IQkaluIhaoruUvpJbZXMBUNb69iu1sMOFyTjwqkv947Qy7pApw4hZ1XV7mt9mqwqjO6iAGeQ2NI lUhrDlel6v70= X-Google-Smtp-Source: AGHT+IEEklNzkNGfA9KJhrPToL7IvF1wzVOM6/DOx1IM/phUQViKEQPQSPmASpV6trZ+2LQhYKqvFA== X-Received: by 2002:a05:6214:2303:b0:70d:db23:b97b with SMTP id 6a1803df08f44-70fac89eb50mr130775406d6.18.1756778316809; Mon, 01 Sep 2025 18:58:36 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::7efe]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-720a30b79aesm4284666d6.0.2025.09.01.18.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 18:58:36 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH 3/7] bootimg_efi: copy grub modules Date: Mon, 1 Sep 2025 21:58:21 -0400 Message-ID: <20250902015825.2785789-3-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250902015825.2785789-1-vince@underview.tech> References: <20250902015825.2785789-1-vince@underview.tech> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 02 Sep 2025 01:58:44 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/222685 Assumming all grub modules weren't embedded into boot*.efi (core.img) copy them now. This commit populates the common partition used to store the grub config and grub modules for both PCBIOS and EFI. Signed-off-by: Vincent Davis Jr --- scripts/lib/wic/plugins/source/bootimg_efi.py | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/scripts/lib/wic/plugins/source/bootimg_efi.py b/scripts/lib/wic/plugins/source/bootimg_efi.py index 98be12160c..c3254033d6 100644 --- a/scripts/lib/wic/plugins/source/bootimg_efi.py +++ b/scripts/lib/wic/plugins/source/bootimg_efi.py @@ -350,7 +350,39 @@ class BootimgEFIPlugin(SourcePlugin): (kernel_dir, mod, hdddir, mod[9:]) exec_cmd(cp_cmd, True) else: + # Assumming all grub modules weren't embedded + # into grub.efi or core.img copy them now. + copy_types = [ '*.mod', '*.o', '*.lst' ] + + # It appears the EFI directory resides after + # initial population of the EFI System partition + # in the if statement above. Remove so that the + # partition doesn't contain any unrequired files. shutil.rmtree("%s/EFI" % hdddir) + + hdddir = "%s/hdd" % cr_workdir + + staging_libdir = cls._get_staging_libdir() + + grub_format = get_bitbake_var('GRUB_MKIMAGE_FORMAT_EFI') + if not grub_format: + grub_format = 'x86_64-efi' + + grub_prefix_path = get_bitbake_var('GRUB_PREFIX_PATH') + if not grub_prefix_path: + grub_prefix_path = '/boot/grub' + + # Copy grub modules + install_dir = '%s/%s/%s' % (hdddir, grub_prefix_path, grub_format) + os.makedirs(install_dir, exist_ok=True) + + for ctype in copy_types: + files = glob('%s/grub/%s/%s' % \ + (staging_libdir, grub_format, ctype)) + for file in files: + shutil.copy2(file, install_dir, follow_symlinks=True) + + # bootimg_pcbios calles prepare_rootfs no need to here. return 0 elif source_params['loader'] == 'grub-efi': shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, @@ -457,3 +489,24 @@ class BootimgEFIPlugin(SourcePlugin): part.size = int(bootimg_size) part.source_file = bootimg + + @classmethod + def _get_staging_libdir(cls): + """ + For unknown reasons when running test with poky + STAGING_LIBDIR gets unset when wic create is executed. + Bellow is a hack to determine what STAGING_LIBDIR should + be if not specified. + """ + + staging_libdir = get_bitbake_var('STAGING_LIBDIR') + staging_dir_target = get_bitbake_var('STAGING_DIR_TARGET') + + if not staging_libdir: + staging_libdir = '%s/usr/lib64' % staging_dir_target + if not os.path.isdir(staging_libdir): + staging_libdir = '%s/usr/lib32' % staging_dir_target + if not os.path.isdir(staging_libdir): + staging_libdir = '%s/usr/lib' % staging_dir_target + + return staging_libdir From patchwork Tue Sep 2 01:58:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Davis Jr X-Patchwork-Id: 69365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C26ECA100E for ; Tue, 2 Sep 2025 01:58:44 +0000 (UTC) Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by mx.groups.io with SMTP id smtpd.web11.67784.1756778320434446786 for ; Mon, 01 Sep 2025 18:58:40 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=NhBUBuIu; spf=pass (domain: underview.tech, ip: 209.85.160.174, mailfrom: vince@underview.tech) Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-4b30d09dab5so50916091cf.2 for ; Mon, 01 Sep 2025 18:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1756778319; x=1757383119; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=muIkAhajL310B+tHVnSzlhmDPJ+ZoBA5H89wnfQNDsE=; b=NhBUBuIuKHXwHy8U5sNIVZprhkO3mQky4vbaBpF4aKNu2eHYSFei0oHbzi9mQkpo6R re73C8LRTTRhRKtJcLaKNGYP0M8cquL4na8mWFfMNknPkMsxj2HCii4knzZGexgAIlTG 3x4twckKZurNMNzG37JB2PUTh4yZ7EBzBxHTZphTrGFz/VJ+0jnHAT/atwFkKLk1SCWl hE5Il4wpmyga7fK0sdhVE08gsMtlYVcz3qK7Z5hEGekvnElDm54E1GtHXOwFkk6ytVbR VHMLbmKfWbK6ieeC7tdAyy7HJrC5fhVCDiPAzuok4XDhoLg24x0qU6psZ14eW2Lrl05I FtzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756778319; x=1757383119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=muIkAhajL310B+tHVnSzlhmDPJ+ZoBA5H89wnfQNDsE=; b=DZhU/yK26856xWKbeXpQA/0enD6DhcMEKQDWOHGFe0pbKR3qMn1HYs07cmUJV2dOKi kZ5qNKItVw5ch3gZeCUDHl6kCgeJXD6+urVgNc0nvrMyxqmGWMw2VFygBN/nP3E5mtSM UhWux3Pu27i/M+OUppHtSmA05W9ZfimiZ0LoM/MFOsbR50Wuh2X1CD/UcAga2OgfxCsu XsUhMXUtPyagiTJmvRHTCLjasrpM60/v1j3DBDvJ/F/WPE9hfQAJKKP4vABE3PcgjRDI j7TtHp4aM2ELrEKHRxSbQLEAnnGQh1vzofO4DCInaZjjiBpxXgZIksiOx/Bk4ZGPS3vZ 1nHQ== X-Gm-Message-State: AOJu0YyjumJDsezuUlcYTAXF1LAU4a3Xc8FW6ilMzMXN9lqznLHHdkHQ 7cQuliPbpaD6AdMF1HXqTX/2nRqOtAgu8Cbch3YLoiMNyzNZl1gSmvjFqI8KL8/9ktMBORSHMJX FqxuYk0k= X-Gm-Gg: ASbGncu2VYYlq57dzCeIEhMgvrzP7dShZAACJjqLvfqNgzGbxRM7f53zA/8H0dQKsxK wSAkR/0fYnF9gLjDGP3bjMDGtzh3x5WIY4GlBCCI6DxS/ZoIYpQIn6k1WXE94TEc14YjRx6Igkk vlY9o2aPbrt6oHyq+EJzH2bF2V0qosoDxnzvCN49qD6HK/bTrcH9GIBxPtlQnkFYhbSTcUJOXAk mjLD1V2FK7JPIzkoPYg5tdEkm5HrQH1UnuHZZ4Sny61kriGxw4DWc448eJ5ifqXwFM4Uv8FOU2R NQgW3b1cgMy9g92eetTawEf79Ma3sxosMVv1PdTFt975Nmi7i75r9A89X7ERc07UYNZcOKV+7j/ CIqScWvt9kec= X-Google-Smtp-Source: AGHT+IGWVzhNpLlqFKrbxlQTCZYUtxuc7rElOqdho1Zbdt7TAXRMDXTrOgC52oSjAVnvqmpWJ6QFkg== X-Received: by 2002:a05:6214:622:b0:70f:a460:c454 with SMTP id 6a1803df08f44-70fac896f25mr122202156d6.34.1756778319042; Mon, 01 Sep 2025 18:58:39 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::7efe]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-720a30b79aesm4284666d6.0.2025.09.01.18.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 18:58:38 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH 4/7] bootimg_biosplusefi: add grub only examples Date: Mon, 1 Sep 2025 21:58:22 -0400 Message-ID: <20250902015825.2785789-4-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250902015825.2785789-1-vince@underview.tech> References: <20250902015825.2785789-1-vince@underview.tech> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 02 Sep 2025 01:58:44 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/222686 Updates the comments section to explain new usage of wic plugins. Signed-off-by: Vincent Davis Jr --- .../wic/plugins/source/bootimg_biosplusefi.py | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py b/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py index 4279ddded8..ad4c0e1768 100644 --- a/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py +++ b/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py @@ -27,7 +27,7 @@ class BootimgBiosPlusEFIPlugin(SourcePlugin): """ Create MBR + EFI boot partition - This plugin creates a boot partition that contains both + This plugin creates a boot partition(s) that contains both legacy BIOS and EFI content. It will be able to boot from both. This is useful when managing PC fleet with some older machines without EFI support. @@ -50,7 +50,9 @@ class BootimgBiosPlusEFIPlugin(SourcePlugin): not turn the rootfs into an initramfs RAM image. This plugin is made to put everything into a single /boot partition so it - does not have the limitations listed above. + does not have the limitations listed above. Unless GRUB is the primary + bootloader. We have to seperate it into multiple partitions because + of core.img. The plugin is made so it does tries not to reimplement what's already been done in other plugins; as such it imports "bootimg_pcbios" @@ -70,9 +72,33 @@ class BootimgBiosPlusEFIPlugin(SourcePlugin): Plugin options, such as "--sourceparams" can still be passed to a plugin, as long they does not cause issue in the other plugin. - Example wic configuration: + Example wic configurations: + + ************ Example kickstart GRUB/Syslinux Hybrid Legacy Bios Or Newer UEFI Boot ************ part /boot --source bootimg_biosplusefi --sourceparams="loader=grub-efi"\\ --ondisk sda --label os_boot --active --align 1024 --use-uuid + ************ Example kickstart GRUB/Syslinux Hybrid Legacy Bios Or Newer UEFI Boot ************ + + + ********************** Example kickstart GRUB Hybrid Legacy Bios Or Newer UEFI Boot ********************** + # See https://wiki.archlinux.org/title/GPT_fdisk#Partition_type + + part bios_boot --label bios_boot --fstype none --offset 1024 --fixed-size 1M \\ + --part-type 21686148-6449-6E6F-744E-656564454649 --source bootimg_biosplusefi \\ + --sourceparams="loader=grub-efi,loader-bios=grub,install-kernel-into-boot-dir=false" + + part efi_system --label efi_system --fstype vfat --fixed-size 48M \\ + --part-type C12A7328-F81F-11D2-BA4B-00A0C93EC93B --source bootimg_biosplusefi \\ + --sourceparams="loader=grub-efi,loader-bios=grub,install-kernel-into-boot-dir=false" + + part grub_data --label grub_data --fstype ext4 --fixed-size 78M \\ + --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --source bootimg_biosplusefi \\ + --sourceparams="loader=grub-efi,loader-bios=grub,install-kernel-into-boot-dir=false" + + part roots --label rootfs --fstype ext4 --source rootfs --part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 + + bootloader --ptable gpt --source bootimg_biosplusefi + ********************** Example kickstart GRUB Hybrid Legacy Bios Or Newer UEFI Boot ********************** """ name = 'bootimg_biosplusefi' From patchwork Tue Sep 2 01:58:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Davis Jr X-Patchwork-Id: 69363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F647CA1007 for ; Tue, 2 Sep 2025 01:58:44 +0000 (UTC) Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by mx.groups.io with SMTP id smtpd.web11.67786.1756778322480658214 for ; Mon, 01 Sep 2025 18:58:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=MedDlQ0X; spf=pass (domain: underview.tech, ip: 209.85.219.51, mailfrom: vince@underview.tech) Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-70de9ffcfffso47136016d6.2 for ; Mon, 01 Sep 2025 18:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1756778321; x=1757383121; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mjfMfBdxyLebbwDgPMPC5T4UWLf7dF4GlEqze820sYU=; b=MedDlQ0XWUBnoTDyrkmCdHrqvxYpIZD25PwQkGRT60rI3zcud2YpR5+bfmqMOntf0N qva4oYB7uwESkwQ5+fk9yQRvqF+GvwLP/CX50Qfk2HX1QjqUg6UG+Dgy2UojSH0MT903 N3lBcIH22KMW4Vx0kudpiuoy5ZLkT61cjc0cUmG/n/ys2bxHxxeGeqQ9S1AyJpGJeMRs uWFMLVaj+L14pQdaie71qOMNOfZIxeTtEVJlQh1425YAAHEIqIUkWIyBKtfTlS7mcNZt 7upac4MRSNr7Ne8BPPwOwVIyllUFsyo8VcmGnBuLol/VBRtCXRUOA/5JbIZRh6l2xEyO IK6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756778321; x=1757383121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mjfMfBdxyLebbwDgPMPC5T4UWLf7dF4GlEqze820sYU=; b=rGMQPEsO5tJp4zs1j/RUNHGNe2doPdbotf2U2V+9wfoH/DHnElTuyS82Dt07zj62w2 BToDCcGl/zEgSN+lY+XLH0TZLB7Pc/65hdN+JGJmcl/oHGMYOJFIrGmyUlGccCwALbdp R2Psjnhzp5xbKMQ1M2MwYYIU59fXEtSldkkq4vUd/xC+tO98NV/CkgOOQNfef5w+G40k IXoBSRrGgYURy58QbWInSsHGd7eDEf3QtTbe+mCBgZQCW1ezFbYspmh88otVyH8rwt7M VXpx5tUBHeiIbAVDOK4WP7B1rny7AiadAfnp7kGyejE/KkuqlkEdXPi9zu/2m3abDGUR g9dg== X-Gm-Message-State: AOJu0YxRLbOOsP6irFiPQ4h/ScxeXpX54iBOHeQJ+/40UK3BuSvbZiU/ WmJkF67ADz7i1Y5aVw7xQzCeU3tG7HmVHCILVrG17vNCy6s67xdA2rS4XRAAsFfQ4Zp4NN3BCP5 /F9XbmaE= X-Gm-Gg: ASbGncvRR9sBocruB7HaHu2tVp+xQLxjHF6+tlFaHf1QIFaIlmKwIied2q+HKRujRlF jKgjFs3Yw1rJaruhju54nsr02zVKVnqijrvisL1LI0J6mncrXqXjAvqyVS/+1lGbx0C8iQ4Lywz jX4WT6kDFiY3eizWjUivdZK0nU4rUsuY175TOli9Cyi+3/ueklTqEvlUP2+FqMbtkM+Q0caf1wT UDtH7sTUNurikMjanH3SdjnHJRvPkUfOkVu6x5ADYbznjtpAlV238S3p1d1JPcM0HLibEEPYHyP 7YdjhH5f3OnNWIuxKXVdTxt5eSb5RctEYYhfwBoFK5WX/pcQYQ7dpje0jnVVGKhmd+Z2Zy6iO0u qtTIIOC/5FQ2HMynuoMe2Tg== X-Google-Smtp-Source: AGHT+IGk8hBU8gTHaJ9eNP93bt+kp9t2Ui4ojCqN46rCD/nOOvw3XNbdTOU+5esxIEGBqWATFYQgZA== X-Received: by 2002:ad4:5ce2:0:b0:71a:5b14:3cbe with SMTP id 6a1803df08f44-71a5b143fe4mr51142836d6.27.1756778321147; Mon, 01 Sep 2025 18:58:41 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::7efe]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-720a30b79aesm4284666d6.0.2025.09.01.18.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 18:58:40 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH 5/7] grub-efi: support custom embedded grub configs Date: Mon, 1 Sep 2025 21:58:23 -0400 Message-ID: <20250902015825.2785789-5-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250902015825.2785789-1-vince@underview.tech> References: <20250902015825.2785789-1-vince@underview.tech> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 02 Sep 2025 01:58:44 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/222687 Commit: Adds support for including custom embedded grub configs. The default one provided in OE-core is limited to everything being in the /EFI/BOOT directory. Adds an embedded grub config that sets root and prefix based upon the /boot/grub directory. Adds probe to the list of default builtin grub modules. Probe is required by the bootimg_pcbios wic plugin generated grub config. Signed-off-by: Vincent Davis Jr --- meta/recipes-bsp/grub/files/cfg-boot-grub | 3 +++ meta/recipes-bsp/grub/grub-efi_2.12.bb | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-bsp/grub/files/cfg-boot-grub diff --git a/meta/recipes-bsp/grub/files/cfg-boot-grub b/meta/recipes-bsp/grub/files/cfg-boot-grub new file mode 100644 index 0000000000..ab370479af --- /dev/null +++ b/meta/recipes-bsp/grub/files/cfg-boot-grub @@ -0,0 +1,3 @@ +search.file /boot/grub/grub.cfg root +set prefix=($root) +configfile ($root)/boot/grub/grub.cfg diff --git a/meta/recipes-bsp/grub/grub-efi_2.12.bb b/meta/recipes-bsp/grub/grub-efi_2.12.bb index 6354b43989..91748c8d04 100644 --- a/meta/recipes-bsp/grub/grub-efi_2.12.bb +++ b/meta/recipes-bsp/grub/grub-efi_2.12.bb @@ -9,6 +9,7 @@ RDEPENDS:${PN} = "grub-common virtual-grub-bootconf" SRC_URI += " \ file://cfg \ + file://cfg-boot-grub \ " S = "${UNPACKDIR}/grub-${PV}" @@ -48,6 +49,7 @@ EXTRA_OECONF += "--enable-efiemu=no" # Define GRUB_MKIMAGE_OPTS variable for additional grub-mkimage options (e.g., disabling shim lock) GRUB_MKIMAGE_OPTS ?= "" +EMBEDDED_GRUB_CONFIG ?= "${UNPACKDIR}/cfg" do_mkimage() { cd ${B} @@ -63,7 +65,7 @@ do_mkimage() { # Search for the grub.cfg on the local boot media by using the # built in cfg file provided via this recipe - grub-mkimage -v -c ${UNPACKDIR}/cfg -p ${EFIDIR} -d ./grub-core/ \ + grub-mkimage -v -c ${EMBEDDED_GRUB_CONFIG} -p ${EFIDIR} -d ./grub-core/ \ -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \ ${GRUB_MKIMAGE_OPTS} ${GRUB_MKIMAGE_MODULES} } @@ -87,7 +89,7 @@ do_install() { # To include all available modules, add 'all' to GRUB_BUILDIN GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \ - efi_gop iso9660 configfile search loadenv test" + efi_gop iso9660 configfile search probe loadenv test" # 'xen_boot' is a module valid only for aarch64 GRUB_BUILDIN:append:aarch64 = "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' xen_boot', '', d)}" From patchwork Tue Sep 2 01:58:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Davis Jr X-Patchwork-Id: 69367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45B24CA1009 for ; Tue, 2 Sep 2025 01:58:54 +0000 (UTC) Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by mx.groups.io with SMTP id smtpd.web10.68016.1756778324319256744 for ; Mon, 01 Sep 2025 18:58:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=F/e0XbI1; spf=pass (domain: underview.tech, ip: 209.85.219.44, mailfrom: vince@underview.tech) Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-70fa947a7acso6720716d6.2 for ; Mon, 01 Sep 2025 18:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1756778323; x=1757383123; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FvG99qTrAmjSaLoPwqOTPkdhf+GS6D//ePb0cA3Nblk=; b=F/e0XbI1H76pfRRPwpA2B2EfSbqAGZK4W1tRx+oUF57AB0+BMEFJ//6sCkL4ZE9GwY B9RfIhOBF4zcuKWpGG/4C3+r6Cz5B2zcLP6BRjjt1o/P5pN4fKgB/QaD3Ol7ge/qotSl 1VVuRRcvAdC+Er7SjWbnHYuLh0nYd7lPzB8DT1X8540S9J2Krf2Qbds1ZCdVVTIzxHwY lA+LTyPdtl9RVCW/HsBb2HaM/hVm53LLzn8Wl6dH7fykSDpahUium7Umn06w0bpsY24I 0pm8G6N14nDPfHi5sDimhg0/zSd+Xzk5Uth4yBGxTSY1XBbLOIA27BwgP44NhrTSee0Z xmfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756778323; x=1757383123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FvG99qTrAmjSaLoPwqOTPkdhf+GS6D//ePb0cA3Nblk=; b=ewC8FEePBVk4uKq98kWTwyfI9+R8Pzsh9TqnpJYSraXm5Jqu79CjSq38G86g3xXfb6 DTdwYUuaMD2hApJ5gFkw9E/YJoPsgz+zylC1+IIj5u6nXOK1eC1eTYQJLnMlF+ZVekYP 5OZ6I+ClLVC/TYVJlLexrq3oF5tr6aghcyDr8gmXkHm4qTR3pjE23dOPCi69ptSGN/b0 NGERajLyIQ0noS7afWMbcMgYAAMRIw+xp54gV+J9WdgHTyyg3/PR0aaZ0MikD9CHnbwL 58KPWY4cD7lwS9l1o4/4QYlBNuldDO3KgayobNDMQcN6kYUg3zV9qyjSl+oqO4duhP8n CAsQ== X-Gm-Message-State: AOJu0YwmFqoKtCmBcMOQpNA7lNu5igUG8lmtGGEMgAbzVjfrGSjvzlqK 2B2+W4ERjIzHbrvs+UBiBfIu9AqyCBvoFabsAFdHc14X+gZH75+X9JJZDSdFGX9h11j7ommFN7J pGy6T1rQ= X-Gm-Gg: ASbGnctXwnR/pE1BiQWo9OHhqWkG2T08F6qtf+KMeJWBRjnUMnmN0LVGNa81gSfI8/1 XlJPunG6TNZPn3VyIGvnD3L1lrRCg28xIzGjypbkQfVY1xF54uv166Ypvi8pb+UUp1xRivgEHlj LkashM7PExL66fBQ1LM3R7QmjX5va62YOTKoxeM0EIhiAxZwrhSDZFcP6UOz2keD2cvs/YmgU5m 1QN/Ox+rSrPbHcDcD9WhdRK/fWFVEaAtzv9Awlfyi24JjWyMCF11T4cPmU4iwWUydbFK1duuIBJ hIqHFZ0q0mBPdYVhlGr4B298Hs19r8CGRFbSUM8tFEve0/3NYFyoZGU+x5sA1dOVT1k00iYfJ/s LtTbUE5q5csMTwVFN22tNWA== X-Google-Smtp-Source: AGHT+IH2JfzhFllqCDkMw5tk1POIsvre0j+2mX9cMUUq5amjFeInFLnptLxScNsHmx4Fx+yMKZl8dQ== X-Received: by 2002:a05:6214:d89:b0:71d:9d4c:192a with SMTP id 6a1803df08f44-71d9d4c3056mr46480166d6.36.1756778322922; Mon, 01 Sep 2025 18:58:42 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::7efe]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-720a30b79aesm4284666d6.0.2025.09.01.18.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 18:58:42 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH 6/7] oe-selftest[wic]: add test_grub_install_biosplusefi Date: Mon, 1 Sep 2025 21:58:24 -0400 Message-ID: <20250902015825.2785789-6-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250902015825.2785789-1-vince@underview.tech> References: <20250902015825.2785789-1-vince@underview.tech> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 02 Sep 2025 01:58:54 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/222688 Commit adds test to check if required files are found in the EFI directory and that grub modules for both EFI and BIOS are found on the same partition as the grub config. Signed-off-by: Vincent Davis Jr --- meta/lib/oeqa/selftest/cases/wic.py | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index 44442e402d..10c3497519 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -1456,6 +1456,60 @@ run_wic_cmd() { out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname)) self.assertEqual(1, len(out)) + @skipIfNotArch(['x86_64']) + def test_grub_install_biosplusefi(self): + """ + Test the installation of the grub in hybrid boot mode. + """ + + # create a temporary file for the WKS content + with NamedTemporaryFile("w", suffix=".wks") as wks: + wks.write( + 'part bios_boot --label bios_boot --fstype none --offset 1024 --fixed-size 1M ' \ + '--part-type 21686148-6449-6E6F-744E-656564454649 --source bootimg_biosplusefi ' \ + '--sourceparams="loader=grub-efi,loader-bios=grub,install-kernel-into-boot-dir=false"\n' \ + 'part efi_system --label efi_system --fstype vfat --fixed-size 48M ' \ + '--part-type C12A7328-F81F-11D2-BA4B-00A0C93EC93B --source bootimg_biosplusefi ' \ + '--sourceparams="loader=grub-efi,loader-bios=grub,install-kernel-into-boot-dir=false"\n' \ + 'part grub_data --label grub_data --fstype ext4 --fixed-size 78M ' \ + '--part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --source bootimg_biosplusefi ' \ + '--sourceparams="loader=grub-efi,loader-bios=grub,install-kernel-into-boot-dir=false"\n' \ + 'bootloader --ptable gpt --source bootimg_biosplusefi\n' + ) + wks.flush() + + img = "core-image-minimal" + config = 'DEPENDS:pn-%s += "grub-native grub grub-efi"' % (img) + + self.append_config(config) + bitbake(img) + self.remove_config(config) + + cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) + runCmd(cmd) + + wksname = os.path.splitext(os.path.basename(wks.name))[0] + out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname)) + self.assertEqual(1, len(out)) + + sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') + + # Check if grub UEFI application (core.img) installed + result = runCmd("wic ls %s:2/EFI/BOOT -n %s" % (out[0], sysroot)) + self.assertIn('bootx64', result.output) + + # Check if grub.cfg is installed + result = runCmd("wic ls %s:3/boot/grub -n %s" % (out[0], sysroot)) + self.assertIn('grub', result.output) + + # Check if normal.mod is installed + result = runCmd("wic ls %s:3/boot/grub/i386-pc -n %s" % (out[0], sysroot)) + self.assertIn('normal', result.output) + + # Check if normal.mod is installed + result = runCmd("wic ls %s:3/boot/grub/x86_64-efi -n %s" % (out[0], sysroot)) + self.assertIn('normal', result.output) + @skipIfNotArch(['i586', 'i686', 'x86_64', 'aarch64']) def test_uefi_kernel(self): """ Test uefi-kernel in wic """ From patchwork Tue Sep 2 01:58:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Davis Jr X-Patchwork-Id: 69368 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4856CCA1002 for ; Tue, 2 Sep 2025 01:58:54 +0000 (UTC) Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by mx.groups.io with SMTP id smtpd.web10.68017.1756778326055898404 for ; Mon, 01 Sep 2025 18:58:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=KwcIE3kR; spf=pass (domain: underview.tech, ip: 209.85.219.41, mailfrom: vince@underview.tech) Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-7193fc78bc3so13448626d6.3 for ; Mon, 01 Sep 2025 18:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1756778325; x=1757383125; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WAr2jUuf31unGa7pEo72YuJRETTe006dI512TTExHKs=; b=KwcIE3kRNIeNSZo839OK2LWUCoWRQGeSXSjjvHSzGsxAeCz9doMvKbuy7XR46WqEjS PGze5kgon0I6XUO0ZTEbrtMn6P92KDWuAVf66wVpICZ+aEZX4Yfj+33Kb4sUkQ20cSgB 2Fl7GnyvdRThlxKYOCrU+SYIRJsAzdfU+1E0gRG0LMZ8hXDhY81P/LUSnfJ0PtAMEwlR t5/OLksQyr07sI7M3xp4d3fzKWRI13eghcjzIZCvawY+Ut9YuZIiolHlZqOi6mXiFH44 BUnJq3xar1fCNqkpBrBhIsEbCNTfgh2ZqsGnZDAhyoR3vjAFtrJstrUIMDhtQQ0loCDq PwVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756778325; x=1757383125; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WAr2jUuf31unGa7pEo72YuJRETTe006dI512TTExHKs=; b=YWie3n0WMd6ySK0EbJpzLsYL+vz5w8Z/+MsI3qrajL0NXgCu5TSEYRtOMVF/aWEqfo oAgRoN+U+n4CCobmU16WcUBmr+XJ7lP/c/2qbiEMltWmw39js1N6dxB8LX9pxswhggmM zyZmEZwog5tJbUw0fFAurExYKL9fvh7ZEYWuh50cAkMA4+vPJ5TWfmjcQK0SM0Dhs+vb LDUcpNKR7wlKcxIQuPDAqtbQu+IGsEhu/OxAqp8OUyy5CqmaQIjd3afJH9/xiXQzFryG PZcwpEtG5Gh+VaR0MkrFq2HgkxsvthBzcjrsnHdBPgjZPKH85+EHixXwcxMDJ+2vqfYg 2mkg== X-Gm-Message-State: AOJu0YxmScKGTjvHGGKJD2ro3xTccrm/uMZ3aTEDNJMa6MgkyGNZ77mn s39Y1+XvW6ox7sUD8MKd/pumbJZDbe1RE9JkXGmBj6+B2mkAIemV3bQ6cW89HLxLW/rrUzuGJJL QSFknZc0= X-Gm-Gg: ASbGnctsdZ7Lu0e8ZiaEMZDoyRTLNS92Xx9wSD2QX1SyRW63pvDeX9UEmBZFwHHMj1N goBHtnsFbq+e2iq0zMJGuQeA/j93Nh1kwstuWB8wTf8i7PuMpOxUsoz2whI1kZLdv2Sbd/PFO3T 1jd3rYgKt8uKiXZZ5rgQLMmaFGtZXQ+W4lZarahnXfyQPQ8NbP7pYRSFMRxOl/E1jgVhbzR6y2p /5sCO2EawRHklvCuajrlf5G/sBqSVUy+DlY6edo/ces9QMQCWvBM/k40bXPeGwA2uKiDVauqg8s hqtouGlp1YsZMr4ZKSoFNPQ3OKvSysuv/othg/4iHgvu8VOuCLRIHYcjtLpvjid43mnFjGRgVDK q/hdkMvrpXsiB97uJONG9sg== X-Google-Smtp-Source: AGHT+IE7i7DhfJfmgrRTmjeXSphr/7E6WrCmbPHgF4N6mpkwZFOZKdl/uwAwzXBXu3bn60lQjZ18vA== X-Received: by 2002:a05:6214:76b:b0:70f:a874:9838 with SMTP id 6a1803df08f44-70fac544bc6mr100819686d6.0.1756778324532; Mon, 01 Sep 2025 18:58:44 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::7efe]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-720a30b79aesm4284666d6.0.2025.09.01.18.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 18:58:44 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH 7/7] oe-selftest[wic]: add test_grub_install_biosplusefi_qemu Date: Mon, 1 Sep 2025 21:58:25 -0400 Message-ID: <20250902015825.2785789-7-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250902015825.2785789-1-vince@underview.tech> References: <20250902015825.2785789-1-vince@underview.tech> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 02 Sep 2025 01:58:54 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/222689 Test runs qemu given wic file and checks to see if the resulting wic image boots with either legacy bios or newer UEFI frimware whilst grub is the primary bootloader. Signed-off-by: Vincent Davis Jr --- meta/lib/oeqa/selftest/cases/wic.py | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index 10c3497519..efd1f5e6f0 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -1510,6 +1510,67 @@ run_wic_cmd() { result = runCmd("wic ls %s:3/boot/grub/x86_64-efi -n %s" % (out[0], sysroot)) self.assertIn('normal', result.output) + @skipIfNotArch(['x86_64']) + @OETestTag("runqemu") + def test_grub_install_biosplusefi_qemu(self): + """Test biosplusefi plugin grub only in qemu""" + + img = "core-image-minimal" + + # create a temporary file for the WKS content + with NamedTemporaryFile("w", suffix=".wks") as wks: + wks.write( + 'part bios_boot --label bios_boot --fstype none --offset 1024 --fixed-size 1M ' \ + '--part-type 21686148-6449-6E6F-744E-656564454649 --source bootimg_biosplusefi ' \ + '--sourceparams="loader=grub-efi,loader-bios=grub,install-kernel-into-boot-dir=false"\n' \ + 'part efi_system --label efi_system --fstype vfat --fixed-size 48M ' \ + '--part-type C12A7328-F81F-11D2-BA4B-00A0C93EC93B --source bootimg_biosplusefi ' \ + '--sourceparams="loader=grub-efi,loader-bios=grub,install-kernel-into-boot-dir=false"\n' \ + 'part grub_data --label grub_data --fstype ext4 --fixed-size 78M ' \ + '--part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 --source bootimg_biosplusefi ' \ + '--sourceparams="loader=grub-efi,loader-bios=grub,install-kernel-into-boot-dir=false"\n' \ + 'part roots --label rootfs --fstype ext4 --source rootfs ' \ + '--part-type 0FC63DAF-8483-4772-8E79-3D69D8477DE4\n' \ + 'bootloader --timeout=1 --ptable gpt --source bootimg_biosplusefi\n' + ) + wks.flush() + + config = 'DEPENDS:pn-%s += "grub-native grub grub-efi ovmf"\n' % (img) + config += 'IMAGE_FSTYPES:pn-%s += "wic"\n' % (img) + #config += 'MACHINE_FEATURES:append = " efi"\n' + config += 'IMAGE_CLASSES += "qemuboot"\n' + config += 'WKS_FILE = "%s"\n' % (os.path.basename(wks.name)) + config += 'WKS_SEARCH_PATH = "%s"\n' % (os.path.dirname(wks.name)) + + self.append_config(config) + bitbake(img) + self.remove_config(config) + + cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) + runCmd(cmd) + + # Test legacy bios boot + runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', img) or "" + with runqemu(img, ssh=False, runqemuparams='%s nographic' % (runqemu_params), + image_fstype='wic') as qemu: + # Check that we have all four /dev/sda* partitions (/boot and /) + cmd = "grep sda. /proc/partitions | wc -l" + status, output = qemu.run_serial(cmd) + self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + self.assertEqual(output, '4') + + # Test UEFI boot + # Can't test as it requires swapping the grub-efi*.bb + # embedded grub config. With one that works in the + # hybrid boot case. + #with runqemu(img, ssh=False, runqemuparams='%s ovmf nographic' % (runqemu_params), + # image_fstype='wic') as qemu: + # Check that we have all four /dev/sda* partitions (/boot and /) + # cmd = "grep sda. /proc/partitions | wc -l" + # status, output = qemu.run_serial(cmd) + # self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output)) + # self.assertEqual(output, '4') + @skipIfNotArch(['i586', 'i686', 'x86_64', 'aarch64']) def test_uefi_kernel(self): """ Test uefi-kernel in wic """