From patchwork Thu Aug 14 04:25: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: 68493 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 C61FDCA0EDC for ; Thu, 14 Aug 2025 04:25:59 +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.15466.1755145558480650395 for ; Wed, 13 Aug 2025 21:25:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=JO2dEO0p; 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-70a88ddb1a2so6438286d6.0 for ; Wed, 13 Aug 2025 21:25:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1755145557; x=1755750357; 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=tP9J796JFWiAJbWiRJ9fxIQtNdlshPEiVGR7i1hl5kg=; b=JO2dEO0pukVD4uTzpY+/KclcgKq7p+VPsZ3HxO1vS/6Q1PZri3PYP5o8LG52B0xt0g kTDsgBtFZvKT/1ruFyofaQPn0jPVgkRuPrm5qOp84gCtKlf9v+3HEq6w5MT+7xAjp1ij uetMZ6G7I7IM/jHlYL8IvbMpK2to5xJk4wgkrnqxMOZAdkAKwb7a4oiN2G4G2q2BJxNs 73Aq1tgkE+QXLu3fMFKDnSg9iOsBa85sJ/zyV0sPqzcf3AFyPKoFiIOxr9mywNm09Yty XlwqIHR8+Du25WBGG6Dp0Iia58b7P20GkMO8y6sCGw0DQDCENPeuVuFOLO22LAi5QO/y 19vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755145557; x=1755750357; 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=tP9J796JFWiAJbWiRJ9fxIQtNdlshPEiVGR7i1hl5kg=; b=J9dCzVDXsc6z2Wm7t0Yxq9gJx1craFRpImP6GzVgoIV0oN/j9SlqiWRANURU/8M1JG Ih5bD3D0QhEgwz6obDlu7+sFQJv0qdFgwxsHZoKENz0HuHxdiOdpd176acE7QDFbzITp z5y+JTlrCNVSYH68TAR6hCsBmRGITgfbTO8eAbuo8n040mR2f5EBdRUe/2C15CwWGRLk LX1ZPyu/vuovAXNYWCI0Ls+e132maZ+LyUJm9fKWwQNYC6x11xfJ3vx+/GGUqPpgLk4u fDc/C9nt1gOCfQy9abvJL4Xba8IHcfV5twC/SZ/kuy8lp/BOnqGVyhgQ/D4mYUheCKkr LUNw== X-Gm-Message-State: AOJu0YxzOGnyEDMhD+BBVuSPe9WQmUvoH28PqJIg5hDrflEfgx37CF3Z iqT4tlgRWGA6EgNCRokPtkVlCU9aXkbr+Mo/rHPIsvv3lXne61JQ4E3x8VIcvJ2eCj4kQo73/kj nisg6ztg= X-Gm-Gg: ASbGncuSbJ4M+qaZ0CHXv07sGOytXIPwIXSyjGdK2E1IIt4OUAjOoQFCqWgrjlI+X6q VbWJOoOqwv3lMAT27YYADomnGAfRqFprMBIUSiu+GRp/f/aDYeYVFPPUJLgjGk7cFyqHWZn44uj IsVDI705Gu3FhfX7fkzpRbDKzB6Udm/cpoMNQrY5f+wA0dnc14rZVFfDJrYCRDIyA0CY3eFYSxs chm8A9U/XHXNLtOzJ9DvX//rgyUNrznfTb1n3YOycq5dAz+1Kv67HiuojMM35jPRDYFQQ0fjoic eUIUbCtnExhB2XyAH5AFx6Gw3koz9OG0QD4oOqFLHuJD2R8jvB/2eOTYIqtDbFE5Bu72UyNjjcR BfvqIWLAfEsiaF1+uQEpMSDxJptU6yod3rN8+FzN7nOA5rw== X-Google-Smtp-Source: AGHT+IGxDXPJ/ccIL1V6a77DlnZPbwM/w2PsG5IxWYykTVBxBnUGaHm5JoNmGxOEwwf993Kiwts9Og== X-Received: by 2002:a05:6214:1d23:b0:707:5046:6a1e with SMTP id 6a1803df08f44-70b9821b51amr18220106d6.10.1755145556982; Wed, 13 Aug 2025 21:25:56 -0700 (PDT) Received: from vince-B550I-AORUS-PRO-AX.. ([2601:406:4d01:1820:e358:dd1a:4ea0:986c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-70ae6cb6cc2sm8322816d6.22.2025.08.13.21.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 21:25:56 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v8 1/9] bootimg_pcbios: move syslinux install into seperate functions Date: Thu, 14 Aug 2025 00:25:44 -0400 Message-Id: <20250814042552.21887-1-vince@underview.tech> X-Mailer: git-send-email 2.34.1 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 ; Thu, 14 Aug 2025 04:25:59 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221841 Current oe-core bootimg_pcbios wics plugin only supports installing syslinux directly into the resulting wic image. This commit seperates syslinux installation from class BootimgPcbiosPlugin(SourcePlugin) override functions in preparation of supporting the installation of other bootloaders to the resulting 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 Thu Aug 14 04:25:45 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: 68495 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 A53CECA0EE4 for ; Thu, 14 Aug 2025 04:26:09 +0000 (UTC) Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) by mx.groups.io with SMTP id smtpd.web10.15470.1755145563793218788 for ; Wed, 13 Aug 2025 21:26:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=L0B9OD3d; spf=pass (domain: underview.tech, ip: 209.85.219.48, mailfrom: vince@underview.tech) Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-70a928c3686so6210486d6.1 for ; Wed, 13 Aug 2025 21:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1755145562; x=1755750362; 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=mYCpoc5ZHK0fiFKtUpyU4evEUZ0uoQzt0H4G8S1+1ZE=; b=L0B9OD3dbK9rAAw6uofgmpV4Sd/bif+HA2Tnah5Q6oHFHRAlDfNTTWWd4XGnNpBJQi M8OC/pBRevWO91ct2MOIxmjZJukqoz+oi2l2pTx4iKqHcOsAhMNIIP8qIZD0sudxTHZe 6tGuJvNlEmscnpFbPAjYe/UrtJybCnwvpzLRZpYeP+043M2s2kpkKbzpREX3CrVusdCZ ytXNJ5ZaG5E+9MeocIwa1ZUq0Ml5UBRWdq6KHjBkhwFXbXhmwe9PeRMcUqRhoztnv76g iqBQ0zB+xf/Qcj8aox1+Ev+7ItYuQSdH6Aw2rYoktnF4t34w90yPpG3G/JtsA2OkOB5Y 9yRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755145562; x=1755750362; 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=mYCpoc5ZHK0fiFKtUpyU4evEUZ0uoQzt0H4G8S1+1ZE=; b=hSjfglyKHcQRhzDZHFIio79qoMVwfBDFXv3PBqgds/brueFNCrwmuTLLGmbckBptl+ sTWFo6ArXDgGdcwSVUF7l5SbcOknxobrhHcs7VIENyUinPEso5V3tnXoSBk1IqXFyHiU ZgzEsqIf6di9ORP5S8pQmYXm00vUnHX5e5vvw2lhGMHpHnTII8w6le2v6dfDv637pWdB j29CNWMyQjogLGuYDHuu1XhNPdUSVQ1DdZmI7NH9qLN/B70DSAzQcTQZqzUSztGfNTRo pFhdiaUXcyTCR+mUZtsGUqUDZLsG/9zeGjIOSGt0o8HXg9sSj4urPt9570Igos9HVti/ X87Q== X-Gm-Message-State: AOJu0Yx7lvY9yrpk8o+vmIlsTT18Bwtfv6ayOBxII5KlOl8NbANOoL0t HfwqWCYbJwKVdraYmbOBuKHGavWQcviTKx2nWsJEFgZucXbWnu43n00N/hpVXJdgeU3PPjTmzUc EHJDyfnM= X-Gm-Gg: ASbGnctpt7MCOczQRF+caI1mvjUN6NJA0ojN4E9C6aV4295fhb1z7Y/Qa1n9pLOWfP7 k82PljWR70W6XUXShs8iirzmbFBwD4xr5QsXjF4YzX1UF7bRot7cS9j051Cf2o/jbNMtT6GpMJI 6jTMlzM96hlBExfiz3FViz529BmNSOgLXJOn++wxkF5HCu6zK1ncVWzZFLa7vGWCd2bR0IHXzWA ce8RF34S3f3M5bKW4+5SdnzXCBKTx50GtAnQA+VfXgiW4nBcx60leNL+AnnkAPgk28nVZPLy9wJ 1STZs7Oq2ZCfAzTve27j4qsGFZ94tKW+6HkOJEDw8DRMduzVpmgQ/37nbqQ+ggaUGCyZNwKH3fD hWd/s/Sj710+4bw8+qYQVWpN1FX0U68i3xblX0gN0Ie4NeQ== X-Google-Smtp-Source: AGHT+IHgq1spTn/aN9tNBqU15iIy/M0buRZA8Pq3jCkJMupB+APqmuu/bgtP5t1UZIixW7v1mpJh7A== X-Received: by 2002:a05:6214:f2f:b0:707:255:6239 with SMTP id 6a1803df08f44-70b9830d7d0mr17492306d6.20.1755145561842; Wed, 13 Aug 2025 21:26:01 -0700 (PDT) Received: from vince-B550I-AORUS-PRO-AX.. ([2601:406:4d01:1820:e358:dd1a:4ea0:986c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-70ae6cb6cc2sm8322816d6.22.2025.08.13.21.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 21:26:01 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v8 2/9] bootimg_pcbios: move syslinux funcs to end of file Date: Thu, 14 Aug 2025 00:25:45 -0400 Message-Id: <20250814042552.21887-2-vince@underview.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250814042552.21887-1-vince@underview.tech> References: <20250814042552.21887-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 ; Thu, 14 Aug 2025 04:26:09 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221842 This commit moves the seperated syslinux creation functions from their 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 wics 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 Thu Aug 14 04:25: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: 68494 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 A2297CA0EDC for ; Thu, 14 Aug 2025 04:26:09 +0000 (UTC) Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) by mx.groups.io with SMTP id smtpd.web11.15407.1755145567883970657 for ; Wed, 13 Aug 2025 21:26:08 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=GP9GALVc; spf=pass (domain: underview.tech, ip: 209.85.219.48, mailfrom: vince@underview.tech) Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-70a928ad710so5558436d6.2 for ; Wed, 13 Aug 2025 21:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1755145566; x=1755750366; 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=fY2EWCWOrRqghnf+n2KE3YOARzOkxsT1AF2Fqu6fdiY=; b=GP9GALVcDTl50StKjhirexY/xt4aL36R4EuNTPmI4wcMsnTnDgn+iAIpGt1wQiRLle DYLMYo0LpWnAMQ6p0h629zafUy860Uc0zqz6pGV5Xnw4uFLvJhSceNI8EHSlGbaE3gBL VxOBkV8UItPjpMMS+fok83mqCqo/M2qv5XuaA8ygtWfNjtjqoKLZtj4VgXBMBF5SlexZ yj0HlaWDzZy5ckq4+xIErvFnb/f/9zO3pk3Ym2btQFVWIGZ6ATh59JHy8jaUgtbnTI0m SVyJOsAm3fusPAiC4Jgxdl64UjUL9Cv2Pn9zbpzqb2DTA41kdiBUO7nCQIQw6bwFwNEk F+MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755145566; x=1755750366; 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=fY2EWCWOrRqghnf+n2KE3YOARzOkxsT1AF2Fqu6fdiY=; b=ZQnC6LmVOmmAWDrXgdZb0PzuUlRcd7C9S/B/m0NDyCb5+kPL9NyguV8xxaI3heQqSw cARaAjbFAqZ/bu8un8lK4Ng7yCecAsLQi+ARg6VzhbxSfeAS25iyBPat4L7znqYtdeXM DlpEy3NgA0Kei5uoKo8O0d1T/QS4r84M+TtwwAFdJHpU/d3Lm8RkQ08vCoRqNpq6mlUR fatr1J8769uIrBVA+ypH7PCOv6D8QkXJQZ6QAnvZpvmIRFMpDrJQLK2am/SZ8+6SvMMu gCwZKtnTyRq9U361dPlGAxSXS7RZusB2MchcGVGs8Qv/n6HTSKb2qm4Qua4hsOBTu61q NP3w== X-Gm-Message-State: AOJu0YwjA5OHl01bb1jJZKHjnSyrF44DCzCZa3oMnajVbl4pd/dc3Ayz Tr+Z7Fa0V2xBqeI8x1HFFl1VyYJ+5IvMjyNkRdm4vheNBvekEE+60fSovR1w9zRr4Q44Z7QNaDS NlTPma64= X-Gm-Gg: ASbGncsGvyj5LkNqOtHxisHqZl4cI83kxjN3fpoeef9bz3/qoW1RIiwnT8hOWZbw4Ya 7izI4J4vFaKUFExohUFahO8KS69cTIoOsL/FzXkteT8UlsJ44k94Hxcmk1XOnf1U+L61PAPpD94 70QVbgGp1evQDd9C4+SOOpcXpTVhpmGcoplkq9tXW3zGHOnPWHUgjuv3DZDhAN/DfbjIvO04TSf AzSxQUXhDc64WgG7SsKMFHnAGVIuN4vERR9XgVos6TkgqOvSeJLivLtxIHhfgGJHsR7G4fgnhst 4CmfkOISnOBtJhhhAZjeqc7hZiVLZffch+sTJkkrk4daqCcuKx265iA9SZsbAJ8h2KbaqgEMCFP 99Viw8ky6DcO+yR8KD/R1gGLLABwejAoQXyeWnhE+UbljgQ== X-Google-Smtp-Source: AGHT+IHpfor4ZS7TvhMFwBuMlNJApfF9I7hSrgqiU2TyrisdyOK1/P4RRHKwB9trlFAkrC3Hd3M+1w== X-Received: by 2002:a05:6214:1bcc:b0:707:4c29:c53b with SMTP id 6a1803df08f44-70af5f4106bmr25392476d6.51.1755145566519; Wed, 13 Aug 2025 21:26:06 -0700 (PDT) Received: from vince-B550I-AORUS-PRO-AX.. ([2601:406:4d01:1820:e358:dd1a:4ea0:986c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-70ae6cb6cc2sm8322816d6.22.2025.08.13.21.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 21:26:06 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v8 3/9] bootimg_pcbios: seperate bootloader config creation Date: Thu, 14 Aug 2025 00:25:46 -0400 Message-Id: <20250814042552.21887-3-vince@underview.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250814042552.21887-1-vince@underview.tech> References: <20250814042552.21887-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 ; Thu, 14 Aug 2025 04:26:09 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221843 Most bootloaders that will be included in this wics plugin will require a configuration file to define kernel params, execute custom modules, or enable the ability to select one of multiple boot entries. 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 Thu Aug 14 04:25:47 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: 68496 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 A4C42CA0EE4 for ; Thu, 14 Aug 2025 04:26:19 +0000 (UTC) Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) by mx.groups.io with SMTP id smtpd.web10.15474.1755145570137090524 for ; Wed, 13 Aug 2025 21:26:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=B3xxinr7; spf=pass (domain: underview.tech, ip: 209.85.219.47, mailfrom: vince@underview.tech) Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-70a928133e1so5597226d6.1 for ; Wed, 13 Aug 2025 21:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1755145569; x=1755750369; 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=vYL3+SMxOfz7LJXvuqv95zUvs4DZCf9tVJZcvGNurJo=; b=B3xxinr7wQt+eATQf8v56x2eJ1EW8FwKW9t5oFKfr43yZc24w9q4rx2ihyhvtEWHUo ZafN/WQPDYTw4fR+r6wcbTSbgkyI1OKGC6bkh8W8rRN9R6kMoxpWG9zpTRNMJUj2M5wM u65yPRn5o6wV2/siN9ktmmcPo02MrudJ8KORv9U0CzSJK3t5l3QUgOSncUtgk8GJdhIo /d1AILikWeKFjaYNCnbfqz246Sn+sjQPAkGCwqjTwL8qwDY3Fg3bfEfaVDM/J7pd9qMV frUpouclQrAfwZIDrgEwsAS8TM1++uAX/Bpop7uwYJNfjgE/oK50RDtpsitWHYjwIsuG 3/fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755145569; x=1755750369; 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=vYL3+SMxOfz7LJXvuqv95zUvs4DZCf9tVJZcvGNurJo=; b=UIF6pAGf+taGIo4wJKfoWEsaS9noucbM4RCWHrw6QxhZapn5svbP6D2Z/BAab20UR6 cLOQXFMyN4OhuKa5azXkwa61nD0SZbTWoEzfEfdIpTbW5NgrPc3LmwHpIPyMr9FP5gTz 3PJvQr8/U0lt9KwdC+1KhsaPpUPGKfIR1YJ1BT80LxopEJyuJv+jzb8ZwakllqmPZImB FXX5uPs/kzMCMJlgc35z6d5yQE38eTJf2e4KdaFBkN0guh/IPQwSuuN9zRb5mESy/wGf dUv3FEJDrSYdDoVYhfT2l3R9dpJu1/TFYsm9RlV+Qz7KPX+wd8DaX3vimt2hKxYJBMA8 PN0A== X-Gm-Message-State: AOJu0YyTh2Qe6ln+OnSNaCg9wKoykLZzxbHyBZAHuqLocALLU22o7kGU Gx2wsobsifwhTMadJBlRtpFG3Hf9aMppyiTWCsQt3bgJNuzDOdhbjCRMoYMRlMIrByQrbhCN1Tm yWm00TVg= X-Gm-Gg: ASbGncvF2Rs7+OreXPi9+nwu30TppLbPHVWc6+ul+bUGre1nMKGo6KjbXnZepN7KfjQ SNCH4bkOq/qIeur1NM2a3wLbAMSzsrUcbyoUeLoxPBhnzaMMdrWJ+Hphj4R3BE8pgUSHfIGBTNE rgZ452zxSR8ZiB/LZXZ1AffOcIwKlb+jYZxvZdn1WU+AuxE5L2zXxs+hQoRMDfHNbHjyb66V9a3 s+QAaMtWeZJAFKKWyFuOhxPh8TkSAMEyhs8FP9jVXCt66zei3ni5BSlExQkjLzTIcPojeJ/OLnX 6x+NEmTzmeXfTpBAwiVnHtiLVme5mgFekWTHL1ZyGwONjAxuZ4cXm9SJTgq1mLiytiNpaLNtsXB duDLIo2VW5oY1F/tRlZRJgbLDJa3KkTqPK/sg5R58psK5Kg== X-Google-Smtp-Source: AGHT+IEhqjBhnZoPmx74JyPCxRvT16xuAEqpXJgmGcfGsps6zNYnxXr9qq6UWGE97H0V6lFCUddaqA== X-Received: by 2002:ad4:5aa9:0:b0:702:b805:276b with SMTP id 6a1803df08f44-70ae6f6f80amr27253076d6.20.1755145568803; Wed, 13 Aug 2025 21:26:08 -0700 (PDT) Received: from vince-B550I-AORUS-PRO-AX.. ([2601:406:4d01:1820:e358:dd1a:4ea0:986c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-70ae6cb6cc2sm8322816d6.22.2025.08.13.21.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 21:26:08 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v8 4/9] bootimg_pcbios: cleanup _do_configure_syslinux function Date: Thu, 14 Aug 2025 00:25:47 -0400 Message-Id: <20250814042552.21887-4-vince@underview.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250814042552.21887-1-vince@underview.tech> References: <20250814042552.21887-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 ; Thu, 14 Aug 2025 04:26:19 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221844 This 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 the 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 the 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 Thu Aug 14 04:25: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: 68497 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 A40F7CA0EDC for ; Thu, 14 Aug 2025 04:26:19 +0000 (UTC) Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by mx.groups.io with SMTP id smtpd.web10.15476.1755145571717625721 for ; Wed, 13 Aug 2025 21:26:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=fzUl/nWM; spf=pass (domain: underview.tech, ip: 209.85.219.50, mailfrom: vince@underview.tech) Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-70a9f5509f5so5419736d6.3 for ; Wed, 13 Aug 2025 21:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1755145570; x=1755750370; 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=YBKRFSS370kTonC5vGdeLwS/U+ATyMsp7AFQ6ttUiLI=; b=fzUl/nWMU8F2qb6bNrSiR6vb4odj0GfoUxyVdj3jJ+eQl95yH0RG3ofxa2zq8U8iZ3 XqTmoI4sk0Z+45NGhJ5Ck8xI6uS5snEbf2s4yA1wqIAG7KtAv+umVDraE6YCVfX93hIh nq62/ZJv0O1F0ArVXjCs6HbDS32gnBMFEIoixx8SLq+uVJsVpbEc6ynxKDL0hfGVYGO1 sQ0A21qykBbIc3QIMYf90TWetCS0ecZnjkuEnf8Cf0vYrVAlafAYLKlOe/npvPIjBC9z SxTrvIsnBNAA3pNVue9CfJQ4jmOcinyjqtW0nnMgDIBi+8NcwJsMtJiARbJP+mZwmJS/ rnqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755145570; x=1755750370; 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=YBKRFSS370kTonC5vGdeLwS/U+ATyMsp7AFQ6ttUiLI=; b=pNf9sbXI0VWHHE4wxKP+C23wAmnLa/AGe9GUuQoLicNGFdhZZfzPE6Aq8u/BMbNO3l iijkhiOfHRpHpEDnuq5Usox5OxNNE0LACnatgfw4dOQ6poeZS0nbcJ+ywdaqahdoUNZ2 meEkbNmicw6hqwEfb4ZivF4P7B/r0n3Ey0hUTzAWYzUwQRJ4UrQG4vVtOvo9H64lrPkL 1I6EMj4A8dPnSCXcrxvIO3NGg2RYpTdA0NDcERqur/TfwcnNf4vgzK+py95LKQib+ZwZ ld8U8+zyZ57nj8vSJgErF7uY0jQmMb9Z1FVGdfRxj/7yYD+7Xmggt00oKy5XL+p1CIc0 CM+Q== X-Gm-Message-State: AOJu0Yyvj2rOLFaEW7DIiNQM1QBpepMuYZB6GTfUJYT/fL5Kh/R2cQLy 015AJ6zsmK5mRmWfObsR+vqb3yYCpYQWqaUZOkd+EmxGAs9bN6JVUzWS48DmxebJtzEB785k4aU TlU0sjvQ= X-Gm-Gg: ASbGnctP0HQy5Gsge/Xz0KZVjU5I8EL+Aq2p/RZcy2l8IMfj3LIgZPB3aCkE/kdJtmK oncUzQVoWoLItb7a0rscm0R9JljxPL4hnrCJ4iCKUiVHaXU77r8KGQlJyXPD2vHCd4vYTsBZDjD PLRPGboBv2mqRb07DQAeIUTNQhx0TVL2C47IJoflTxCgEKoALb3eD7RWpjq+VNEZsvPIzyziZmj LYjzgcBdfuQz07XLF/SI2bbIlwdI4lpL80M0V29zpwtXC6WApyI2gRO+v9m/QKHiZhlyBLQhFmk IKyeyZDprhl8/kx7ZuSvIRjQKCHVFc0muaMxkYUdnBTReTz409xfw0FLrI0tTqkKaopF6VCq23G nlPYj0GoV99D4KL0ALeGp42Qh2gCWTe6bPmMIwXh2v8YOgw== X-Google-Smtp-Source: AGHT+IHFhVpG1s3vkLRNeYpOrhrwRr3ozWotcjDu6XYXYzOLEPA4RyR7oyvWaHQlJsShSzJP6kbLWw== X-Received: by 2002:a05:6214:493:b0:707:4229:6e8c with SMTP id 6a1803df08f44-70af5b93968mr29525716d6.12.1755145570462; Wed, 13 Aug 2025 21:26:10 -0700 (PDT) Received: from vince-B550I-AORUS-PRO-AX.. ([2601:406:4d01:1820:e358:dd1a:4ea0:986c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-70ae6cb6cc2sm8322816d6.22.2025.08.13.21.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 21:26:10 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v8 5/9] bootimg_pcbios: cleanup prepare and install syslinux funcs Date: Thu, 14 Aug 2025 00:25:48 -0400 Message-Id: <20250814042552.21887-5-vince@underview.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250814042552.21887-1-vince@underview.tech> References: <20250814042552.21887-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 ; Thu, 14 Aug 2025 04:26:19 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221845 This 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 Thu Aug 14 04:25:49 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: 68500 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 B355CCA0EE6 for ; Thu, 14 Aug 2025 04:26:19 +0000 (UTC) Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by mx.groups.io with SMTP id smtpd.web10.15477.1755145573672869345 for ; Wed, 13 Aug 2025 21:26:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=FqR3NSW3; spf=pass (domain: underview.tech, ip: 209.85.219.49, mailfrom: vince@underview.tech) Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-70a88db0bd8so6104096d6.0 for ; Wed, 13 Aug 2025 21:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1755145572; x=1755750372; 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=E53GO5l3Hd8eM4ap4AumPBduB+XTyY1FxcPASVl0VY4=; b=FqR3NSW3z9ppcDEKpRX3WtIO6ANrcU/fdLZ3XLRmT8D78WUW0T8VXEPx3ASXh/up2d gwsRvZ9Ahj7OAQy0mtHqf3gTu1iCvDlyXHIKLnDwDxQJZy2yPZcDIJ2joVVRBW6yeH7V oZ5uAFohtKtuIdg/DXuvJeN3EJrjE6Q/lghvb1GYPD/XxPjrMYb6gcOdWwsv8SYCszLB TeGxX6+mseqkhRNsxkJNHOOS1dMO2kAdYlrwXOfVVgvtYEJKCovd4VA0bczwtjk87z1j DhmQe4EV0Dro1Yk0o4u5cwPpIV4+7+sJPkxANjYh9nGnnEFtSZm+CpKmMcE3h4mZtsqi Trjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755145572; x=1755750372; 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=E53GO5l3Hd8eM4ap4AumPBduB+XTyY1FxcPASVl0VY4=; b=Fd69fSIgNR02tWJ9igZF0tCCOtqhGaY2OPmnvsAiQBdcWcz+CI/RGJKvSkERHv5g79 Qz5ZVf7pmlRu1PdtWhsrxWSp6Zi7SRqfNlgUVRHOrWs2CcRTAhxnzmmZxabH3J5b38Ar wOSZoWNeWx74KIdHBLq5mHeaFfmeRSA8Dbl6mplp//Kesm7UadyEI5HsTFNP71WGkubb xNpyy2rNl/Uroj4aU2U5o/QqptIBd05ABgGAsWVvjDucDxDiUVAyZDQ82/20xMdhsOZk iFY8Reo9pjPu1bLzLuHtTlEVwIrCmG9SBvHCGVJHlx31SPon11ZnMYIcHqRfiF5+Mv+M U4yw== X-Gm-Message-State: AOJu0YxXR/sVrDUcy/R5H0OPkDzO04n1gAaaD52dQIMI+BzFhZRfz5bT eNJ4lI0UxkVOi7FYx6XtcS79VlHsg/a1ci3oDChQ7MYng9JCgVnLzuevOY/xn4i2n9gVupoQ2+A F/1d8l9E= X-Gm-Gg: ASbGnctRzsmHlDWVWOtAaibOB3Y2hc+djeTj8LBVYQN+QiUiszO19kClM5XYuG4cLkt ORQNvXHsXfYLFoamb50o9N2m61f2TjvfRIHeCQnUT0fPZPMBg6RbAA6KCqy2FLve5EMdMQIx+AT 2fXefnUaNdSRuwM+JpLJFrLMh+quPUl0aNINZ/KJeVtttFtRqXXmcjt5XbWn7M2XwgC8ouErfKo Z2crZ4J3z8QeaWUk8wPHtDim4uk1MUFad3W4JyiLznONYUuLesK9NfKRNZijxnhk4Q7aadppjUS q8VPjD87GXWc+mqaPfb7Bs+xrcI+3eY2FBZNaXQUAn8I1PGoEUeLmwaMl16X0jsxoYhHQ5OGG+a /XDB85gUAdmrs0P45jEAoU9fFHi6WrRIgk98Stim6+4CeHw== X-Google-Smtp-Source: AGHT+IH5sYIJC2zXcg7kWdjdkwwmDo5LRxzkItT3X4bcGccUoZxMDcpvvqC+ZkSniSb9xdZpglQdpw== X-Received: by 2002:ad4:5d41:0:b0:6fa:d956:243b with SMTP id 6a1803df08f44-70af5e95f6emr24878386d6.37.1755145572127; Wed, 13 Aug 2025 21:26:12 -0700 (PDT) Received: from vince-B550I-AORUS-PRO-AX.. ([2601:406:4d01:1820:e358:dd1a:4ea0:986c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-70ae6cb6cc2sm8322816d6.22.2025.08.13.21.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 21:26:11 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v8 6/9] bootimg_pcbios: add funcs to configure booting with grub Date: Thu, 14 Aug 2025 00:25:49 -0400 Message-Id: <20250814042552.21887-6-vince@underview.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250814042552.21887-1-vince@underview.tech> References: <20250814042552.21887-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 ; Thu, 14 Aug 2025 04:26:19 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221846 Functions added, but not executed during wic image creation include: _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 if none specified. Both variables are required by grub-mkimage. * GRUB_MKIMAGE_FORMAT_PC is used to define target platform. * GRUB_PREFIX_PATH is 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 bytes of the resulting wic image. dd grub stage 1 to wic image. If this wics plugin is used with GPT as partition table format and grub selected as bootloader it's more than likely for grub hybrid booting because bootimg_efi plugin should and more than likely will be used in that case. So, boot.img may be dd regardless if partition table format is GPT or MBR. 2. dd custom core.img (grub stage 1.5) with embedded configuration to the resulting wic image starting at byte 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 Thu Aug 14 04:25:50 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: 68498 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 C0CF3CA0EE5 for ; Thu, 14 Aug 2025 04:26:19 +0000 (UTC) Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by mx.groups.io with SMTP id smtpd.web11.15408.1755145575442541995 for ; Wed, 13 Aug 2025 21:26:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=VO1hmQmd; spf=pass (domain: underview.tech, ip: 209.85.160.171, mailfrom: vince@underview.tech) Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-4b109bcceb9so5850761cf.2 for ; Wed, 13 Aug 2025 21:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1755145574; x=1755750374; 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=RvgZjxwOTYKxbUK8oqDkfVJDT9za23Q+5vYjRqL3POQ=; b=VO1hmQmdBvEiNY6czOwYvPNGITee1G5bxt2Ly6JTpyKYR3qu4I6QSiUcFpj/jW1E1O h153hbIzsSLdV/ji8EXvtNE1SKD3BIKptWhnOKR9cciu15VRwS7lNPhGuniKLnJBhM5O mcxAqo1rg8THv51uIuqqZNsNsuKaGhwSUNESk9PsVLQhZHZunGTrGuehLDugEyUMYwfm wDvNOGOF749ec9Ktnakhf+nNjUaRi1/itikmdT1Eh25C9Kgj9LJwBSjq2Xx2jfbZVDod LqhZyXKhKBUBdvcLEaEhfRfBUYWYl/xgbJEZb99kwnR4EBb6JYS9m7Eqc947xOybjrGn eynA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755145574; x=1755750374; 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=RvgZjxwOTYKxbUK8oqDkfVJDT9za23Q+5vYjRqL3POQ=; b=knAWurzmcbDPMJgHIIY6EujLgLDGHvatiVW7xwDNt7xnslM/E/YNsn0FLJwQAv8Ayh rpjNpogCkQ68zksfqgI4pRHffvEaxDymqqOWzKdy41D6acSB9OMf5VR2O/ZdEt1YFwyW sqUUuJ7HJSdXprto3HMOU+G5WB4sDJ6BNKhW7F3FQncXxfn2o/qjijyBPQLtFCugpKYi CiMPjkIVwk653iQkFxJQEgm2zL6WjyKFF0fv7MkaWk9jSWyTMaGBXLJjQWEr+6ldJpS/ RAupCcnz5CsrpQMsdbCansEOU4In/daepUBHD0jwN/XkSmimgrfDPQh1WOtWlJlWpkWL 3QwA== X-Gm-Message-State: AOJu0Yx1W3j91ajDp2JdpZoKlI5K2VMFcvYsN6fsDeG4/MsqwOqjjy7U FXbl+nFyHvmM7riPbKqiqQEhKodDOTbHQ9wfdckkx1hLhkU6ggL5SqzH7HEX8KGMXMexStkTTGN ZZmKrxJ4= X-Gm-Gg: ASbGnctoVX9Wa599yS6WP31w1DsjOW0AzArqAFCOyuJ2JAFn/ySXnvu+9dOrDFr64Pd o4J87L+XL8+9m879+MGie5MLDBPkWvFBz7d8YBPO8ZUZLSG6iHd7rfrlLv6gbPjrlY7y8WISQSk WH3lQ9hUOmEyDfwu6iSuhGP07qjzG7+uYMuvJq6B4Jj+1ASs+y8UM3GvaJzIEP2qspK5bPbzF1O oaZrKu4Rylc1Ev+R3y/c1qLrKgifoKcqAPWE6Z0M42Bdbn4M/v9FkkyWqOy7BOmya+2I9imGqOL yeEZtzxV0J1Es6hzpDfs/3qj9YoTbMlIUWh/ixAo20MWFbo2iJKhekXa+bwGr+h1WBpDivV+ty9 G0ithP6yklKIqUB+83TmhCRU8ueA9mpEoo4NQHcWdARA6GA== X-Google-Smtp-Source: AGHT+IEOYQ9dBn3Es1fqND7VA21Us/Kml7CVdKYj3VL1aALAhEK37cWV7SFlma3qXnwqD8C6LvY8UQ== X-Received: by 2002:ac8:580c:0:b0:4ab:ab85:e54e with SMTP id d75a77b69052e-4b10aa7a720mr22960871cf.8.1755145574035; Wed, 13 Aug 2025 21:26:14 -0700 (PDT) Received: from vince-B550I-AORUS-PRO-AX.. ([2601:406:4d01:1820:e358:dd1a:4ea0:986c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-70ae6cb6cc2sm8322816d6.22.2025.08.13.21.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 21:26:13 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v8 7/9] bootimg_pcbios: include grub as an optional bootloader Date: Thu, 14 Aug 2025 00:25:50 -0400 Message-Id: <20250814042552.21887-7-vince@underview.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250814042552.21887-1-vince@underview.tech> References: <20250814042552.21887-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 ; Thu, 14 Aug 2025 04:26:19 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221847 Commit adds in support for installation of both grub and syslinux 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 Thu Aug 14 04:25:51 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: 68499 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 B3504CA0ED1 for ; Thu, 14 Aug 2025 04:26:19 +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.15478.1755145576741552651 for ; Wed, 13 Aug 2025 21:26:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=DdGk+Vmp; 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-70a9282141fso7467246d6.1 for ; Wed, 13 Aug 2025 21:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1755145575; x=1755750375; 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=ZnhWm4HTU8auWxhAYl/6t0HLjjhzJ4uhXsqEXynPhVk=; b=DdGk+VmpSCK8C8sXzDQejDPdPCOwXuxYpJXZ7nrm+fm2tQuCzATAbfNeRTxF/SqiAC j/0z+BlybawJTJr1W/hA25nEnk1K4nKXHllebj1BC+wzQJGKb0HC38huPyEOqVnBjr3H nyGowhZcNvO3ww0VXabvP7aU7U0WuMY9W0y+A4nYY2Byn/XWXZYoq5UvlMlQl39ZW15S Zvrz0XKh2JNBXvl0qi+WYQU9+/+Z65Oe7/NUNe9dD+TGbHReRnFJuGZAODsP+L/lyaZu lDOhe8gN0JDR3W9V3w+kyIhz9L/4FKjNsVN9KWmsn/A2z1i9UYPkW4vv/2GuaYuNNp7L P4sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755145575; x=1755750375; 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=ZnhWm4HTU8auWxhAYl/6t0HLjjhzJ4uhXsqEXynPhVk=; b=KgMGyCStNIwyCxbySnwGILFRDH2NUfwqPCAQbToMb7vJMesIAD74gMuHYqsfN/QEBH TcIHZm/h4+2lztuU763slAvNABKD04SxwwiqkHitgclcRkhIYD2oADrv8vniRP0FlJAe 9TA6YmhMTYwWodCKhhMoDNyZApmhxzmR+paoppaVHlk+V+GevS1U6H0LwekF4uv+ffd3 RAh0AFfqMWNg05SS24MwVBmYaFfr3yg7Ud62cg0ZJ9OtYS3cBTuLQQqiTIBm447q+nFF YkvlZDLTm3wC5ww9AzFqb54sSzqWA/zDekWNQ4dzWdSPITiHlch1HCDflT/eFMJtw62Q ZXxw== X-Gm-Message-State: AOJu0YyQXq7O2yCcXUgEDYwFp2Ov8PHaDLaSK1Vtt81/+cJ41uPrD3V2 Og3UXgfUsqneJLwZcwu0nVS6xfLwSjWoSCiwEV81Ivvh5zWk3n5hAjxskOgaHgWTLmSJgmjFIiD ReHSc0Bw= X-Gm-Gg: ASbGncufrFDtIVeOzH5Nt7q5QuSoVOBDJSr7o1ZvLpf4knuLn1/n+2BJM+qUc5V6kfw 8hbVwZv6I71JvesyDlH+XbNFvkcmrQitL/wuKY+KpPRdOYK+uH7CLfFYZkxiOdt6VNgDT5sDGm+ ALpBkYhZkEXnsJQ4NSM5fHpJ6JIZ3FABo1wgY75xyPe7npqYIHoaw+1keO7qKvboXZDH3HCglWl g6a8TLX/cleTVEbVjmrehlGJYUENpixqwjdOv0FkR/+RDCgRbpNbKaRlSLf20fDTkDcCgcgZ2kb w2nOspfw1KBz3sl9kCdQPrkY3+TerKjcWBw08HC/osDz4FkhvMz35y9uGNPHFQ/u1r8FW74VTsG vJffOnkFFXinCRVFwYiQQQu27LO/zYt+PUIxPY5ASjNGZ7A== X-Google-Smtp-Source: AGHT+IEvRlty3MlMKRExoq2e6v1iIa2q3kRsPZ5yLQGfAbeUz+fR8OdtNI54EUeBFOOI9+3jDfsdWQ== X-Received: by 2002:a05:6214:1c8d:b0:707:4daf:641 with SMTP id 6a1803df08f44-70af5b2d44fmr31392156d6.39.1755145575441; Wed, 13 Aug 2025 21:26:15 -0700 (PDT) Received: from vince-B550I-AORUS-PRO-AX.. ([2601:406:4d01:1820:e358:dd1a:4ea0:986c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-70ae6cb6cc2sm8322816d6.22.2025.08.13.21.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 21:26:15 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v8 8/9] bootimg_pcbios: add help and usage comments Date: Thu, 14 Aug 2025 00:25:51 -0400 Message-Id: <20250814042552.21887-8-vince@underview.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250814042552.21887-1-vince@underview.tech> References: <20250814042552.21887-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 ; Thu, 14 Aug 2025 04:26:19 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221848 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 Thu Aug 14 04:25:52 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: 68501 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 CCEBFCA0EE7 for ; Thu, 14 Aug 2025 04:26:19 +0000 (UTC) Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) by mx.groups.io with SMTP id smtpd.web11.15409.1755145578425894356 for ; Wed, 13 Aug 2025 21:26:18 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=gHQJV/4D; spf=pass (domain: underview.tech, ip: 209.85.219.47, mailfrom: vince@underview.tech) Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-70a88dcb665so7477006d6.0 for ; Wed, 13 Aug 2025 21:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1755145577; x=1755750377; 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=bUgW/Dohl1eu3VTBxdIh947IqoJcytGLntlsQO7Jxzo=; b=gHQJV/4D7KdbsJOaJNMYsz1zy1/2Mw5cjuxk9emhMZOMXqzPWvHCCTbU1mFpV0pj+1 yz7sQBXi/9hDjELRjpXsR6h9TyNzgHAyQjBsetmXFPGgRBZV/4gbvB/XfqdjZtmEuyOR EaPJo5uQYPRMl3SnV9IvX8ktVxJ/MeFbW0/a/YDZklkGQnD8fDQtMt5Cti5FGPjRbm+7 GBAKFRjoFg8sVbC+PWjzfvL2W2UstqMXrLT5jQPS81cqDXUJDp6qejkENvctz4vRhd10 sFEJ3AJSJYgJueC1BcZdlTZtGIoC0LQ5St/c9jx5IbdoFRf8Q7IcecJWmyZrR3WrhnLr XO7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755145577; x=1755750377; 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=bUgW/Dohl1eu3VTBxdIh947IqoJcytGLntlsQO7Jxzo=; b=tIhds8C/FL2CyoXr9dLWZe/scyydSBedKZXN3cE1XfBb/LorqBfB12ftWmd6i+6BwP WOIbZ/IpYuoy8C6xIL24KsIfeYGE5WoFiM0DAkW8oPvN28mBf883dsmJ3sSIbNRwYcfv hZwa5NCTcwNn9fN5U0aALBciOs/t8S0MNw238hHjdGAmLadHfrv8N3BIaHtU5WEFhGzA +0rYFKzENE9DbLyYmkcPOGHSJLWf4sae6M8rwUEURpT7/7Lbi8nQ44cypxi0111GLZ6l AKyr9VQcsH/qL1fqq3FmDbUtgLuMH/uWP/M1AG4btjzzulzgtCRh4HSQe00vo/+dcMuC adkA== X-Gm-Message-State: AOJu0YypbreL7rwnHcFcZECpFcVw9QpGyDo92u0vHO7F/W9/AIe5+vKZ jAN/9ymejRKQzHspkyPALldVc4+tRfEWxD2a59utYtxAnRsleN+QEc3sXdMrGbueJ+YVQOER9Bf EBZsVBpg= X-Gm-Gg: ASbGnctIGXWrmyJJU7HxGffEArzILzucTEPULhfDBcBtPP3pozPFDaMmVdoXmkkxkuv IhEa2LSI75wRWRvdIR+NsWsZwCfl2gqJC2QaF2HJDDDPc7x/Z/je0OsDnecT4a4TCWfFyjasG90 RPNECNmPMeKa18ejCuV0Hzp4eeZapp6lgOfdSTRFKr20WLihG7NDvjcImoA5SsGPQPBdGOrKCSY dpWcFAT84QIF5CWPW+EyZ8McGNb+1kAwGIOV+WtI+bjuPT5QV702b0YMPtLgv+02SU5UPKAXvWX OFWp+K+Fx7rA2B7j/40fbXWXREygmbNRcEq1uSW0CkCXvkff8OGOT9x6HW3xxnTvfgUAdp3G+VQ oCBIrYMwzSYdqQPKmcLKQw2qNgMYozNT29S5ZvpLFdsvJww== X-Google-Smtp-Source: AGHT+IFbe5jsEsO9iZd09B4YyjGvK5v8D6Fk9IKt7rFvlRVnZKNwY93D0TtOF1fGCdrXFfZMXK0KPQ== X-Received: by 2002:ad4:5946:0:b0:702:c4d8:ec02 with SMTP id 6a1803df08f44-70af5f57928mr24126186d6.40.1755145576942; Wed, 13 Aug 2025 21:26:16 -0700 (PDT) Received: from vince-B550I-AORUS-PRO-AX.. ([2601:406:4d01:1820:e358:dd1a:4ea0:986c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-70ae6cb6cc2sm8322816d6.22.2025.08.13.21.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 21:26:16 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v8 9/9] oe-selftest: add wic.Wic.test_grub_install_pcbios Date: Thu, 14 Aug 2025 00:25:52 -0400 Message-Id: <20250814042552.21887-9-vince@underview.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250814042552.21887-1-vince@underview.tech> References: <20250814042552.21887-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 ; Thu, 14 Aug 2025 04:26:19 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221849 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