From patchwork Mon Jul 21 01:51: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: 67157 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 747DBC83F22 for ; Mon, 21 Jul 2025 01:52:09 +0000 (UTC) Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by mx.groups.io with SMTP id smtpd.web10.30688.1753062724155492915 for ; Sun, 20 Jul 2025 18:52:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=joQXUIRO; spf=pass (domain: underview.tech, ip: 209.85.160.182, mailfrom: vince@underview.tech) Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-4aaaf1a63c1so28936291cf.3 for ; Sun, 20 Jul 2025 18:52:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1753062723; x=1753667523; 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=zlHgYPpQ1hMZf5lMp+SYlNRkxOMYIv2CEeb5XAbH564=; b=joQXUIRObNVeIyAVvMTsZ1EQxMsJf4aIyhtZLQjob/WqEi7kuJl7NtTZs22j5JjoED gfEhZKaql9i3HRHQysYXh6nBVB/jIk9FIArpkpSfAYtMDTVz0Ju9hOXCNlbSjsUE3iLc WV3t6sI6UMvUJwW8LYoDmg692hUvaQ9Skza1gN+lDQ7FiTbRKvUNCNLP4WgyyVufMEnS LSACFIXgrOLsz3cYMhnlPxOiBYViI2X23Nt99wM4wdDA5rEcU2WrOv4hx6mRda+WzMlZ 29ZcALjwDBnpGL5QSaYyViB8Aet4Q/e217//KFDhGYg2yAibPrPaG+tW0Klu9RPA5KG1 XJBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753062723; x=1753667523; 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=zlHgYPpQ1hMZf5lMp+SYlNRkxOMYIv2CEeb5XAbH564=; b=A1BVZQKakLy6Bza2yP5Efd2owlPf3TBj7oEKh0PBq4Xo/FVkQlwgoPPZ6b8OpsApVt pbWl2XSgQKQlrIBrRPYpp4eiC2ri47uce/04Pla9nAs/0UssQoDWTQuVPa9QBuNxEZlI j8QCq9J6fb03pMd2if1f7gSQnOlVP6MkOjkqHEWNcqDsgBHCSp//WS7Jxby+CldQPLeh jCvHiPax03Yx5Wpc3NPBJ8Cia+9Ah/WeRlVvRGpIhUeXCtL1EWWEBUJ3MN6g1A6vAr+7 X1PxiXvWp9RoXji6nRjid2Al9JPGdw6UMsUvJB6yKjLfwMHRhBbcVqiJeGlqSuka9Qa3 +T3Q== X-Gm-Message-State: AOJu0YwFr/9ujfnKL+X191p5pkiGUZRGS3iw88PaD6T7t7eQkMxFI2bT 1nEf1jnVKIyjaMuDts/hnaiwAaaA+Imb90zZSC6QcUiJyCda5xV79GnUaQlC4OEXpweSfgSembT k/e9l X-Gm-Gg: ASbGncsQwd431P5gWskgpn6Hux11DfWXlDfd/bf+vELfgsTGxC8S29taVPOXh/8s8Y3 2C2/2E7leXt6RJezefp/gH+ZfBy0ZCBZfiaZhSzSgNWacxbCCdqefLn6tunu7asCaxqfXuCtuRl ZiDQUDrs6UfLOO96imTOPTxMfGC1r3KGhnX+rF1UPYBO9g9SHNI3wrSsAOJdh/yb5fIQGSgC79s Auj7j1375yEMNHdu9B4oIboGNPM0NW/Wc765F4JL/9k4YVxib9sSaTjjdrfwRWSdBtxPO7+0kBD L00M9IHDBc9YobSdTxo+guWBnKQi7mSdt1emr45XjeK4kd4iW7QnJueC3IlEbqnOcD56t6/6sH4 KhP6EGsjIfC0= X-Google-Smtp-Source: AGHT+IGDIXlMkxS1TLdn3cZGsIMhPnzry408qZ3IatQscKBXFq3i1ZcArmIfiu1KfA2nMNFTY+HW9g== X-Received: by 2002:a05:622a:1ba4:b0:4a4:3913:c1a5 with SMTP id d75a77b69052e-4ab93c8910bmr234834901cf.16.1753062722632; Sun, 20 Jul 2025 18:52:02 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::b05c]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4abb49d0513sm36039741cf.33.2025.07.20.18.52.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 18:52:02 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v3 1/3] bootimg_pcbios: support grub legacy bios boot Date: Sun, 20 Jul 2025 21:51:40 -0400 Message-ID: <20250721015141.3599063-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, 21 Jul 2025 01:52:09 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/220650 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. Signed-off-by: Vincent Davis Jr --- .../lib/wic/plugins/source/bootimg_pcbios.py | 345 +++++++++++++++--- 1 file changed, 288 insertions(+), 57 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index 21f41e00bb..2582ce1164 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, Intel Corporation. +# Copyright (c) 2014-2025, Intel Corporation. # # SPDX-License-Identifier: GPL-2.0-only # @@ -8,12 +8,15 @@ # # AUTHORS # Tom Zanussi +# Vincent Davis # 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 @@ -24,11 +27,52 @@ logger = logging.getLogger('wic') class BootimgPcbiosPlugin(SourcePlugin): """ - Create MBR boot partition and install syslinux on it. + Creates boot partition bootable off of legacy BIOS firmare with + MBR/MSDOS as partition table format. Plugin will install caller + selected bootloader directly to resulting wic image. + + Supported Bootloaders: + * syslinux + * grub + + ****************** Wic Plugin Depends/Vars ****************** + WKS_FILE_DEPENDS = "grub-native grub" + WKS_FILE_DEPENDS = "syslinux-native syslinux" + + # Optional variables + 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 --active --align 1024 + + part roots --label rootfs --fstype ext4 --source rootfs --use-uuid + bootloader --ptable msdos --source bootimg_pcbios + *************** Example kickstart Legacy Bios Syslinux Boot **************** """ name = 'bootimg_pcbios' + # Variable required for do_install_disk + loader = '' + @classmethod def _get_bootimg_dir(cls, bootimg_dir, dirname): """ @@ -48,63 +92,70 @@ class BootimgPcbiosPlugin(SourcePlugin): raise WicError("Couldn't find correct bootimg_dir, exiting") @classmethod - def do_install_disk(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, - native_sysroot): - """ - Called before do_prepare_partition(), creates syslinux config - """ - hdddir = "%s/hdd/boot" % cr_workdir - - install_cmd = "install -d %s" % hdddir - exec_cmd(install_cmd) - + def _get_bootloader_config(cls, creator, loader): + custom_cfg = None bootloader = creator.ks.bootloader - 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) + "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_grub_cfg(cls, creator, cr_workdir): + hdddir = "%s/hdd" % cr_workdir + bootloader = creator.ks.bootloader + + grub_conf = cls._get_bootloader_config(creator, '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 custom_cfg: + if not grub_conf: + 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 500 secs.\n' + grub_conf += 'set timeout=500\n\n' + grub_conf += 'menuentry \'rootfs\' {\n' + grub_conf += '\tsearch --no-floppy --set=root --label rootfs\n' + grub_conf += '\tprobe --set partuuid --part-uuid ($root)\n' + + kernel = "/boot/" + get_bitbake_var("KERNEL_IMAGETYPE") + grub_conf += '\tlinux %s root=PARTUUID=$partuuid %s\n}\n' % \ + (kernel, bootloader.append if bootloader.append else '') + + 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_configure_syslinux_cfg(cls, creator, cr_workdir, bootimg_dir): + hdddir = "%s/hdd/boot" % cr_workdir + bootloader = creator.ks.bootloader + + syslinux_conf = cls._get_bootloader_config(creator, 'syslinux') + + install_cmd = "install -d %s" % hdddir + exec_cmd(install_cmd) + + 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: @@ -128,21 +179,100 @@ 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) - cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w") + logger.debug("Writing syslinux config %s/syslinux.cfg", hdddir) + cfg = open("%s/syslinux.cfg" % hdddir, "w") 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): + def do_configure_partition(cls, part, source_params, creator, cr_workdir, + oe_builddir, 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. - In this case, prepare content for legacy bios boot partition. + Called before do_prepare_partition(), creates syslinux config """ + + try: + if source_params['loader-bios'] == 'grub': + cls._do_configure_grub_cfg(creator, cr_workdir) + elif source_params['loader-bios'] == 'syslinux': + cls._do_configure_syslinux_cfg(creator, cr_workdir, bootimg_dir) + else: + raise WicError("unrecognized bootimg_pcbios loader: %s" % source_params['loader-bios']) + except KeyError: + raise WicError("bootimg_pcbios requires a loader, none specified") + + @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 = get_bitbake_var('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_prepare_syslinux(cls, part, cr_workdir, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot): + bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux') staging_kernel_dir = kernel_dir @@ -207,3 +337,104 @@ class BootimgPcbiosPlugin(SourcePlugin): part.size = int(bootimg_size) part.source_file = bootimg + + @classmethod + def do_prepare_partition(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. + In this case, prepare content for legacy bios boot partition. + """ + + loader = '' + + 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, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot) + else: + raise WicError("unrecognized bootimg_pcbios loader: %s" % source_params['loader-bios']) + + loader = source_params['loader-bios'] + except KeyError: + raise WicError("bootimg_pcbios requires a loader, none specified") + + # Required by do_install_disk + cls.loader = loader + + @classmethod + def _do_install_grub(cls, creator, kernel_dir, + native_sysroot, full_path): + core_img = '%s/grub-bios-core.img' % (kernel_dir) + + staging_libdir = get_bitbake_var('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) + elif creator.ptable_format == 'gpt': + logger.debug('Update core.img stored on bios boot partition') + else: + raise WicError("Unsupported partition table: %s" % + creator.ptable_format) + + @classmethod + def _do_install_syslinux(cls, creator, bootimg_dir, + native_sysroot, full_path): + + 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) + + dd_cmd = "dd if=%s of=%s conv=notrunc" % (mbrfile, full_path) + exec_cmd(dd_cmd, native_sysroot) + + @classmethod + def do_install_disk(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. + """ + 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) + + 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) From patchwork Mon Jul 21 01:51: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: 67158 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 569F6C83F1A for ; Mon, 21 Jul 2025 01:52:19 +0000 (UTC) Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by mx.groups.io with SMTP id smtpd.web11.30856.1753062733896399701 for ; Sun, 20 Jul 2025 18:52:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=HaqH9F3b; spf=pass (domain: underview.tech, ip: 209.85.160.181, mailfrom: vince@underview.tech) Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-4ab71ac933eso31770681cf.2 for ; Sun, 20 Jul 2025 18:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1753062732; x=1753667532; 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=RVyXIqnaRLTKZPu721o7FJUReWE4Ybj0ippXF9PwIqY=; b=HaqH9F3bH03alJk34avMgd8KOdoH11ppntKcTebR1+Z6FZC46mhf4OHTo4qADRW217 ECD0ysn+xtA0z6U/6LFxGjR75yHnuZMAznkP9JI2EQaUqhP12LlHGJRXG9DsmE6x7FJ2 20xtRYNmbos5vnulbCEK8zjdiFCYv9srTuKoAmY/gQHgz1sXPjN21txL0JXWhCOszSKA fAwntzvMlOKiUBRP9+4PFp7NTbV9qaM5uxFbdPkdBqGapn8QOs2gXuBDxsqiEUmSdESo d8fktRwjAU5vPJdAlsOrWzkjFRHUuHd13kB0Pzq5QETfzo6Z6YJpMSg5awW443s+0CdP +sfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753062732; x=1753667532; 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=RVyXIqnaRLTKZPu721o7FJUReWE4Ybj0ippXF9PwIqY=; b=uqK7L8fSq3umciYoSiLtgamz+dFR8XD3Dun5GXL/d/ioLXomIVpi6CnZJ50/LZHyEk raf8eR1r6s5HuXSIxv1SXmGyV+GHJm8fgDO9wIMJ8SnDKfLkGkrbbxJpnfactRXXV8Zi Vn/OFyMt+XiaF4hGv4yCDps1D5n+rh2EmzZxSec5++v/zlKr2/Vsd+6oVkz2hwpfogp1 mjoIaHe7tZpKj0NXLnMvfOp5p50fj7Wr3xI9zCXxlIT485wAgmY5aJ2+0oRCeETTaxmu CA01ZLhpygT0QQJrVx6TGVS//1pe2cu9aVBwlCOXQd/kYEimJC9pil6FddxGRddAlbkG sFmA== X-Gm-Message-State: AOJu0YywhkGtLJKtC1Uov3DsRcg5nd7zzsQuAbBIjDNUQ55gLfjEPbZW tivs3IcpjjfK5z5UTjqTPh6BkiA8E6SlfwheaYdFVR9Siqrn0A0qzVmgyxHksHQpoCKSkctpFEI yLbhN X-Gm-Gg: ASbGncv4l5f7w2KU6hUAmC3L2ZMkz6oTiwdzBPwg1zTf1muNwLlRRmuofw5Bn5HHkUr DnUd0lg/N7Yeonpt75ptxNkvvIsUvq6GAbiNBh7fSH4bSqS/tbNiuLFu2T0+YjqipWC2GHruCNF EjwATnSG8Ym7/L4jpvPvxLa2lCavV07AQ8lOBDMiBvUvW1uv11G1ri27xoMwM/l6U5KSR8LffXD GdKu3NMwIk2rh0F0EicUcX8VqcGMf08gYvt33nN7V9pO9ViVHpWi1/4uXeDLn1vvVRJF0Cl2atI DDDkL5fhCABFFIsKPQoPyBQi88q0Trn9Fuy+IJOzMA3nWRoQvBZvMg0/KAtBSao/EEUX4JT7TLR ogQEv+Ax5VHw= X-Google-Smtp-Source: AGHT+IHfnlr1lF1hIANxicFe4NfeMDqLWeqAkdso+ijq3ADuRz6FfGR2IZ1/5cjMQbr5cz6W59b3hg== X-Received: by 2002:ac8:7c47:0:b0:4ab:7daa:d84a with SMTP id d75a77b69052e-4ab93dc1722mr282904531cf.43.1753062732440; Sun, 20 Jul 2025 18:52:12 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::b05c]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4abb49d0513sm36039741cf.33.2025.07.20.18.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 18:52:11 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v3 2/3] wks: add loader-bios to bootimg_pcbios source_params Date: Sun, 20 Jul 2025 21:51:42 -0400 Message-ID: <20250721015141.3599063-4-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721015141.3599063-2-vince@underview.tech> References: <20250721015141.3599063-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, 21 Jul 2025 01:52:19 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/220651 source_params['loader-bios'] is required for newer updates to bootimg_pcbios wics plugin. Signed-off-by: Vincent Davis Jr --- meta-selftest/recipes-test/images/wic-image-minimal.wks | 2 +- meta-selftest/wic/overlayfs_etc.wks.in | 2 +- meta-selftest/wic/test_biosplusefi_plugin.wks | 2 +- meta-selftest/wic/test_rawcopy_plugin.wks.in | 2 +- scripts/lib/wic/canned-wks/common.wks.inc | 2 +- scripts/lib/wic/canned-wks/directdisk-gpt.wks | 2 +- scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks | 2 +- scripts/lib/wic/help.py | 4 ++-- scripts/lib/wic/plugins/source/bootimg_biosplusefi.py | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/meta-selftest/recipes-test/images/wic-image-minimal.wks b/meta-selftest/recipes-test/images/wic-image-minimal.wks index 4186b16517..b0471b59ed 100644 --- a/meta-selftest/recipes-test/images/wic-image-minimal.wks +++ b/meta-selftest/recipes-test/images/wic-image-minimal.wks @@ -2,7 +2,7 @@ # long-description: This image contains boot partition and 3 rootfs partitions # created from core-image-minimal and wic-image-minimal image recipes. -part /boot --source bootimg_pcbios --ondisk sda --label boot --active --align 1024 +part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" --ondisk sda --label boot --active --align 1024 part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid part /media --source rootfs --rootfs-dir=wic-image-minimal --ondisk sda --fstype=ext4 --label uuid-test --align 1024 --use-uuid --fsuuid 2c71ef06-a81d-4735-9d3a-379b69c6bdba part /mnt --source rootfs --rootfs-dir=wic-image-minimal --ondisk sda --fstype=ext4 --label core --align 1024 diff --git a/meta-selftest/wic/overlayfs_etc.wks.in b/meta-selftest/wic/overlayfs_etc.wks.in index 8375d73a9c..89f2771e49 100644 --- a/meta-selftest/wic/overlayfs_etc.wks.in +++ b/meta-selftest/wic/overlayfs_etc.wks.in @@ -1,4 +1,4 @@ -part /boot --active --source bootimg_biosplusefi --ondisk sda --sourceparams="loader=grub-efi" --align 1024 +part /boot --active --source bootimg_biosplusefi --ondisk sda --sourceparams="loader=grub-efi,loader-bios=syslinux" --align 1024 part / --source rootfs --ondisk sda --fstype=${OVERLAYFS_ROOTFS_TYPE} --use-uuid --align 1024 part --ondisk sda --fstype=ext4 --size=5 --align 1024 bootloader --ptable gpt --timeout=1 --append="rootfstype=${OVERLAYFS_ROOTFS_TYPE} console=ttyS0,115200 console=tty0 ${OVERLAYFS_INIT_OPTION}" diff --git a/meta-selftest/wic/test_biosplusefi_plugin.wks b/meta-selftest/wic/test_biosplusefi_plugin.wks index 4be6643a6f..ef31ad20c4 100644 --- a/meta-selftest/wic/test_biosplusefi_plugin.wks +++ b/meta-selftest/wic/test_biosplusefi_plugin.wks @@ -1,6 +1,6 @@ # short-description: This file is used in oe-selftest wic module to test biosplusefi plugin -part /boot --source bootimg_biosplusefi --sourceparams="loader=grub-efi" --active --align 1024 --use-uuid +part /boot --source bootimg_biosplusefi --sourceparams="loader=grub-efi,loader-bios=syslinux" --active --align 1024 --use-uuid part / --source rootfs --fstype=ext4 --align 1024 --use-uuid bootloader --timeout=0 --append="console=ttyS0,115200n8" diff --git a/meta-selftest/wic/test_rawcopy_plugin.wks.in b/meta-selftest/wic/test_rawcopy_plugin.wks.in index ba324d9980..cb25acf0c6 100644 --- a/meta-selftest/wic/test_rawcopy_plugin.wks.in +++ b/meta-selftest/wic/test_rawcopy_plugin.wks.in @@ -1,6 +1,6 @@ # short-description: This file is used in oe-selftest wic module to test rawcopy plugin -part /boot --active --source bootimg_pcbios +part /boot --active --source bootimg_pcbios --sourceparams="loader-bios=syslinux" part / --source rawcopy --sourceparams="file=${IMAGE_LINK_NAME_CORE_IMAGE_MINIMAL}.ext4" --use-uuid bootloader --timeout=0 --append="console=ttyS0,115200n8" diff --git a/scripts/lib/wic/canned-wks/common.wks.inc b/scripts/lib/wic/canned-wks/common.wks.inc index 4a440ddafe..673bd15725 100644 --- a/scripts/lib/wic/canned-wks/common.wks.inc +++ b/scripts/lib/wic/canned-wks/common.wks.inc @@ -1,3 +1,3 @@ # This file is included into 3 canned wks files from this directory -part /boot --source bootimg_pcbios --ondisk sda --label boot --active --align 1024 +part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" --ondisk sda --label boot --active --align 1024 part / --source rootfs --use-uuid --fstype=ext4 --label platform --align 1024 diff --git a/scripts/lib/wic/canned-wks/directdisk-gpt.wks b/scripts/lib/wic/canned-wks/directdisk-gpt.wks index cb640056f1..07040d316c 100644 --- a/scripts/lib/wic/canned-wks/directdisk-gpt.wks +++ b/scripts/lib/wic/canned-wks/directdisk-gpt.wks @@ -3,7 +3,7 @@ # can directly dd to boot media. -part /boot --source bootimg_pcbios --ondisk sda --label boot --active --align 1024 +part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" --ondisk sda --label boot --active --align 1024 part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid bootloader --ptable gpt --timeout=0 --append="rootwait rootfstype=ext4 video=vesafb vga=0x318 console=tty0 console=ttyS0,115200n8" diff --git a/scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks b/scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks index 4fd1999ffb..fb51a22283 100644 --- a/scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks +++ b/scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks @@ -15,7 +15,7 @@ # # - or any combinations of -r and --rootfs command line options -part /boot --source bootimg_pcbios --ondisk sda --label boot --active --align 1024 +part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" --ondisk sda --label boot --active --align 1024 part / --source rootfs --rootfs-dir=rootfs1 --ondisk sda --fstype=ext4 --label platform --align 1024 part /rescue --source rootfs --rootfs-dir=rootfs2 --ondisk sda --fstype=ext4 --label secondary --align 1024 diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py index 2e3061f343..5b170594bb 100644 --- a/scripts/lib/wic/help.py +++ b/scripts/lib/wic/help.py @@ -544,7 +544,7 @@ DESCRIPTION the --source param given to that partition. For example, if the partition is set up like this: - part /boot --source bootimg_pcbios ... + part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" ... then the methods defined as class members of the plugin having the matching bootimg_pcbios .name class member would be used. @@ -794,7 +794,7 @@ DESCRIPTION Here is a content of test.wks: - part /boot --source bootimg_pcbios --ondisk sda --label boot --active --align 1024 + part /boot --source bootimg_pcbios --sourceparams="loader-bios=grub" --ondisk sda --label boot --active --align 1024 part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 bootloader --timeout=0 --append="rootwait rootfstype=ext3 video=vesafb vga=0x318 console=tty0" diff --git a/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py b/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py index 4279ddded8..2687217ad2 100644 --- a/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py +++ b/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py @@ -71,7 +71,7 @@ class BootimgBiosPlusEFIPlugin(SourcePlugin): plugin, as long they does not cause issue in the other plugin. Example wic configuration: - part /boot --source bootimg_biosplusefi --sourceparams="loader=grub-efi"\\ + part /boot --source bootimg_biosplusefi --sourceparams="loader=grub-efi,loader-bios=syslinux" \\ --ondisk sda --label os_boot --active --align 1024 --use-uuid """ From patchwork Mon Jul 21 01:51: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: 67159 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 582F5C83F22 for ; Mon, 21 Jul 2025 01:52:29 +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.web10.30694.1753062746726762087 for ; Sun, 20 Jul 2025 18:52:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=LNdEgz/k; 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-4ab3802455eso51594681cf.2 for ; Sun, 20 Jul 2025 18:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1753062745; x=1753667545; 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=j2lkqBC85P3/aUk6JATkdQzwcDuCajsC3XHAuaHUIM4=; b=LNdEgz/kptvlIe4pUiDybfjbk2KCbBQJZBX+GDHtFO2fsnwHYQPSwyQuYMRykDyVh/ 5+IZ36hmvkk9Ve2rrxO7wc646tSsljQbdrp6gLgrBXB9pBI+DI5r+NQo13R7FX6aROAa J8CAV+n9xu2GCGDh2CjVbkIvg6HfMsVWwcD6BRPfMSzRTI5NYjmvKniOc9iXr+RtW726 Dq8M9nOJfmJdYnF4m1U5A0+ym8RdRz4hgnjAaD47PB9ZCa2X82u1xszZx/DOxt7oXHVs E/kCvnVhR92M1lDlyD5Vr1wRCFeMzmHcVu8znOiQUhbeLy/pBeu2wet5qJ5TRpewdFZM k3Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753062745; x=1753667545; 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=j2lkqBC85P3/aUk6JATkdQzwcDuCajsC3XHAuaHUIM4=; b=MGAOYpS779Nlzz/9UpEZ84/oI+tx0yBXY6b9/0OCi1cQW3DR3SpqJp45friLhPcv0P Q8pT7/M3iJHcY2HUqEf692KZbb2j/S1ijZoKFHtbYvSRCetm1mzxPvhHBq+2Uc+xSAj/ Tf7x9b/HiLGP39WQ7owU1BxxMRYhB4Yo/fmt2Na8iOiay5X69ro+0CUg+iU/y1wM11uY FVVB/2jO8FkUxp3pekcYByJCqwGmtxiaki3q+AdlZlWlaPSYRm+tLfJ3lXrdHWHLgXjQ 0WCDt+ZxgD5E8t3ZK4/J6m7iU5yK+5Jwau7qKDNPYimBpK2oZN4DHYYLopjUTXOnjCV0 cNSQ== X-Gm-Message-State: AOJu0YzyEOJnilTC1u+LPKDLW/akL4MtcwAkEuOkWBwr15jQd3Wze2go m8zbfqOSjosw8aciM0c3uBWfZ64UlyyIMpFRtwf8VDK4ygkldLv5lKi86aUDCDu4lsMo1PlCelw blo1J X-Gm-Gg: ASbGnctQODBlbBdLq98Myzt5MmsCnWoeN97xEdzLbF0k6fbzxm0NAdTx80WTk2/JGwt OY4nfgvuN+s7OEH2gU0Ful3V75+fXLLVKe5GxXBRMjgcnipV1Sjmx8PBLZjOQ89SpDy9JTxdToO BywhdXsNlaQLQI61qGlm3dc4H8dCx8DQpWk+BVKhkRhbDFm2j9OBK7VEDNx31uxJSCS2n7GhzXR YZuIQiF1OBwljIHHC6uVAXF2NG6SA0O78nw1qcqhIl2Ka2lBx72bFB+5AQaCVEdPmvWuat5H1eQ DZbJbtTrDiBtgL44w9pGiQaTjvTBVlbSYzTK4oqKSZB5ktOB3wQm3VYMcZSRmt42WOgELsbwxjt RjjatdeDY+2Y= X-Google-Smtp-Source: AGHT+IFE5kDy8wzjgoNuIhxjK7NUoGPMG1wEwp/vEd8ydLFXnyJjjo8UhQUSH74EuvpeunuoTjBhWA== X-Received: by 2002:a05:622a:2588:b0:4ab:8ca8:5d72 with SMTP id d75a77b69052e-4aba39df4femr238278971cf.0.1753062745330; Sun, 20 Jul 2025 18:52:25 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::b05c]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4abb49d0513sm36039741cf.33.2025.07.20.18.52.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 18:52:24 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v3 3/3] oe-selftest: add wic.Wic.test_grub_install_pcbios Date: Sun, 20 Jul 2025 21:51:44 -0400 Message-ID: <20250721015141.3599063-6-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721015141.3599063-2-vince@underview.tech> References: <20250721015141.3599063-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, 21 Jul 2025 01:52:29 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/220652 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 | 43 ++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index 680f99d381..9e502ff5c7 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 @@ -1405,7 +1446,7 @@ run_wic_cmd() { img = 'core-image-minimal' with NamedTemporaryFile("w", suffix=".wks") as wks: - wks.writelines(['part /boot --active --source bootimg_biosplusefi --sourceparams="loader=grub-efi"\n', + wks.writelines(['part /boot --active --source bootimg_biosplusefi --sourceparams="loader=grub-efi,loader-bios=syslinux"\n', 'part / --source rootfs --fstype=ext4 --align 1024 --use-uuid\n'\ 'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n']) wks.flush()