From patchwork Mon Jul 21 01:14: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: 67154 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 4E3EAC83F22 for ; Mon, 21 Jul 2025 01:16:49 +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.30071.1753060599234837922 for ; Sun, 20 Jul 2025 18:16:39 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=SxhGw0KU; 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-700fee04941so38830066d6.1 for ; Sun, 20 Jul 2025 18:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1753060598; x=1753665398; 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=SxhGw0KUgoGcdk1lvUkzKR5mzrVeiH33pAVVpcK0grj+ThIudqEzfENAfp7/3hIE3t LoB26dZ5P6nzCjBOHIcHoZ+W1z5od9Vb/UeuLMB7dXOms6seQeKt03n60ADsJpvHuYhZ Hint2f6muHtOahfCaocHt2Ouh2nL8eMngOOzh+q7pqvp+KFaQBrmKS7EK1QOD8iZurFV h/T8ISIogyqE6SgxePjtKnQdlqvnsJW4cT/gg8qGiQ38TL/b6O8o86mffI+C2JWKp7gl s3OIIaDPrcCj7fRyKdkh93mPc1KpNssrOxj2jy83GL3PwcEA/UenYL33C3Qepv590uzB 1/qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753060598; x=1753665398; 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=f5qPG/sP7YY/RPl7YpReJA5mhIDuao7gclQ5+sBefaqnfntVMxXPgfxXp5Fly/F0g2 4UTCAwbs8k7jDEumOn6Q80OO60XomQ92u9gJmQWp+VMa1b7jf6XATBcr7CrWXODR4xS7 gz20+MpkFw/pSHGYjTFOU+LqsNiuSAZv+JXoP+9lxLuOG2CXbUfUURpWIeDCaPDFzHNM 5dN835ebivb5bx0A7sxyME2vRqFp+TAPUkus9yyeVXyu412u3BXhdgiJK6TMQGcvXeF1 RG+x0bkQfWr/YfgWJexeNs2lEJQJWfaDV5FCcivStrMV3SnuVdDaF16FeKOzitHH+1Yz 7dtQ== X-Gm-Message-State: AOJu0YwSFSQPHn4Y+8PMTrVnIDjFJUV1253nxawfeud861GLH9Vc80k5 as9gn9Uo3ZTuUC+I+unsPbXEoCVNLJfrr95v/Ix/QadsEogdc08yZC7uaDRGc3ZrLqh382yGtT+ iSqF8 X-Gm-Gg: ASbGncvBOwrsC/5AYMEOnU1mJ6S1nUvUEvxpRLIu2uY9EiZZRex9LkIJR/3IfSycWce LwMHm+pHxVwMY1IcLTclGC/55GZ7dUvTDqRC0UZNKZqPITS2AIwqaGsHq7g7wDLJBDABNUBmz3I OVJvVKSTrXudNnRRCUsvWBSOZ1ZrXChdrjoBf2bIHG8587fohHQqwN7VP9QoAz/WpeLCvKuErN/ ppl19SnbQ1HdTcGGgWE8qouexokPJDdFqUpJzWMN8HJLNffmLRTNkFUQO+aFscHVhu7tcDvJydi KLK23bb8IX6cf2ElDZxn2XGFyrHRltpq8ZbgmGFM/x0dvw1ew97DkYL8URzazqpPgRX+Bz0hzu+ WSVvmeumPS/Q= X-Google-Smtp-Source: AGHT+IGOg0FaYfeiZi8xOOipnUhI1aTRwUPlTsEvfVTOl/IJHnaeygXxF8Tg+PAMjIl++eTdlyZ5dg== X-Received: by 2002:a05:6214:5c44:b0:704:7dbd:d991 with SMTP id 6a1803df08f44-705073a31b4mr254543766d6.31.1753060597748; Sun, 20 Jul 2025 18:16:37 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::b05c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-7051b8df533sm33318396d6.26.2025.07.20.18.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 18:16:37 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v2 1/3] bootimg_pcbios: support grub legacy bios boot Date: Sun, 20 Jul 2025 21:14:48 -0400 Message-ID: <20250721011448.3565296-3-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:16:49 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/220645 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:14: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: 67155 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 34403C83F1A for ; Mon, 21 Jul 2025 01:16:59 +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.web11.30257.1753060616010786737 for ; Sun, 20 Jul 2025 18:16:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=CZB8hdNj; 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-6fad79433bbso34373176d6.0 for ; Sun, 20 Jul 2025 18:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1753060615; x=1753665415; 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=CZB8hdNjyH2BNiqWP71Z1KlMSQekYyFkhryl3Vi5bHzbpFN0w7M3CDsCwb7wbC2mBX YFRZ0A4Wgz078zEay0oM5g+nGKXBuP1ouQr3f6Hdb7n/yO5zIo4kiMjkuhQSb13gtSW3 KrhquNBin7YBsj8Mbr8a9fkHWl9SqeaBPp8ZnJ7QHafqTOoOUgZqe5BIIvjXP/5koIAo uAmiVaBw7agQ7QE/r3DhKfIVCHf/v9r2DJGzSonsleDCLWLvZg+dNX/AuFTbRrV8v4Pi coThOee/G9as+b1tqxHAhL1LoGuVuGRZNpx5L6ZAOrWm7adBzu2VrQMc/BRYgGeISd29 vsfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753060615; x=1753665415; 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=VpoReBHgDqxfyNndg+u884/CZTbhATqRAzPoIfUvhNb2oy4w542WEyFzmtPO2xpV0S xo6zxZa9Bpi3twHKnJKkYR76jN+nFgsAcQvxk/EP0L74l7GKo7GIVR/6HaAxUa9ZcoeL CQHcCzLFGK7tgE56cWk/8TO+d1rL7v6qEAKAlwfjFbLyViozV3fS5FWGuw/ifiB77k02 JXujtgyDCnVBj0npBAzNiHfMVQuZU66PqlXy6PtZnbHkCaV/1bI2yet3/XzYJf467PiJ qtqX8cCSPYz4rPAXHAuOKuv8w2ef+lSXhA+65Vv/zizCcpCV4rDXQ9GFq1C+MRoqDMPm qvaA== X-Gm-Message-State: AOJu0YwhtVeepAtAntPq2foY64khj07sPxGqk5HPdYoHtCRv8bF7rBkj BznTVTt7TyNDwXJy3rmY2jvc/UGXK8OmJlaHQF9wH3LTiwfnOA3nkac23icCKc+jZ1DlKMzb1wb hn93v X-Gm-Gg: ASbGncv2bAeqNe3JXupDAzBH2B8GvITEbFWdsCUvRWxB8vFScK7LK7yRkyGw3b/QV32 TygTFH4vawS3SNKzMatA4HWk4p4UcgWIoJTU6HOwPs+vIIrZ4moQKTfJW01WO9XWILgsIb92QGu 51OErbxqNnyFmEgWwqKr+Nxj865GT5xU6C+UwDu5a3agZMlYfjGU+AzKZcBUHOKYIjR29DX6BHS LWLXEYGjHLvog72LiEUQmvGl6K3mvIhD5qaQSOL0vK796/ojtSS3Njh24FvTZHQT2pc1+2kDrM9 FSvrQM/+D2mi9AuUHzBZKPI347Lt4/6o3QDNKXq8UMPQ6OPQllWxWEmk5zGSTE4cuKLnpmBLkjT BpSrwpq2NfDc= X-Google-Smtp-Source: AGHT+IF0IiTrc9dSFdKHU+/vh4onuEA21VSaiVRH2QKpyqzo23W1PIeXjIwfWI8Xl8UUY4nIPvyMPQ== X-Received: by 2002:a05:6214:5885:b0:704:9077:e0c8 with SMTP id 6a1803df08f44-704f69fdde6mr296661836d6.3.1753060614572; Sun, 20 Jul 2025 18:16:54 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::b05c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-7051b8df533sm33318396d6.26.2025.07.20.18.16.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 18:16:54 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v2 2/3] wks: add loader-bios to bootimg_pcbios source_params Date: Sun, 20 Jul 2025 21:14:50 -0400 Message-ID: <20250721011448.3565296-5-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721011448.3565296-3-vince@underview.tech> References: <20250721011448.3565296-3-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:16:59 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/220646 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:14: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: 67156 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 2ECA2C83F22 for ; Mon, 21 Jul 2025 01:17:19 +0000 (UTC) Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by mx.groups.io with SMTP id smtpd.web10.30079.1753060631305098039 for ; Sun, 20 Jul 2025 18:17:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=JKWX66L7; spf=pass (domain: underview.tech, ip: 209.85.219.51, mailfrom: vince@underview.tech) Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-702cbfe860cso31852206d6.1 for ; Sun, 20 Jul 2025 18:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1753060630; x=1753665430; 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=RiKOxel66Nejq4tE8zoKblWfssQFptbmU/p8gbnZ2gg=; b=JKWX66L7DOZ8zWBr/ffC3ohDIF9ML6H7tCyNHxoJZjVbrjfYfxETZ8b/dglpo3DH7u Hq7+Ltv8IdDB7uno9QQjZyE8DpuS/XS7DDcdapuJnZtA1B2KU8Hi/CU3bkqA5AKTuF9O WW62cC3cVVr/oDcxfObwctWiw5/llEIckVDabJ2cHsYcyOG142Yx2hlndqx2g7jxP1Dw XIhgfuqAqGPfbGxb5SOII+k6Fg+kJeotQFXNDE7C5fZmev6bB4BCYGpW5cV6lRieCM+S beqZAykAs91rv6E4vIfuy4/7TvjLRajwznL0XeLiGVCOfQY0ocbyNYUx6PfaGQwMDicO kdJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753060630; x=1753665430; 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=RiKOxel66Nejq4tE8zoKblWfssQFptbmU/p8gbnZ2gg=; b=FEs17+3PT57Oc+lnWX3gk58kmfq/ng2LBaeMwphgbCLOpo+TeWf95+XnO5ABURI4Uk E2SakHVBQ4+e474CLnLdsDN0ZqKALgYJNr0I+cU5Nvt0TjykndxrhxPN8Fb9elVDyy0b M9MRT3GryrZkJVDji8yZZjUosx2+zx41RUElNM3kf+Z1QQ1Ybc4Xtr3ukrmju2zQlmij 9xETX5Boi0RNYFx+YlFC7c4jpbAe8jtiMp9m4woBkR0VcnzVORqmShPpwq4isWa6k8MD tTWMuvrues3Kr0g+Y5MLPqFLDPHoqV5JeEgvajvzEvLlRvBDBOSyJRwV8xrN1/BwAI74 12QA== X-Gm-Message-State: AOJu0Yyd8vNZ4SmiO3oGiStRa6x869B0sqaVfdtCPOhoB3YnMxpem1St ChL8xVDz07Ajzei4cqihsDgL1gL5AKc+EM3QZxyIh6f0v4EGIeGLkSVfe8WlYkAYX3cHP892uh+ ITi5D X-Gm-Gg: ASbGnctrugH+yU9e7XacXP96eCoLeJrE2X7TfRkTN8BkxevYRQO8By/tFZXUuTtvk5v yV+1EhBvd2cNqOLSHQXNwlILVrWp9PE3PodqDlMw9T9WBgpFNsjrNky43bsjr2ekDtLpjDv155c g+EvE30BRM2U3yCx+qSfmM2f7ImfbK8DnwmLTMF0na8ZhJSggTPx0KY5t1niaQc6tlz8OTAnRkC Lx5+QdGnDTrhmNug8WrMy1WuOkBDfTONitx06azg4X9DNCJTkHbyH9Jgmjg9aIHajh7tZ79U1t3 gq5xA375E+G3HkpYL76oYv2Rei501fRMR0VIc3P00/WKysYd8oL7qrqyhFnyIhcFh1dREXrz8Wz tEd3jnUFaJRM= X-Google-Smtp-Source: AGHT+IGsKs2TdmRE2s67WBpJOA/SUlVrWHL6vDsFIyl/7Deh8qY0bw1jaE9UPy4JbVcxGL06sB5Alg== X-Received: by 2002:a05:6214:1248:b0:704:8e3c:7b4d with SMTP id 6a1803df08f44-704f47fa528mr249534596d6.4.1753060629906; Sun, 20 Jul 2025 18:17:09 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::b05c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-7051b8df533sm33318396d6.26.2025.07.20.18.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 18:17:09 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH v2 3/3] oe-selftest: add test_bootimg_pcbios_grub_install Date: Sun, 20 Jul 2025 21:14:52 -0400 Message-ID: <20250721011448.3565296-7-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721011448.3565296-3-vince@underview.tech> References: <20250721011448.3565296-3-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:17:19 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/220647 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..91d9d31da1 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_bootimg_pcbios_grub_install(self): + """ + Test the installation of the grub modules + config + into the boot directory in the wic plugin. + """ + + # 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()