wic plugins, any documentation?

15 views
Skip to first unread message

Ulrich Teichert

unread,
Jan 7, 2025, 11:36:58 AM1/7/25
to isar-...@googlegroups.com
Hi,

I'm trying to write a wic plugin to generate a bootable partition for a Xilinix zynqmp
board. I've managed building the necessary infrastructure (bootgen) and have the
contents available for the python script. As far as I can tell all gets assembled correctly,
but it doesn't show up in the FAT partition (mounted as /boot on the target).

Is there a documentation available for wic plugins which I've missed? If not, would it
be a mistake for my plugin to derive from the RootfsPlugin? In which way the plugin
controls where the content ends up in the target partition?

TIA,
Uli

Schöne Grüße / Kind regards


Dipl.-Inform. Ulrich Teichert
Senior Software Developer



Phone +49 431 375938-0
_____________________________________

e.bs kumkeo GmbH
Heidenkampsweg 82a
20097 Hamburg, Deutschland
www.kumkeo.de

Geschäftsführer Michael Leitner, Günter Hagspiel
Registergericht Amtsgericht Hamburg
Registernummer HRB 187712
USt-Idnr. DE449906070


Jan Kiszka

unread,
Jan 7, 2025, 12:03:37 PM1/7/25
to Ulrich Teichert, isar-...@googlegroups.com
On 07.01.25 16:57, Ulrich Teichert wrote:
> Hi,
>
> I'm trying to write a wic plugin to generate a bootable partition for a Xilinix zynqmp
> board. I've managed building the necessary infrastructure (bootgen) and have the
> contents available for the python script. As far as I can tell all gets assembled correctly,
> but it doesn't show up in the FAT partition (mounted as /boot on the target).
>

Hmm, I created images for zynqmp before but didn't need that back then:

https://github.com/siemens/jailhouse-images/blob/master/wic/ultra96.wks

What does your plugin have to do differently?

> Is there a documentation available for wic plugins which I've missed? If not, would it
> be a mistake for my plugin to derive from the RootfsPlugin? In which way the plugin
> controls where the content ends up in the target partition?

We are taking wic from upstream OE, and I'm not aware of any generated
doc from what wic has inline. But you could browse it, e.g. here:

https://github.com/ilbers/isar/blob/master/scripts/lib/wic/pluginbase.py

Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center

Ulrich Teichert

unread,
Jan 8, 2025, 2:46:23 AM1/8/25
to Jan Kiszka, isar-...@googlegroups.com
Hi Jan,

>> I'm trying to write a wic plugin to generate a bootable partition for a Xilinix zynqmp
>> board. I've managed building the necessary infrastructure (bootgen) and have the
>> contents available for the python script. As far as I can tell all gets assembled correctly,
>> but it doesn't show up in the FAT partition (mounted as /boot on the target).

>Hmm, I created images for zynqmp before but didn't need that back then:
>
>https://github.com/siemens/jailhouse-images/blob/master/wic/ultra96.wks
>
>What does your plugin have to do differently?

Perhaps it got too complicated - it's my first dip into wic:

part /boot --source bootgen-partition --sourceparams "fsbl=/usr/lib/boot-firmware/fsbl_a53.elf,pmu=/usr/lib/boot-firmware/pmufw.elf,armtfw=/usr/lib/arm-trusted-firmware/zynqmp/bl31.elf,uboot_dir=/usr/lib/boot-firmware/u-boot" --ondisk mmcblk0 --fstype=vfat --label boot --active --align 4096 --size 100M

part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --mkfs-extraopts "-T default" --label root --align 4096 --exclude-path=boot --size 1G

bootloader

In the python script the extra source params are used to generate a BOOT.bin:

import logging
import os
import types

from importlib.machinery import SourceFileLoader
from wic import WicError
from wic.plugins.source.rootfs import RootfsPlugin
from wic.misc import get_bitbake_var, exec_cmd

logger = logging.getLogger('wic')

class BootgenPlugin(RootfsPlugin):
"""
Create a boot.bin with bootgen, contents are at least the FSBL,
the PMU and an U-BOOT FIT image on a FAT partition.
"""

name = 'bootgen-partition'

@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.
"""
logger.debug("bootgen-partition: do_prepare_partition: part: %s", part)

# check for options which have to be set
if source_params.get('fsbl', None) is None:
raise WicError("bootgen-partition: fsbl source_param must be set.")
if source_params.get('pmu', None) is None:
raise WicError("bootgen-partition: pmu source_param must be set.")
if source_params.get('armtfw', None) is None:
raise WicError("bootgen-partition: armtfw source_param must be set.")
if source_params.get('uboot_dir', None) is None:
raise WicError("bootgen-partition: uboot_dir source_param must be set.")

# Prologue from RootfsPlugin.do_prepare_partition, retrieves the
# rootfs directory
if part.rootfs_dir is None:
if not 'ROOTFS_DIR' in rootfs_dir:
raise WicError("Couldn't find --rootfs-dir, exiting")

rootfs_dir = rootfs_dir['ROOTFS_DIR']
else:
if part.rootfs_dir in rootfs_dir:
rootfs_dir = rootfs_dir[part.rootfs_dir]
elif part.rootfs_dir:
rootfs_dir = part.rootfs_dir
else:
raise WicError("Couldn't find --rootfs-dir=%s connection or "
"it is not a valid path, exiting" % part.rootfs_dir)
if os.path.isdir(rootfs_dir):
real_rootfs_dir = rootfs_dir
else:
image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir)
if not os.path.isdir(image_rootfs_dir):
raise WicError("No valid artifact IMAGE_ROOTFS from image "
"named %s has been found at %s, exiting." %
(rootfs_dir, image_rootfs_dir))
real_rootfs_dir = image_rootfs_dir

root_dev = creator.rootdev
if not root_dev:
root_dev = source_params.get("root", None)
if not root_dev:
raise WicError("root not defined, exiting.")
root_dev = root_dev.replace(":", "=")

logger.warn("bootgen: root dev: %s, root fs: %s, build in %s, bootimg_dir: %s", root_dev, real_rootfs_dir, cr_workdir, bootimg_dir)
# copy all parts
cp_cmd = "cp -a %s%s %s" % (real_rootfs_dir, source_params.get('fsbl'), cr_workdir)
exec_cmd(cp_cmd)
cp_cmd = "cp -a %s%s %s" % (real_rootfs_dir, source_params.get('pmu'), cr_workdir)
exec_cmd(cp_cmd)
cp_cmd = "cp -a %s%s %s" % (real_rootfs_dir, source_params.get('armtfw'), cr_workdir)
exec_cmd(cp_cmd)
cp_cmd = "cp -a %s%s/u-boot.elf %s" % (real_rootfs_dir, source_params.get('uboot_dir'), cr_workdir)
exec_cmd(cp_cmd)
cp_cmd = "cp -a %s%s/uboot-env.txt %s" % (real_rootfs_dir, source_params.get('uboot_dir'), cr_workdir)
exec_cmd(cp_cmd)
cp_cmd = "cp -a %s%s/boot.bif %s" % (real_rootfs_dir, source_params.get('uboot_dir'), cr_workdir)
exec_cmd(cp_cmd)
bootgen_cmd = "cd %s && bootgen -arch zynqmp -image boot.bif -o BOOT.bin" % (cr_workdir)
exec_cmd(bootgen_cmd, True)
# we need to create the VFAT image
bootimg = "%s/boot.img" % cr_workdir
label = part.label if part.label else "boot"
dosfs_cmd = "mkfs.fat -n %s -i %s -C %s %d" % \
(label, part.fsuuid, bootimg, part.size)
exec_cmd(dosfs_cmd)

du_cmd = "du -Lbks %s" % bootimg
out = exec_cmd(du_cmd)
bootimg_size = out.split()[0]

part.size = int(bootimg_size)
part.source_file = bootimg


>> Is there a documentation available for wic plugins which I've missed? If not, would it
>> be a mistake for my plugin to derive from the RootfsPlugin? In which way the plugin
>> controls where the content ends up in the target partition?

>We are taking wic from upstream OE, and I'm not aware of any generated
>doc from what wic has inline. But you could browse it, e.g. here:
>
>https://github.com/ilbers/isar/blob/master/scripts/lib/wic/pluginbase.py

Yes, I have seen that, but this only talks about the plugin entry points which are called
but not about where the output of the plugin is expected. Perhaps I am missing
something essential here....
Reply all
Reply to author
Forward
0 new messages