From patchwork Mon Aug 11 04:03:32 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: 68323 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 C7848C87FDA for ; Mon, 11 Aug 2025 04:05:03 +0000 (UTC) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by mx.groups.io with SMTP id smtpd.web10.40636.1754885095665179489 for ; Sun, 10 Aug 2025 21:04:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=DomcwgrE; spf=pass (domain: underview.tech, ip: 209.85.222.177, mailfrom: vince@underview.tech) Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7e814f6fc57so456850685a.1 for ; Sun, 10 Aug 2025 21:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1754885094; x=1755489894; 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=9vbe2aQu/GvLqs3hg8yJjmM0Qv7/RXyPeeoWiBnr2hc=; b=DomcwgrER7gr49YDGlDeNLp7L5DeJHvF69mDMjjjumpRiWPhOwh63ABQ2ClOSJFoqR qNkjf6itdAP2rbCzXpHEmFMjnp84ZEKEUtEk2OVUFa/oOuUSoT0jNT8INPodv5q7gHnb e1V46y7m2PYBairK0ewju2bAu5Yka+iB6Z1ndudjN7J0kkJAcFjjqNQTVfzdtnmnNNlT 7Ta3o+0tF0LEVytX2cSnIyO9jaq1NOV347sz5YjVKMPadKUCh5ErueCse8Kwcf61Cbri EO91rRIbht3WMEYiVI/c4YaDF4F2mfwx/QU9iu+TRblJmm2fqF6BuXUbjsjZEFBolkYK PRog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754885094; x=1755489894; 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=9vbe2aQu/GvLqs3hg8yJjmM0Qv7/RXyPeeoWiBnr2hc=; b=Vc1bBiewp5H8L3fX979Nouzn0EnRO1MSKLzEU15+iUs8ncwePcJQp6P7k17y1SOk5E q1zdSFjM6tGXt2oz2uz38D4VJ4kGeUD/Os5s1vIvFpRVo+n32KuR9ELVma2JPN1f0ewT IaEeuSUH7ZHUvW+eLb7msmTS7p4L+VJM2f+bEBNJS6iP+ohm25pltpXhWxFkWQzJP04e 03jB3Z7+JY6CgwYu6M0G2z6nIBXI1Su3Mo0v9/llzrbfCUayYhjmSTjfbflMNThmBqIF kCWs5yj+iXSK5ZX0fPXQA5J2H3c0ZJXRUL1pop8RfBA+bJMYttINRU9HqkLHf7VE41Wl 6zug== X-Gm-Message-State: AOJu0YxgUUq88pDWRDwiUkk2YVd66IS7kHoLuRAA4QG8E8LKRevys4Ow vvKCG4C9+ps9aJDDPvVa9byJD5BPMqNARp5i2RBmNB1trRmvPf6hLZlUebOarYF/3NDfwD+TaQo 4Lu9m X-Gm-Gg: ASbGncv96y7kE7dDXl76dqiSt8JZCVR1us0M/JLaw/LthNBC22CGV49+jIiSXWQbNwM KqoeOOa6UfVdyrs3/n6wG41yGiKGbVu+LJbS7WmgmVTYf+7XOdkLCIhGq+xz5OyTTaRb2/GWW95 8LmZN/2Jlu7zavjGCQUHRuJ+L/Z11mZo8d/V5Su/1FdjjpMaPZeniiXgzvo+HW32MScFkQh5vPB M+42qsPEw1aYDIrMvKkpwlSadpvk2lQqeFUK1PMva/jNcaKrzo1jy3SikyJZRkg+Lr4ijxa8s79 Lc3Mu6d7gOeEWSUQku7uFcfY7+CWqQfSQ6wxsaF/0nD6wh8eYlDyAcSZIFd1aOJqneC63aZdMdI Q761EzAP5JTIFQaiqiQXj/g== X-Google-Smtp-Source: AGHT+IGHlZfmdaWwRQoYG8B1JIts5eCG1x3+CU5Z2zXLqBNekIgsaEcH+1SCzwVwvXSKBmdL8PhAbw== X-Received: by 2002:a05:620a:4917:b0:7e8:1b9a:fd57 with SMTP id af79cd13be357-7e82d4ccdaamr1092931785a.23.1754885094152; Sun, 10 Aug 2025 21:04:54 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::6d26]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e823fddc10sm597842685a.16.2025.08.10.21.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 21:04:53 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v7 1/9] bootimg_pcbios: seperate syslinux install into seperate functions Date: Mon, 11 Aug 2025 00:03:32 -0400 Message-ID: <20250811040339.857858-2-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 ; Mon, 11 Aug 2025 04:05:03 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221708 Current oe-core bootimg_pcbios wic plugin only supports booting with syslinux. This commit seperates syslinux creation from class BootimgPcbiosPlugin(SourcePlugin) override functions in prepartion of supporting booting other bootloaders in the wics plugin such as * grub * extlinux Being moved now to make it easier to include future bootloaders. Signed-off-by: Vincent Davis Jr --- .../lib/wic/plugins/source/bootimg_pcbios.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index 21f41e00bb..6bde7a67d3 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -50,10 +50,18 @@ class BootimgPcbiosPlugin(SourcePlugin): @classmethod def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): + + cls._do_install_syslinux(disk, disk_name, creator, workdir, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot) + + @classmethod + def _do_install_syslinux(cls, disk, disk_name, creator, workdir, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot): """ Called after all partitions have been prepared and assembled into a disk image. In this case, we install the MBR. """ + bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux') mbrfile = "%s/syslinux/" % bootimg_dir if creator.ptable_format == 'msdos': @@ -80,9 +88,19 @@ class BootimgPcbiosPlugin(SourcePlugin): def do_configure_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): + + cls._do_configure_syslinux(part, source_params, creator, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot) + + @classmethod + def _do_configure_syslinux(cls, part, source_params, creator, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot): """ Called before do_prepare_partition(), creates syslinux config """ + hdddir = "%s/hdd/boot" % cr_workdir install_cmd = "install -d %s" % hdddir @@ -138,6 +156,15 @@ class BootimgPcbiosPlugin(SourcePlugin): def do_prepare_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, native_sysroot): + + cls._do_prepare_syslinux(part, source_params, creator, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot) + + @classmethod + def _do_prepare_syslinux(cls, part, source_params, creator, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it 'prepares' the partition to be incorporated into the image. From patchwork Mon Aug 11 04:03:34 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: 68324 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 A63EFC87FD2 for ; Mon, 11 Aug 2025 04:05:13 +0000 (UTC) Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by mx.groups.io with SMTP id smtpd.web11.40383.1754885109750469495 for ; Sun, 10 Aug 2025 21:05:09 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=elNJXK+0; spf=pass (domain: underview.tech, ip: 209.85.222.182, mailfrom: vince@underview.tech) Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7e7fb58425cso600150385a.1 for ; Sun, 10 Aug 2025 21:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1754885108; x=1755489908; 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=7eKgOnVBPg4nZsvPJst8cxUbqw2xjqqQxagqJKdeJHU=; b=elNJXK+0iDTq+VYddMvd9Q5kOzp9ZzH1nT54ctdJmLv5X75zUJFs2nUpi2KMwCmMYG Jau8BwtqGjIEqFXVgapNps7g752UPugIkSypTqv9Frxx4n5n5Pkt9OvkSRb/gNc5Iqt0 sdt24TABTlVAIIf23hrW1zn4B8WsxUyQhAL3Mu1NLDgYuGP8cjJoEPIsvdJf+g9q2T8N 8Ioj/miu94932Q91TpnPYLDvqFV16FPmS/zpE9bNfwTEqhekKLRWJHZ+O5/cmkPzINNq b0LX+4O2aNEDTac2Ht9ufEC7l1OFGiog5GfYAjnGQXiWF1pDkKdd1vVmtUTTb/JaYeTe 8mIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754885108; x=1755489908; 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=7eKgOnVBPg4nZsvPJst8cxUbqw2xjqqQxagqJKdeJHU=; b=PFUmtobLK14E+05VPBKkF6Wqkpkes87R0UzmbI0M09K0VpxBnLKCDWXqUK6PElg9zz PeYV5JSsug2gQC6NkQtHnsjhrzOdO3ym7sEB9vzB0JD00oq4FmO2rcePf7QgOttSYjTc HYeej34W/9hkci0yOTS0MrRxGHjn70XWFrJIcIs0foTzTzEvoy74wDAFgpxxSVrSW80U 82SNcRDv9U5Ge9IAOsD10TFAR+xXJ0co0maUOBJ/ijBYwO0dXbD1O03PmjhBmsreb778 UHvH8r4q6KSvXp1Vh11SdOwp7P6TJjyk2SeFKXZee5Ggk6TqD6FOlJywoWzYTaWa1aLM 33pQ== X-Gm-Message-State: AOJu0Yx+k0zL4f5FxoMyMcBpR33zPsDbXy618fMTzYq40vgFLrEgeZ9X apn/muAiN8/tyC+b9rj/Ig9F0VglutV+luwm20lgJPcdiB5JAlflKouGEzJriocetHN06cOywWe cQhKF X-Gm-Gg: ASbGncvNgujNFGwOHcHhVW8itFJsr4G9XMiDBr5R42Z6swd36e0NE0UtgJlRjrECLLB gHJ0Aj1AjVmBf1t1c9n0CbmiRwxv6Oa6UJXn+Y76dHhsSsejLBUGKGCZekpzfRh3W1+oJay5ENW /Sf63JqNIGEGFZl7ti5ncgNOqPzTBL/oXx33hcURt55hsfGbrnJAsbADuMnZr5xPueWdOtqpz73 v61tf3EM/Zw9Akr4YzlcoUECJ3+Vv2AMzAcxET+M0LNxN2NNIkUS5x4p+tJDguNTt1BPGseXQlY F1GFLMQtGwslwQOdwBsE3eUSr12Ykn61b+eua21fviybvfG9N0gNk5q/6TsPxZKf94n6axO3y9p H1Y9TnSAzNvS1iFOUn4MnEQ== X-Google-Smtp-Source: AGHT+IGKLIRYSOlV17YDY1jQpeg2yfgx4CAVFvDuNcj3xE8VKqV62vdT/Ta2WgfFv+/jqDoqRYcZpQ== X-Received: by 2002:a05:620a:a48c:b0:7e6:8545:5505 with SMTP id af79cd13be357-7e82c7904f8mr1463042785a.55.1754885106457; Sun, 10 Aug 2025 21:05:06 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::6d26]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e823fddc10sm597842685a.16.2025.08.10.21.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 21:05:06 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: "Vincent Davis Jr." Subject: [PATCH v7 2/9] bootimg_pcbios: move newly created syslinux funcs to end of file Date: Mon, 11 Aug 2025 00:03:34 -0400 Message-ID: <20250811040339.857858-4-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811040339.857858-2-vince@underview.tech> References: <20250811040339.857858-2-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 ; Mon, 11 Aug 2025 04:05:13 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221709 From: "Vincent Davis Jr." This commit moves the seperated syslinux creation functions from current position to end of file in the order 1. _do_configure_syslinux 2. _do_prepare_syslinux 3. _do_install_syslinux This is to prepare for inclusion of other bootloaders. It also makes reading through the wic plugin much easier if you group bootloader specific partition creation functions together and place them at the bottom of the file versus leaving them in their current position. Signed-off-by: Vincent Davis Jr. --- .../lib/wic/plugins/source/bootimg_pcbios.py | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index 6bde7a67d3..9ad301b008 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -54,36 +54,6 @@ class BootimgPcbiosPlugin(SourcePlugin): cls._do_install_syslinux(disk, disk_name, creator, workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot) - @classmethod - def _do_install_syslinux(cls, disk, disk_name, creator, workdir, oe_builddir, - bootimg_dir, kernel_dir, native_sysroot): - """ - Called after all partitions have been prepared and assembled into a - disk image. In this case, we install the MBR. - """ - - bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux') - mbrfile = "%s/syslinux/" % bootimg_dir - if creator.ptable_format == 'msdos': - mbrfile += "mbr.bin" - elif creator.ptable_format == 'gpt': - mbrfile += "gptmbr.bin" - else: - raise WicError("Unsupported partition table: %s" % - creator.ptable_format) - - if not os.path.exists(mbrfile): - raise WicError("Couldn't find %s. If using the -e option, do you " - "have the right MACHINE set in local.conf? If not, " - "is the bootimg_dir path correct?" % mbrfile) - - full_path = creator._full_path(workdir, disk_name, "direct") - logger.debug("Installing MBR on disk %s as %s with size %s bytes", - disk_name, full_path, disk.min_size) - - dd_cmd = "dd if=%s of=%s conv=notrunc" % (mbrfile, full_path) - exec_cmd(dd_cmd, native_sysroot) - @classmethod def do_configure_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, @@ -93,6 +63,15 @@ class BootimgPcbiosPlugin(SourcePlugin): oe_builddir, bootimg_dir, kernel_dir, native_sysroot) + @classmethod + def do_prepare_partition(cls, part, source_params, creator, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): + + cls._do_prepare_syslinux(part, source_params, creator, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot) + @classmethod def _do_configure_syslinux(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, @@ -152,15 +131,6 @@ class BootimgPcbiosPlugin(SourcePlugin): cfg.write(syslinux_conf) cfg.close() - @classmethod - def do_prepare_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, - rootfs_dir, native_sysroot): - - cls._do_prepare_syslinux(part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, - rootfs_dir, native_sysroot) - @classmethod def _do_prepare_syslinux(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, @@ -234,3 +204,33 @@ class BootimgPcbiosPlugin(SourcePlugin): part.size = int(bootimg_size) part.source_file = bootimg + + @classmethod + def _do_install_syslinux(cls, disk, disk_name, creator, workdir, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot): + """ + Called after all partitions have been prepared and assembled into a + disk image. In this case, we install the MBR. + """ + + bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux') + mbrfile = "%s/syslinux/" % bootimg_dir + if creator.ptable_format == 'msdos': + mbrfile += "mbr.bin" + elif creator.ptable_format == 'gpt': + mbrfile += "gptmbr.bin" + else: + raise WicError("Unsupported partition table: %s" % + creator.ptable_format) + + if not os.path.exists(mbrfile): + raise WicError("Couldn't find %s. If using the -e option, do you " + "have the right MACHINE set in local.conf? If not, " + "is the bootimg_dir path correct?" % mbrfile) + + full_path = creator._full_path(workdir, disk_name, "direct") + logger.debug("Installing MBR on disk %s as %s with size %s bytes", + disk_name, full_path, disk.min_size) + + dd_cmd = "dd if=%s of=%s conv=notrunc" % (mbrfile, full_path) + exec_cmd(dd_cmd, native_sysroot) From patchwork Mon Aug 11 04:03:36 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: 68325 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 A844DC87FD2 for ; Mon, 11 Aug 2025 04:05:23 +0000 (UTC) Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by mx.groups.io with SMTP id smtpd.web11.40386.1754885121983606610 for ; Sun, 10 Aug 2025 21:05:22 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=W7tXG6pP; spf=pass (domain: underview.tech, ip: 209.85.222.171, mailfrom: vince@underview.tech) Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7e835e02d96so210374385a.2 for ; Sun, 10 Aug 2025 21:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1754885121; x=1755489921; 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=S2q3Sd+TruzbpygG2jmkICKxLwXZGUyCtj4TKM1OoMw=; b=W7tXG6pPZz73VZeFjyhuqOh1pt9IH3j69u3KVc2PH2UwOzDfXoxAmbDAc+B20eKGjC 4t89QhezhQxb02jtXeaD+4/QJ5ihmcvHO6jwAQ24pHW2SYYToCquZAFTSiEo0miu4ahG f9la58G1Kr01fu0Whe++NIf0LmKh57DG5bwXyOVZym6zSjxlSUKDNabfBcM7abLTUMcp mHlHbmapHS93XoGmWdgKju+d/xh0dRPwumcbi6QYEugkQ+Vhw59x7JuvsYWQd7FEAuKD XEZMsduxblg10bUsQfvXSQO7xX+K7UD7nKmj5BFqh5lrwD7TxDO4f9zK/fMYZC7Y1Mb2 kx6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754885121; x=1755489921; 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=S2q3Sd+TruzbpygG2jmkICKxLwXZGUyCtj4TKM1OoMw=; b=cEUYHEbCcs1AknU/U0LovnC6wbogdymAY1tM3zFc2xuZfe+NYosW4ZvaJhyMXMkZ7N Gat9AbfFmm7O6BiEupC0VGxOke5tfWIPt0BQsodQljCSRbbMYnXXDKbny5H32Pfh6awP RydxwI+Rk9s6R4t7CbJBt9qQLCYovyFcIlsREkqAujwBEUOWTZHB5eDzEygm1/2YHlfX Yf0Jt893CmiL947hrz8QqfAR/aoLfs+ZsP10J7NCrviDWsvhsmvdhQ7CG/cp00aNmmtG no2l0EtU/Ba8ya/AcwtccGZG07mqcnZN+y96ZKJWtL2L9DXzsYn0oCvTsub/AbflqP+e jP3Q== X-Gm-Message-State: AOJu0Yymjj5dHLP9x4+pXv+MgK4NHRJVjGBY1GYBQ9PSkxqLyQj10TM+ bDnChA9gJXxZyXInot3e/0V+vXy4HTDCFHFs95nf+NyIfh/qQaCCBoVATBsWFg9PZHBPfg1Yg6W azPFn X-Gm-Gg: ASbGncstzMFwx9c7nSfy01EboesyvOkWccnKlXEsYgquvbOl08srgQc/WlKW7MYh//9 MVk7/RanpRi4AAZGFbCS2JPNXIBzeXYx+HOkus9hIUU5wyMAdk38pgFcvCwmvHObrzHrKzeUx0s 96w/vjxkDYdZ/bSKcU6X9oHrbugcuCcwcehg5KdcK38oJH61tPsJAN6F08PQ0LF3K7b273Ze+2z siXHoCO7G/h/Ate3JomnMAnFBP15TG3q8RgaW4Q6mCwwLRijjlOFpGfi++P2CnKDtKMLmBBwHd0 0JHwVEIJ2BIDcgU10sZoy6XnvTsXBddFtAvmg28BqRyXSelEDS8CKDLNmPn/plhRTiM3ngJMvVE u6TwVGeg54mI= X-Google-Smtp-Source: AGHT+IFRs62uxfL3gQc9cttC1RrpSfj64zftcCO3AFbtN1mNqOaNfltAekiN8Q/KNdHPd5p8/RCM6w== X-Received: by 2002:a05:620a:7183:b0:7e6:4fc9:6457 with SMTP id af79cd13be357-7e82c77d504mr1169043685a.54.1754885120641; Sun, 10 Aug 2025 21:05:20 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::6d26]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e823fddc10sm597842685a.16.2025.08.10.21.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 21:05:20 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: "Vincent Davis Jr." Subject: [PATCH v7 3/9] bootimg_pcbios: seperate bootloader config creation Date: Mon, 11 Aug 2025 00:03:36 -0400 Message-ID: <20250811040339.857858-6-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811040339.857858-2-vince@underview.tech> References: <20250811040339.857858-2-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 ; Mon, 11 Aug 2025 04:05:23 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221710 From: "Vincent Davis Jr." Most bootloaders that will be included in this wic plugin will require a configuration file to define kernel params or execute custom modules. Create a seperate generic function to facilitate finding if a bootloader config file passed through bootloader --configfile flag. So, that other functions that are used to create/install a bootloader boot configuration file can leverage the function. Signed-off-by: Vincent Davis Jr. --- .../lib/wic/plugins/source/bootimg_pcbios.py | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index 9ad301b008..47fd4b9415 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -72,6 +72,22 @@ class BootimgPcbiosPlugin(SourcePlugin): oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, native_sysroot) + @classmethod + def _get_bootloader_config(cls, bootloader, loader): + custom_cfg = None + + if bootloader.configfile: + custom_cfg = get_custom_config(bootloader.configfile) + if custom_cfg: + logger.debug("Using custom configuration file %s " + "for %s.cfg", bootloader.configfile, + loader) + return custom_cfg + else: + raise WicError("configfile is specified but failed to " + "get it from %s." % bootloader.configfile) + return custom_cfg + @classmethod def _do_configure_syslinux(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, @@ -86,20 +102,9 @@ class BootimgPcbiosPlugin(SourcePlugin): exec_cmd(install_cmd) bootloader = creator.ks.bootloader + syslinux_conf = cls._get_bootloader_config(bootloader, 'syslinux') - custom_cfg = None - if bootloader.configfile: - custom_cfg = get_custom_config(bootloader.configfile) - if custom_cfg: - # Use a custom configuration for grub - syslinux_conf = custom_cfg - logger.debug("Using custom configuration file %s " - "for syslinux.cfg", bootloader.configfile) - else: - raise WicError("configfile is specified but failed to " - "get it from %s." % bootloader.configfile) - - if not custom_cfg: + if not syslinux_conf: # Create syslinux configuration using parameters from wks file splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg") if os.path.exists(splash): From patchwork Mon Aug 11 04:03:38 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: 68326 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 A8B4EC87FD2 for ; Mon, 11 Aug 2025 04:05:43 +0000 (UTC) Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by mx.groups.io with SMTP id smtpd.web11.40387.1754885134392963422 for ; Sun, 10 Aug 2025 21:05:34 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=OeuYsebq; spf=pass (domain: underview.tech, ip: 209.85.222.170, mailfrom: vince@underview.tech) Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-7e7f940a386so228775185a.3 for ; Sun, 10 Aug 2025 21:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1754885133; x=1755489933; 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=pQSdVNHa8b06wy7TY99YbaIK6vi5QRCkJPGn0a36DE0=; b=OeuYsebqknKkp9eXG0oD4KfvCAN3M9i9ODwSkBv83clPwJrXz8nVxlkycfvOwwRPSf SIG7Q61QBC/upVlNCze1OZ7vLzMYipB6MEcTTueA84agszalzjAMvnuXGr9ESbFUDcV8 W7EsU4Jf23NR8xnM/gUq50qTxa53LdCJ+mUMH8X5WYCUDmqjXojQwC33BKQugmPOQOzy JQgbbcPnvzbULqvtRsKt3Ion/Y1RehXZNYPtY4V9Bk/HoQpabU0lJhV4N7JPglQnMR14 iiDhl82vw1OgIGEx4Io0/615ZFw2rvBiFs02AWRSFdV3XcjBZN8UGPVLWyTyQEk6nE0a e7kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754885133; x=1755489933; 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=pQSdVNHa8b06wy7TY99YbaIK6vi5QRCkJPGn0a36DE0=; b=JdbKsyZgdvB2Ryt2tir5rHdMRiXfqyKjrNmjHszJXGSNzy9uzFriylfJdK07502Gn8 IVrV4Y5dH3RlOhh43x3z65ZeInst62oNUIW0Gc6MHV6mwcrG/n+pmazbfD7y4OjFRH7A g5a1K45LqRoc/8unjHNuicIlxITQggXzfH4+kv/wQ/ClMUA9AzuyTZ8EiPOU9+LTKzkr WmoCMNR20U/FBLp0yub/QObFg3MDkpwqouph2dZLKkUpNHt4G/bsMaDDrPMdyTsqnGlc 0SIKohxeX5AedMUMYjc48mFh6B4CwnEa28qmx1/2hEfEaTRUULKg5SknnTVctn8Gnp5V BQRA== X-Gm-Message-State: AOJu0Yw4AjJKqBEkMqYSpQHBT1WUnzknmosiRQ5rg1ZsJwRFHrde5I8D t6p4+Ad945Xom7s1G4vR+xziaGJfa0iIhtvtsQS/J6c7ohKn6/3WHs/5juuXuh8e/0lsyN2jYj7 PfZ+k X-Gm-Gg: ASbGncsCS6AEUClhsRzLPEhyHyX/j3vtXxj9Ja4+Bn/rezs5bC7EHO0i3fKLWlxO6Xu cZEDo3yB0glK79FGIkkAFpG6nvjh+Wt31I9zTgK2wYjwCCa+WRivQ3FOqWxnu+cgejrKd3Kfl7T uSz/7/DE3xJ5qDlE0U+/KwHWa3HC3KEpfkX/f42sKT7jTKI0t0kOCGRSDBxzyrnOMsHsBjBupSO miQ6rrLFebsMIabKJNdSHAGJtA8TgqFffq4af3g6Z7LOPYwjniBkLPTlNQSvhuiprPqRjYxGJ0g JxTcpZ4XAFH1ctr6LjbhWKN8bpQunjRMUbz3aLKiDUe3fq9uzxl1Q6ckecF2RYaMxQp3gGy0ej/ giYhL6LwnNlY= X-Google-Smtp-Source: AGHT+IGICgUsBsRaNkz8ywxq+ildCy2o5LKT80bMQl5MOfBTiL8UiGPEOctecJsWptZJqwTIAtSYVg== X-Received: by 2002:a05:620a:3190:b0:7e8:46ff:a520 with SMTP id af79cd13be357-7e846ffa5f3mr614782485a.59.1754885132999; Sun, 10 Aug 2025 21:05:32 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::6d26]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e823fddc10sm597842685a.16.2025.08.10.21.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 21:05:31 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v7 4/9] bootimg_pcbios: cleanup _do_configure_syslinux function Date: Mon, 11 Aug 2025 00:03:38 -0400 Message-ID: <20250811040339.857858-8-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811040339.857858-2-vince@underview.tech> References: <20250811040339.857858-2-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 ; Mon, 11 Aug 2025 04:05:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221711 Commit: 1. Removes all unrequired function parameters. The part parameter was kept due to it's potential future usage in _do_configure_syslinux function. part.fstype specifically may be used with he rootfstype kernel paramater. 2. Sets a default timeout to 500 if bootloader --timeout not specified. To avoid 'None' being placed as the value in resulting configuartion file. 3. Sets a default kernel parameter string if bootloader --append not specified. This also helps avoid 'None' being places as the value in resulting configuration file. 4. Replace all instances of cr_workdir, "/hdd/boot" with variable hdddir as it's set at the top of the function. No, need to re-implement what variable is already defined to store. Signed-off-by: Vincent Davis Jr --- .../lib/wic/plugins/source/bootimg_pcbios.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index 47fd4b9415..887a548cde 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -59,9 +59,7 @@ class BootimgPcbiosPlugin(SourcePlugin): oe_builddir, bootimg_dir, kernel_dir, native_sysroot): - cls._do_configure_syslinux(part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, - native_sysroot) + cls._do_configure_syslinux(part, creator, cr_workdir) @classmethod def do_prepare_partition(cls, part, source_params, creator, cr_workdir, @@ -89,9 +87,7 @@ class BootimgPcbiosPlugin(SourcePlugin): return custom_cfg @classmethod - def _do_configure_syslinux(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, - native_sysroot): + def _do_configure_syslinux(cls, part, creator, cr_workdir): """ Called before do_prepare_partition(), creates syslinux config """ @@ -106,12 +102,24 @@ class BootimgPcbiosPlugin(SourcePlugin): if not syslinux_conf: # Create syslinux configuration using parameters from wks file - splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg") + splash = os.path.join(hdddir, "/splash.jpg") if os.path.exists(splash): splashline = "menu background splash.jpg" else: splashline = "" + # Set a default timeout if none specified to avoid + # 'None' being the value placed within the configuration + # file. + if not bootloader.timeout: + bootloader.timeout = 500 + + # Set a default kernel params string if none specified + # to avoid 'None' being the value placed within the + # configuration file. + if not bootloader.append: + bootloader.append = "rootwait console=ttyS0,115200 console=tty0" + syslinux_conf = "" syslinux_conf += "PROMPT 0\n" syslinux_conf += "TIMEOUT " + str(bootloader.timeout) + "\n" @@ -130,8 +138,7 @@ class BootimgPcbiosPlugin(SourcePlugin): syslinux_conf += "APPEND label=boot root=%s %s\n" % \ (creator.rootdev, bootloader.append) - logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg", - cr_workdir) + logger.debug("Writing syslinux config %s/syslinux.cfg", hdddir) cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w") cfg.write(syslinux_conf) cfg.close() From patchwork Mon Aug 11 04:03:40 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: 68327 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 A6DD4C87FDA for ; Mon, 11 Aug 2025 04:05:53 +0000 (UTC) Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by mx.groups.io with SMTP id smtpd.web10.40644.1754885146154061965 for ; Sun, 10 Aug 2025 21:05:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=IJwq4+ai; spf=pass (domain: underview.tech, ip: 209.85.160.172, mailfrom: vince@underview.tech) Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-4af123c6fc4so39600241cf.0 for ; Sun, 10 Aug 2025 21:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1754885145; x=1755489945; 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=otmBbsGcoukEdW/FnrobSdXhWYcx9rZbytFt4Ajfjhw=; b=IJwq4+aibBjgSwRXU/5A0iVwPb4sOYQEzVG8iHVmxJ3m6xF2eXu3zNuFLg0MlOcPW+ rd2bcuAAcLZ+B89PsQbgxB7utCfJ1BV3JWspjPwpad5GOBAUANcsdLDE5snE8Y8H+pCe OKU9yK7F0eABvmdJDHg37j+p/5xeDjL5BkOM0BVMvlog8n0+pkq03AbmxRmAaRlV7Pa2 Cglpw8UG6+0N78Td4y1uZKqcsNBUUMDq4Msi6MHQfQywe2TvRL6d4qAo6JappsPXRphO tZ+zm0lfT9CUZ5sc2YSD2wyXv2f1szf/gfVV5n6+GBwTxBrOHIxgGYua2adjHpp5D+5q JMxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754885145; x=1755489945; 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=otmBbsGcoukEdW/FnrobSdXhWYcx9rZbytFt4Ajfjhw=; b=C960ntqfnObKFYc0A5KcyaSWgh0QzPSSnaw3DRFndzDnqAx0V916COexNpGD+MJirP nK1M+y0Cvg8qKyB1EJZTR3Ib5OZwKRNU8eccKwSmsw7e/Kl7uSnn8XGLr6b+P1nULIi6 Gg/DjTfY1a69E+YOuTM8Bo5qJ/8r2vJgLIAp7pPPLv2NVSzOXk0idTj5DpOA79CCUnvi St/nIgODLSK867yWuCQiFpFX7pE8HYxi4CCSQiNg5E0A/qg9DMXyx6EPrCXe7ZEFy8ac E5jGFAPGKR1eeeiW6AhPSqK6Q1y0ypm0jUI7vXYPwQdrjjLlPXl+daf1y5U8OR+ZPJ/Q zmqw== X-Gm-Message-State: AOJu0Yyg9vtMspYP9eKRywKLti3qlNED0tF67QzFj2VV1Yhs4t+dnYvM vxuLf6swddH+xuRGcbN/xL1XT4jzvt3wWVjIQQuINQV5aHKgJXUOmqE/cKMhYswGZX7yvS+XNx3 qRNN2 X-Gm-Gg: ASbGnct2siZZfaEi7Owb/lY89/azQGQ/DLsqfxlrxWT1RRXMvsojUOfLtuJrnw3iWs0 ovB5HlTwv6ZLL9THwzhLUrI4Amo7riUT/UTDj8JmI9A/h+1mACdYTfKvAjyF4IFGg+b5D57b79w KPZx0Gzx/Zp3ZQ8RoFY7nToBL6EieVeYNnnjRycqOHtQlAlbDg4Wr1V5m1sybIiFMEVLhnpSR4y HE1ZnCQuxSMjq5uamvQkfCurl7DYG6GFmvL3u+XuQpWh8uSnNKwXMFfg5zfC4Stx2/14X81abur jkclZX8t+H2ucaCOJ8mtv8tTjxUpC8BiKGURdFITQ2sBhlanKha1MQg0HkaqoiM1AEsLxs/rlg2 gBxkCIvvarig= X-Google-Smtp-Source: AGHT+IFcPTdj940WGjysAB/+ITCkXuWC1yCL7Gd0kyVqoD4bbC2JyXC2vftsFLEmh6xDqe7jufsOrA== X-Received: by 2002:a05:622a:5906:b0:4b0:8e21:fd57 with SMTP id d75a77b69052e-4b0aed41d45mr189774481cf.41.1754885144814; Sun, 10 Aug 2025 21:05:44 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::6d26]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e823fddc10sm597842685a.16.2025.08.10.21.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 21:05:44 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: "Vincent Davis Jr." Subject: [PATCH v7 5/9] bootimg_pcbios: remove unrequire _syslinux func params Date: Mon, 11 Aug 2025 00:03:40 -0400 Message-ID: <20250811040339.857858-10-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811040339.857858-2-vince@underview.tech> References: <20250811040339.857858-2-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 ; Mon, 11 Aug 2025 04:05:53 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221712 From: "Vincent Davis Jr." Commit 1. removes unrequired function params from * _do_prepare_syslinux * _do_install_syslinux Reason is that they aren't required by the function. 2. Moves finding of resulting wic image back into do_install_disk task. As the same code may be leverage to install other bootloaders to the resulting disk. Signed-off-by: Vincent Davis Jr. --- .../lib/wic/plugins/source/bootimg_pcbios.py | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index 887a548cde..a4fabec0ae 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -50,9 +50,12 @@ class BootimgPcbiosPlugin(SourcePlugin): @classmethod def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): + full_path = creator._full_path(workdir, disk_name, "direct") + logger.debug("Installing MBR on disk %s as %s with size %s bytes", + disk_name, full_path, disk.min_size) - cls._do_install_syslinux(disk, disk_name, creator, workdir, oe_builddir, - bootimg_dir, kernel_dir, native_sysroot) + cls._do_install_syslinux(creator, bootimg_dir, + native_sysroot, full_path) @classmethod def do_configure_partition(cls, part, source_params, creator, cr_workdir, @@ -66,9 +69,8 @@ class BootimgPcbiosPlugin(SourcePlugin): oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, native_sysroot): - cls._do_prepare_syslinux(part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, - rootfs_dir, native_sysroot) + cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + kernel_dir, native_sysroot) @classmethod def _get_bootloader_config(cls, bootloader, loader): @@ -144,9 +146,8 @@ class BootimgPcbiosPlugin(SourcePlugin): cfg.close() @classmethod - def _do_prepare_syslinux(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, - rootfs_dir, native_sysroot): + def _do_prepare_syslinux(cls, part, cr_workdir, bootimg_dir, + kernel_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it 'prepares' the partition to be incorporated into the image. @@ -218,8 +219,8 @@ class BootimgPcbiosPlugin(SourcePlugin): part.source_file = bootimg @classmethod - def _do_install_syslinux(cls, disk, disk_name, creator, workdir, oe_builddir, - bootimg_dir, kernel_dir, native_sysroot): + def _do_install_syslinux(cls, creator, bootimg_dir, + native_sysroot, full_path): """ Called after all partitions have been prepared and assembled into a disk image. In this case, we install the MBR. @@ -240,9 +241,5 @@ class BootimgPcbiosPlugin(SourcePlugin): "have the right MACHINE set in local.conf? If not, " "is the bootimg_dir path correct?" % mbrfile) - full_path = creator._full_path(workdir, disk_name, "direct") - logger.debug("Installing MBR on disk %s as %s with size %s bytes", - disk_name, full_path, disk.min_size) - dd_cmd = "dd if=%s of=%s conv=notrunc" % (mbrfile, full_path) exec_cmd(dd_cmd, native_sysroot) From patchwork Mon Aug 11 04:03:42 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: 68328 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 A90BEC87FDA for ; Mon, 11 Aug 2025 04:06:03 +0000 (UTC) Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by mx.groups.io with SMTP id smtpd.web11.40390.1754885160252986576 for ; Sun, 10 Aug 2025 21:06:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=e3lwSr3l; spf=pass (domain: underview.tech, ip: 209.85.222.173, mailfrom: vince@underview.tech) Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7e1d89fcc31so406831985a.1 for ; Sun, 10 Aug 2025 21:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1754885159; x=1755489959; 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=uaR++pCrHxHOm8GgvryecDb3FZ8EbmnakdMWNZBYT4w=; b=e3lwSr3leJ9W0DE+7rlKLR6a5UFYcmuGQ/ozISpSKitwNm/woAthlsD53SwlI1PXru DMW8onK6aW9uwR4tqpqK7sM1eVLn4OiHdt1Wiqh2YCAoJ9EUzg/TIw9oPAr+y6651ux2 BQkmjNj0nPCHXSaBMHYn+T/8G9h1xzDEykSpeQ+dG1zRGzEv+loI9godqGCnJSKFgVsp WXmVU7iiaYATOG1tmNOUesfREutJBQAZNkcRHSO9cbEIKd9ARauX8GzbChctC8gswyxN /addMGsO6nh3BaQFmyCfBzzYCslGSVxyL8Njb+IzCpFDJrVmo2eg114l47wcjsC1tTtu /M4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754885159; x=1755489959; 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=uaR++pCrHxHOm8GgvryecDb3FZ8EbmnakdMWNZBYT4w=; b=SbEcIOMKctHgxexmNkdtbdqS0dsQ1EQx/a7Fnl5mZusiR9Y2p2UMRtA7yVoanpHx2J iqsYWVj2zXdD1t3MHqRGsrgreb/gYCZdirzozqdgjS2neFL7xCkZMMoYHdmodhG98Yv/ XbXeRpFRMqdEYkWce6/uYdFHKDJsmK4jqm1vvzPHaZ836xBG0KKgBTXyQRXtNbVXmsqi nMCOETKwgfDOTVtyTBrLSddoWV1PuV3TYky13IHHJPVCPOLPMfSF0lPqTHojbjowHI5k SVu5B7vS1pL3yN2sKp2OlqDSN2a8QWB7GH2SpPcBgJ1E0ChU6GsBaSlQJUBOewBUIznY lExw== X-Gm-Message-State: AOJu0YzujvD4gYViD3AFQ7c9zmJBBWqFzLb46aRTYIwPiPaxBwt8QkTN UKVIYSiwozac6Q8fMEuMNvp1Lj3Z7U0aNBnrBfhkRbx6jhBHh6dvCGhtQb+PYuIsHYh+WhCd0/x KZj20 X-Gm-Gg: ASbGncth66XTTbQzEP+DTqZz9QcyPQpx5gcgSa418HF9EX35TBt9UQawj2PU/Yjd53r WaRvOBbOkHJ6yfexqOEDn5pIItgkDh8dMx0nOs0b2rUk0FTJXLOdHyZJ4hZuKaAz9CntIZibCEe SIqi+VxaVTHW8JN71kwQyGfKlalCjq1ZPsVx2l08qyc/YV41XC3xOki5P/QYrpjzshUbiXtX9y4 ArjDGHoXLZgU3SLMfZ7cvArzEj9+CoSV9hf0kL3+y2YicXY2YOst80qbKuuIX7DEzb+VThzNnhX TJxw5kNTmIgD+WUj6bJaYkVdvqbYjm5+BOueo5Iy1ZolinqjP1TfEDFGr9PqFB721XDu/+OZFKx X65GMuAyJYUI= X-Google-Smtp-Source: AGHT+IH+o2vdv5pem0TBzR0BmjfPNFFtTMr/Wk9wYGV0ZQzvTNE7K95j/X7ic1ELjUBaNQXzb9hjXw== X-Received: by 2002:a05:620a:4515:b0:7e8:32a3:8c4b with SMTP id af79cd13be357-7e832a3cad0mr1270455385a.13.1754885158738; Sun, 10 Aug 2025 21:05:58 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::6d26]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e823fddc10sm597842685a.16.2025.08.10.21.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 21:05:58 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v7 6/9] bootimg_pcbios: add funcs to configure booting with grub Date: Mon, 11 Aug 2025 00:03:42 -0400 Message-ID: <20250811040339.857858-12-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811040339.857858-2-vince@underview.tech> References: <20250811040339.857858-2-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 ; Mon, 11 Aug 2025 04:06:03 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221713 Functions added, but not included into SourcePlugin overridable functions. _get_staging_libdir * Finds target lib directory if for some reason STAGING_LIBDIR isn't set. do_configure_grub * Will search for a grub configuration passed via bootloader --configfile. If not found build a default one which searches for partition that contains the given the kernel name via grub search module. do_prepare_grub 1. Sets default values for GRUB_MKIMAGE_FORMAT_PC and GRUB_PREFIX_PATH. Both variables are required by grub-mkimage. * GRUB_MKIMAGE_FORMAT_PC used to define target platform. * GRUB_PREFIX_PATH used to define which directory grub config and modules are going to reside in. 2. Generates grub config to embed into core.img. This config is used to search for partition containing grub config. 3. Creates a custom core.img or grub stage 1.5 with an embedded grub config. 4. Copies all the target built grub modules into GRUB_PREFIX_PATH directory. 5. Creates boot partition do_install_grub 1. dd target platform specific boot.img to the first 0-440 sectors of the resulting wic image. dd grub stage 1 to wic image. 2. dd custom core.img (grub stage 1.5) with embedded configuration to the resulting wic image starting at sector 512 up to sizeof(core.img). 3. Both boot.img and core.img are required for legacy bios boot. See grub Wiki for more details on boot.img and core.img. https://en.wikipedia.org/wiki/GNU_GRUB Commit also imports python modules required by the above implemented functions. Signed-off-by: Vincent Davis Jr --- .../lib/wic/plugins/source/bootimg_pcbios.py | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index a4fabec0ae..f50a5ae0e2 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -13,7 +13,9 @@ import logging import os import re +import shutil +from glob import glob from wic import WicError from wic.engine import get_custom_config from wic.pluginbase import SourcePlugin @@ -72,6 +74,27 @@ class BootimgPcbiosPlugin(SourcePlugin): cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, kernel_dir, native_sysroot) + @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 + @classmethod def _get_bootloader_config(cls, bootloader, loader): custom_cfg = None @@ -243,3 +266,147 @@ class BootimgPcbiosPlugin(SourcePlugin): dd_cmd = "dd if=%s of=%s conv=notrunc" % (mbrfile, full_path) exec_cmd(dd_cmd, native_sysroot) + + @classmethod + def _do_configure_grub(cls, part, creator, cr_workdir): + hdddir = "%s/hdd" % cr_workdir + bootloader = creator.ks.bootloader + + grub_conf = cls._get_bootloader_config(bootloader, 'grub') + + grub_prefix_path = get_bitbake_var('GRUB_PREFIX_PATH') + if not grub_prefix_path: + grub_prefix_path = '/boot/grub' + + grub_path = "%s/%s" %(hdddir, grub_prefix_path) + install_cmd = "install -d %s" % grub_path + exec_cmd(install_cmd) + + if not grub_conf: + # Set a default timeout if none specified to avoid + # 'None' being the value placed within the configuration + # file. + if not bootloader.timeout: + bootloader.timeout = 500 + + # Set a default kernel params string if none specified + # to avoid 'None' being the value placed within the + # configuration file. + if not bootloader.append: + bootloader.append = "rootwait rootfstype=%s " % (part.fstype) + bootloader.append += "console=ttyS0,115200 console=tty0" + + kernel = "/boot/" + get_bitbake_var("KERNEL_IMAGETYPE") + + grub_conf = 'serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n' + grub_conf += 'set gfxmode=auto\n' + grub_conf += 'set gfxpayload=keep\n\n' + grub_conf += 'set default=0\n\n' + grub_conf += '# Boot automatically after %d secs.\n' % (bootloader.timeout) + grub_conf += 'set timeout=%d\n\n' % (bootloader.timeout) + grub_conf += 'menuentry \'default\' {\n' + grub_conf += '\tsearch --no-floppy --set=root --file %s\n' % (kernel) + grub_conf += '\tprobe --set partuuid --part-uuid ($root)\n' + grub_conf += '\tlinux %s root=PARTUUID=$partuuid %s\n}\n' % \ + (kernel, bootloader.append) + + logger.debug("Writing grub config %s/grub.cfg", grub_path) + cfg = open("%s/grub.cfg" % grub_path, "w") + cfg.write(grub_conf) + cfg.close() + + @classmethod + def _do_prepare_grub(cls, part, cr_workdir, oe_builddir, + kernel_dir, rootfs_dir, native_sysroot): + """ + 1. Generate embed.cfg that'll later be embedded into core.img. + So, that core.img knows where to search for grub.cfg. + 2. Generate core.img or grub stage 1.5. + 3. Copy modules into partition. + 4. Create partition rootfs file. + """ + + hdddir = "%s/hdd" % cr_workdir + + copy_types = [ '*.mod', '*.o', '*.lst' ] + + builtin_modules = 'boot linux ext2 fat serial part_msdos part_gpt \ + normal multiboot probe biosdisk msdospart configfile search loadenv test' + + staging_libdir = cls._get_staging_libdir() + + grub_format = get_bitbake_var('GRUB_MKIMAGE_FORMAT_PC') + if not grub_format: + grub_format = 'i386-pc' + + grub_prefix_path = get_bitbake_var('GRUB_PREFIX_PATH') + if not grub_prefix_path: + grub_prefix_path = '/boot/grub' + + grub_path = "%s/%s" %(hdddir, grub_prefix_path) + core_img = '%s/grub-bios-core.img' % (kernel_dir) + grub_mods_path = '%s/grub/%s' % (staging_libdir, grub_format) + + # Generate embedded grub config + embed_cfg_str = 'search.file %s/grub.cfg root\n' % (grub_prefix_path) + embed_cfg_str += 'set prefix=($root)%s\n' % (grub_prefix_path) + embed_cfg_str += 'configfile ($root)%s/grub.cfg\n' % (grub_prefix_path) + cfg = open('%s/embed.cfg' % (kernel_dir), 'w+') + cfg.write(embed_cfg_str) + cfg.close() + + # core.img doesn't get included into boot partition + # it's later dd onto the resulting wic image. + grub_mkimage = 'grub-mkimage \ + --prefix=%s \ + --format=%s \ + --config=%s/embed.cfg \ + --directory=%s \ + --output=%s %s' % \ + (grub_prefix_path, grub_format, kernel_dir, + grub_mods_path, core_img, builtin_modules) + exec_native_cmd(grub_mkimage, native_sysroot) + + # 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) + + # Create boot partition + logger.debug('Prepare partition using rootfs in %s', hdddir) + part.prepare_rootfs(cr_workdir, oe_builddir, hdddir, + native_sysroot, False) + + @classmethod + def _do_install_grub(cls, creator, kernel_dir, + native_sysroot, full_path): + core_img = '%s/grub-bios-core.img' % (kernel_dir) + + staging_libdir = cls._get_staging_libdir() + + grub_format = get_bitbake_var('GRUB_MKIMAGE_FORMAT_PC') + if not grub_format: + grub_format = 'i386-pc' + + boot_img = '%s/grub/%s/boot.img' % (staging_libdir, grub_format) + if not os.path.exists(boot_img): + raise WicError("Couldn't find %s. Did you include " + "do_image_wic[depends] += \"grub:do_populate_sysroot\" " + "in your image recipe" % boot_img) + + # Install boot.img or grub stage 1 + dd_cmd = "dd if=%s of=%s conv=notrunc bs=1 seek=0 count=440" % (boot_img, full_path) + exec_cmd(dd_cmd, native_sysroot) + + if creator.ptable_format == 'msdos': + # 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) + else: + raise WicError("Unsupported partition table: %s" % + creator.ptable_format) From patchwork Mon Aug 11 04:03:44 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: 68329 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 A822DC87FDA for ; Mon, 11 Aug 2025 04:06:23 +0000 (UTC) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by mx.groups.io with SMTP id smtpd.web11.40399.1754885177316373551 for ; Sun, 10 Aug 2025 21:06:17 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=EElNVvP2; spf=pass (domain: underview.tech, ip: 209.85.222.178, mailfrom: vince@underview.tech) Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7e81c336e10so459459085a.0 for ; Sun, 10 Aug 2025 21:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1754885176; x=1755489976; 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=UCUiwPzLRh225dVaSNXyhuL5liUwCz4JrYEbFEQf/6o=; b=EElNVvP2XnXpBdHTBbSjey5aXIWQeP2RvUWPamvpWMJRT3WYj0vUtHAZdzx0OInHw+ cgFJiB8qWEpcnEawq9VH3F0CFvmHvPjoPI4C+IamlNBuQ3dKsNJcmnm+lDn6QmXoLMru ap1VNddzpAH76JlMsD1FUBWln/fNLOFAXVmGVLz9V6E1uBWa8HTay6mpCPRYtqxIO1I4 jvsI7Bxk6spZUs2inQQ48nU63lM102lLDrrh15Hsb9OQmdGS0i60wHNrTrEP9FAa23UB 3JOQgcCeM5xclwWe1CNAo+y4Met2EfHJEKv/dUUYjaTSjNsOXZeBOtAQVngPirhNHEbf Q1Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754885176; x=1755489976; 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=UCUiwPzLRh225dVaSNXyhuL5liUwCz4JrYEbFEQf/6o=; b=cgbix3xQMNZDHxcpcYrPr+Ll98CkMBdrpEUAMKc6F3PP4ChwCPVsporBK1KPVg0I5l bOW1PSKmPP708cVjgR8PNHRwhYTORexAtOn0R/VKoH+3YKC5H4FICZXsmRWAmJgdB569 ylY6SseBmrkV/MKuF7Uzh8B2P5y0QrctMbz1DT7sA8xdKKo8SMkC5UdBhBSf5/9KuLSC mkRusnsYV5Tdgh2i9CyuORqZHpCvr3sLjZy7LAK5b9ilVaX2Mj5yrrq8juIeb+RZmvMH qCE1EC15d+nOzeLSz9U4u3qSszjc9/d0R4z9bCEsnqikRqazWk77QWwjEbVzBdxOu/V0 4CNw== X-Gm-Message-State: AOJu0YxkjnE4GFR4DX7eI3yMdTvT3qkErmtKaHp9B+FxA/HUd+9+WmNz W3Q+Cw1XYOhbsqY0ffVCXpOv86OphJvyQpWFXilB+fBvApkqqchiGLsNPO46YJZhxiun9PKQn+s sWOqy X-Gm-Gg: ASbGncu/3Ct8Uw88F0FsIr3uDo9lXqaPkRv7FirQ5qx1K9JZaMLLXFWNE5yFHvYOElT xdQ48u+PH5xab4sfV/IV9PdhYAs5xU/a9NOYx8BKVRuQhfsKEN/+WdFYvoASuhtT+kbOr3A0whf 4X6FbnZgGEII4pkV+S6hp4TZ8X5usZjTPLrn5rZ+VRRtTs6rPc3tXExV+aTCTMxDvp2Tq+r6rrV jA6rSYaEVZMVY9voea2isyTwGcFqr4vsB9qhJehf1YJ5a6d3KK+DvNNWWkvA92IYptG4Daac5g/ 6pOvRxbi9qFAI+souQkOPrVNWJT5/HzTUbHErZ89muBSsyQlOZLfkyufoBPLXJ67QgyGWHDf4K+ cyDXnb0pPDRo= X-Google-Smtp-Source: AGHT+IFs3MuXoX/4WSwMyCc+jmPq8iJNYlbVNwngXxZiD62DRfh59AdG5kJtnjuX9BMEA2XUWuNwNw== X-Received: by 2002:a05:620a:4548:b0:7e8:3eb5:4cd with SMTP id af79cd13be357-7e83eb50666mr977545585a.33.1754885175997; Sun, 10 Aug 2025 21:06:15 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::6d26]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e823fddc10sm597842685a.16.2025.08.10.21.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 21:06:15 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v7 7/9] bootimg_pcbios: include grub as an optional bootloader Date: Mon, 11 Aug 2025 00:03:44 -0400 Message-ID: <20250811040339.857858-14-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811040339.857858-2-vince@underview.tech> References: <20250811040339.857858-2-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 ; Mon, 11 Aug 2025 04:06:23 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221714 Commit adds in support for booting using newly added grub functions. Due to the bootimg_biosplusefi source_params['loader'] had to be named source_params['loader-bios'] so not to create conflict in the wics plugin. Commits also adds ability to set and or not set source_params. If source_params set check for both * syslinux * grub if not set default to using syslinux as bootloader. Signed-off-by: Vincent Davis Jr --- .../lib/wic/plugins/source/bootimg_pcbios.py | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index f50a5ae0e2..1fa9d895bb 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -31,6 +31,9 @@ class BootimgPcbiosPlugin(SourcePlugin): name = 'bootimg_pcbios' + # Variable required for do_install_disk + loader = '' + @classmethod def _get_bootimg_dir(cls, bootimg_dir, dirname): """ @@ -56,23 +59,50 @@ class BootimgPcbiosPlugin(SourcePlugin): logger.debug("Installing MBR on disk %s as %s with size %s bytes", disk_name, full_path, disk.min_size) - cls._do_install_syslinux(creator, bootimg_dir, + if cls.loader == 'grub': + cls._do_install_grub(creator, kernel_dir, + native_sysroot, full_path) + elif cls.loader == 'syslinux': + cls._do_install_syslinux(creator, bootimg_dir, native_sysroot, full_path) + else: + raise WicError("boot loader some how not specified check do_prepare_partition") @classmethod def do_configure_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): - - cls._do_configure_syslinux(part, creator, cr_workdir) + try: + if source_params['loader-bios'] == 'grub': + cls._do_configure_grub(part, creator, cr_workdir) + elif source_params['loader-bios'] == 'syslinux': + cls._do_configure_syslinux(part, creator, cr_workdir) + else: + raise WicError("unrecognized bootimg_pcbios loader: %s" % source_params['loader-bios']) + except KeyError: + cls._do_configure_syslinux(part, creator, cr_workdir) @classmethod def do_prepare_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, native_sysroot): - - cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, - kernel_dir, native_sysroot) + try: + if source_params['loader-bios'] == 'grub': + cls._do_prepare_grub(part, cr_workdir, oe_builddir, + kernel_dir, rootfs_dir, native_sysroot) + elif source_params['loader-bios'] == 'syslinux': + cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + kernel_dir, native_sysroot) + else: + raise WicError("unrecognized bootimg_pcbios loader: %s" % source_params['loader-bios']) + + # Required by do_install_disk + cls.loader = source_params['loader-bios'] + except KeyError: + # Required by do_install_disk + cls.loader = 'syslinux' + cls._do_prepare_syslinux(part, cr_workdir, bootimg_dir, + kernel_dir, native_sysroot) @classmethod def _get_staging_libdir(cls): From patchwork Mon Aug 11 04:03:46 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: 68330 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 A7C20C87FDA for ; Mon, 11 Aug 2025 04:06:33 +0000 (UTC) Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by mx.groups.io with SMTP id smtpd.web10.40652.1754885192754209223 for ; Sun, 10 Aug 2025 21:06:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=TEuiFcD7; spf=pass (domain: underview.tech, ip: 209.85.222.170, mailfrom: vince@underview.tech) Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-7e80ba947cfso402197285a.0 for ; Sun, 10 Aug 2025 21:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1754885191; x=1755489991; 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=1kfSNVxnvqGWkvUTV1AsKCIm9rTbTCgDhEND2ysqh+c=; b=TEuiFcD7n0k8tA0QWqC27KtnahraQToHlvaPSVZRID5/v//Nm3tHpLxANFMjUVVE/l 9uDwPjbQc9VVmfrN1CGBrbiQr1gDvYA0Y3aO7jWkLxB3d5j+a49DjDwsWfXqqfOEqsKg 0MRk+rHrVrQXacCGktTm3iHP9U1OlY8iJV51b3Gejee7myO0JAGpAG2ANH6XnZrikJPQ c5Ks/jpPSiHXYV3XbdzZ3MQpObfMghzEhIzUlF0GUi9vEX/YvYuyQ9nQrLWKuPhthOUF 1p4aTxqfPtmvzjQbfilZhQwNXTLyrayajZ9iGiP771hcto6vp3rhKJnSZ1ppH3SDTP4z h1oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754885191; x=1755489991; 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=1kfSNVxnvqGWkvUTV1AsKCIm9rTbTCgDhEND2ysqh+c=; b=vQNoEQJirvzvrp3lQZPSsKmumdho3cU7EeHFhpG40ojju4BjiAx1Rm540NZvfyV0o/ pwLfBmTlr7eCC5pH4hh6stzcSsTeCg0aEDv5liIMYVIj34+4cEbSDzi5XyorlxnE+Zp0 oBCJvr0iO/GOrXApE/aYl9Q7oB2hk9m0pS9aeXO3HX9Y7N7YGBri2kk49vv489j6Xfjw x3wLIqvn2e/x+6I/QrgQ3o7nm/YBZuhrURUqNc8mDuFqJW0eovCPghlE9TkfaBvUdElN qlVsTvMGrUYDGZ2cSSUBPZwhJlZuDQ5/Fhj3D2Y3XkKNK2Qu0tSETV4JzJCiHEtcmCuZ +FpA== X-Gm-Message-State: AOJu0YwZLH92ngyAXcxtSS845r362x66shwFhfa9WFmQ/rtdPD1Gvg29 NTl+lURocA79ykX3hvEOiWl0NfNNfwi1+tWPMazP6/dkS5E2STgz7KuhU6n8ItCgmrQuvv0EDiY Qd0ks X-Gm-Gg: ASbGncsIAD7KiWzDE11rktdJyvpTs+6nQLHUhMv5wCE2G1+b6L/0V+td6WCIisBjO30 329SNxxBTERY7EJsWmaxgTXwu7t+NfsZqB6rDRfOkAocN5o+4snFR+bhvWT6OIvgA0zYj9eUN1p kheAdbL2Gx1//ZyKn6I/11VXMYnIAlNTZ3PSj3snQPm4SBS0Qcfd0bzaboPomz+S9R8rk9h8BXu cUI4O8jWti8Y6BKuEm/2LeWD8cnMsr4qVwfsmkdNwidVe+xhKDk4EZPCD6yEG24ra7N1gsNV/US zXx+A5X8C1YIActFXjWVXnwZ+4WE3coXH+O1XT252fKWPpCDBEersM/jwo9Nwck0bVctH6sgq5g V3avJEMhEuog= X-Google-Smtp-Source: AGHT+IHjqHLQ02P/t/vyYxkkMg9zB3PNz9q+c8z7b0poOdmtOOmTVv0s4G30kmYFVPDwlFRfzImTgQ== X-Received: by 2002:a05:620a:4105:b0:7e7:12c1:8f93 with SMTP id af79cd13be357-7e82c7c96cemr1763085085a.63.1754885191241; Sun, 10 Aug 2025 21:06:31 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::6d26]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e823fddc10sm597842685a.16.2025.08.10.21.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 21:06:30 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v7 8/9] bootimg_pcbios: add help and usage comments Date: Mon, 11 Aug 2025 00:03:46 -0400 Message-ID: <20250811040339.857858-16-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811040339.857858-2-vince@underview.tech> References: <20250811040339.857858-2-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 ; Mon, 11 Aug 2025 04:06:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221715 Adds comments underneath class declaration defining plugin usage and potential optional variables to set. Signed-off-by: Vincent Davis Jr --- .../lib/wic/plugins/source/bootimg_pcbios.py | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index 1fa9d895bb..caabda6318 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -26,7 +26,48 @@ logger = logging.getLogger('wic') class BootimgPcbiosPlugin(SourcePlugin): """ - Create MBR boot partition and install syslinux on it. + Creates boot partition that is legacy BIOS firmare bootable with + MBR/MSDOS as partition table format. Plugin will install caller + selected bootloader directly to resulting wic image. + + Supported Bootloaders: + * syslinux (default) + * grub + + ****************** Wic Plugin Depends/Vars ****************** + WKS_FILE_DEPENDS = "grub-native grub" + WKS_FILE_DEPENDS = "syslinux-native syslinux" + + # Optional variables + # GRUB_MKIMAGE_FORMAT_PC - Used to define target platform. + # GRUB_PREFIX_PATH - Used to define which directory + # grub config and modules are going + # to reside in. + GRUB_PREFIX_PATH = '/boot/grub2' # Default: /boot/grub + GRUB_MKIMAGE_FORMAT_PC = 'i386-pc' # Default: i386-pc + + WICVARS:append = "\ + GRUB_PREFIX_PATH \ + GRUB_MKIMAGE_FORMAT_PC \ + " + ****************** Wic Plugin Depends/Vars ****************** + + + **************** Example kickstart Legacy Bios Grub Boot **************** + part boot --label bios_boot --fstype ext4 --offset 1024 --fixed-size 78M + --source bootimg_pcbios --sourceparams="loader-bios=grub" --active + + part roots --label rootfs --fstype ext4 --source rootfs --use-uuid + bootloader --ptable msdos --source bootimg_pcbios + **************** Example kickstart Legacy Bios Grub Boot **************** + + + *************** Example kickstart Legacy Bios Syslinux Boot **************** + part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" + --ondisk sda --label boot --fstype vfat --align 1024 --active + + part roots --label rootfs --fstype ext4 --source rootfs --use-uuid + bootloader --ptable msdos --source bootimg_pcbios """ name = 'bootimg_pcbios' From patchwork Mon Aug 11 04:03:48 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: 68331 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 A7FA5C87FD2 for ; Mon, 11 Aug 2025 04:06:53 +0000 (UTC) Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by mx.groups.io with SMTP id smtpd.web10.40656.1754885206186167327 for ; Sun, 10 Aug 2025 21:06:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=F6VPjvrd; spf=pass (domain: underview.tech, ip: 209.85.160.179, mailfrom: vince@underview.tech) Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-4af156685e2so62829571cf.1 for ; Sun, 10 Aug 2025 21:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1754885205; x=1755490005; 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=bGLy1iMR67fvn+6SuMga8KLU1s1FK38i/nCe0V5V9Y8=; b=F6VPjvrd7n0SrzkRHWWyN2eOzRNdtQfpshI8DXSPMJfepc68wmukoQDr9jR1D7OrfP Ua8gLIFfVV+nCfIDuPVPiHA1mfl+aTgEEd/PlrYXKNz3J6hVblZK/ejR4y/NuIYaVnVG maQzxQILYbSFqkvtZFtm8Ljnv4z4ZIhe6C9FPARDS7l9t6RrsXsml+SyjyqXbQVxCPvF Dh+dFqbNN82SCr8DQZ32993DO4bprdPl5mP7BX8lWrJYbbIVRFuIvkc+RmMNRssQq/vF f9AS9x2UuGKsBam2dkcYtlGOIO0r/QJDiIZr5lOUieiWSRWtDSpRXSiBorBu2HaTs9F9 5arw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754885205; x=1755490005; 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=bGLy1iMR67fvn+6SuMga8KLU1s1FK38i/nCe0V5V9Y8=; b=LdtogLOUcGQCkzBT5yDkunWzA1ra5iMCa1e7hBC7cGGMAGV9ZhO2yZGaDfdE/Wsxsp ZZyY9UR9ghKmpxnaNtE8nkfjvZoiCmo4lGih6K7O9EpuDjYiq+oozmVJUtyj+7VRLFYG 2jRc48kglPVr0+1Y80UsdH+dD28eaQr2RfYU+MRBT/I9fv7cK/N6yMmY75iILXr3EHs6 msCvxJwYn6arSIitYxO4K3NVDPEMjE60d0rENddgVvEljNUFsCWwAoQOtKPQeEdUG0NK NVThGUkmq0aJ83g0jdKwblTZhoGdx1cu0xHvhqBBZXVl2aL/1mDNoDMiqUGhGJLXt5UE WBqA== X-Gm-Message-State: AOJu0YzfVn4rHGnHwZ1cVVAfvmCB1cswHmkhg7BjwXjYI8/vSnttZ3My AgYfM32JnoNcITrKlLO4XZrWtpNIDySpuhm9Ya4qvGYZHu4zLpzjmdagcPJKQ5qrspib4LMC+ua C4pGu X-Gm-Gg: ASbGncs4kWvoFJ8gNss1K+mtk8RSRA1sP1Eg8sN5cCD1Mq4hRQDpI0uIa4FikqHK6Hk 4mZ1Ca23wXQw/8Yu8eG7QJGml0Wr5X/yAqzhb6PaWi3y9HQWKEQaFtGa7IhrpbAF7SVHjCRdpuS y7qH31MVuesea6SE8mmKyaavYUSzc9Eo1CneUQ3MVuGZdjFOcS6qgy33DnhxJQweS3GpRLXzbl1 XPgL4hyjfhLZ0VvNg45LsmB0VJOGuOtWNt4N1Q8KzLdqag5xpq9+Qe37P8/x6mUa31xdPHKzlDk ejKxNHdQhra/HFI8nIqGby41XYuzlGGs+frAKTtWygwWmrmgUxbpcy35wrDZt8jsHm/a2ParYLJ V5+lTn5NWU3A= X-Google-Smtp-Source: AGHT+IE9yVdxrraFCgJFh5E+fyb57DovTyWXdXorAcvRT6llc3CCUx8yAwnoAbVF6dqrTm6izHyYvg== X-Received: by 2002:a05:620a:2994:b0:7e7:fba9:4a79 with SMTP id af79cd13be357-7e81ffd7e54mr1978557085a.29.1754885204618; Sun, 10 Aug 2025 21:06:44 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::6d26]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e823fddc10sm597842685a.16.2025.08.10.21.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 21:06:44 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v7 9/9] oe-selftest: add wic.Wic.test_grub_install_pcbios Date: Mon, 11 Aug 2025 00:03:48 -0400 Message-ID: <20250811040339.857858-18-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811040339.857858-2-vince@underview.tech> References: <20250811040339.857858-2-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 ; Mon, 11 Aug 2025 04:06:53 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221716 wic.Wic.test_grub_install_pcbios test Test updates to the bootimg_pcbios plugin that enables support for installing grub directly to the resulting wic image. The test checks to see if the wics plugin generates a wic image. Then see's if normal.mod and grub.cfg are located in the boot partition. Signed-off-by: Vincent Davis Jr --- meta/lib/oeqa/selftest/cases/wic.py | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index 680f99d381..44442e402d 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -215,6 +215,47 @@ class Wic(WicTestCase): found, "The kernel image '{}' was not found in the boot partition".format(kimgtype) ) + @skipIfNotArch(['x86_64']) + def test_grub_install_pcbios(self): + """ + Test the installation of the grub modules + config + into the boot directory in the resulting wic image. + """ + + # create a temporary file for the WKS content + with NamedTemporaryFile("w", suffix=".wks") as wks: + wks.write( + 'part --source bootimg_pcbios --sourceparams="loader-bios=grub" ' + '--offset 1024 --fixed-size 78M --label boot --active\n' + 'bootloader --ptable msdos --source bootimg_pcbios\n' + ) + wks.flush() + # create a temporary directory to extract the disk image to + with TemporaryDirectory() as tmpdir: + img = "core-image-minimal" + config = 'DEPENDS:pn-%s += "grub-native grub"' % (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.cfg is installed + result = runCmd("wic ls %s:1/boot/grub -n %s" % (out[0], sysroot)) + self.assertIn('grub', result.output) + + # Check if normal.mod is installed + result = runCmd("wic ls %s:1/boot/grub/i386-pc -n %s" % (out[0], sysroot)) + self.assertIn('normal', result.output) + def test_build_image_name(self): """Test wic create wictestdisk --image-name=core-image-minimal""" cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir