| Message ID | 20250915064137.4025945-1-macpaul.lin@mediatek.com |
|---|---|
| State | New |
| Headers | show |
| Series | [v3] wic: Add support for variable sector size when creating ESP | expand |
Hi, Out of curiosity, are you in a situation where only one partition (your ESP partition) is using UFS and the rest of your image is using the regular sector size? This patch is useful for you and if the oe maintainers are okay with it there's no technical problem with it. But it is very narrow, it only provides a variable sector size in the case of the ESP where someone is using the bootimg_efi source plugin. In my opinion, the whole variable sector size thing needs a comprehensive overhaul, not just for specific use-cases at a time. But I understand you probably need this to un-stick yourself so you can move on with your project ;-) At work my team has a more comprehensive variable sector size solution that allows us to build wic an wic.ufs images in parallel, but it assumes each entire image is one sector size (wic=512, wic.ufs=4096), and it is against scarthgap. If there are use-cases where different sector sizes are required per partition within the same image, then the only logical place to support that is with a partition option on individual lines of the wks file. E.g.: part /efi --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024 --sector-size 4096 part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0" On Mon 2025-09-15 @ 02:41:37 PM, Macpaul Lin via lists.openembedded.org wrote: > Derive sector_size from the WIC_SECTOR_SIZE BitBake variable. > Recalculate blocks to align with the chosen sector size. > While the default sector size of mkdosfs is 512 bytes. > Pass -S <sector_size> to align the setting of WIC_SECTOR_SIZE. > > Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com> > --- > scripts/lib/wic/plugins/source/bootimg_efi.py | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > Changes for v2: > - drop --sector-size, use get_bitbake_var("WIC_SECTOR_SIZE") instead. > - drop value filter of sector-size. > - drop creating new sub-varible for 'part'. > > Changes for v3: > - Add -v option back for mkdosfs. > - Round up the value of blocks instead of round dwon. > > diff --git a/scripts/lib/wic/plugins/source/bootimg_efi.py b/scripts/lib/wic/plugins/source/bootimg_efi.py > index cf16705a285a..288fe6a15a7d 100644 > --- a/scripts/lib/wic/plugins/source/bootimg_efi.py > +++ b/scripts/lib/wic/plugins/source/bootimg_efi.py > @@ -415,8 +415,19 @@ class BootimgEFIPlugin(SourcePlugin): > > label = part.label if part.label else "ESP" > > - dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d" % \ > - (label, part.fsuuid, bootimg, blocks) > + # define sector size, default is 512 for mkdosfs > + sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') > + if sector_size_str is not None and str(sector_size_str).isdigit(): > + sector_size = int(sector_size_str) > + else: > + sector_size = 512 > + > + size_bytes = blocks * 1024 > + blocks = (size_bytes + sector_size - 1) // sector_size > + > + dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d -S %d" % \ > + (label, part.fsuuid, bootimg, blocks, sector_size) > + > exec_native_cmd(dosfs_cmd, native_sysroot) > logger.debug("mkdosfs:\n%s" % (str(out))) > > -- > 2.45.2 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#223386): https://lists.openembedded.org/g/openembedded-core/message/223386 > Mute This Topic: https://lists.openembedded.org/mt/115249776/900817 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [twoerner@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
diff --git a/scripts/lib/wic/plugins/source/bootimg_efi.py b/scripts/lib/wic/plugins/source/bootimg_efi.py index cf16705a285a..288fe6a15a7d 100644 --- a/scripts/lib/wic/plugins/source/bootimg_efi.py +++ b/scripts/lib/wic/plugins/source/bootimg_efi.py @@ -415,8 +415,19 @@ class BootimgEFIPlugin(SourcePlugin): label = part.label if part.label else "ESP" - dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d" % \ - (label, part.fsuuid, bootimg, blocks) + # define sector size, default is 512 for mkdosfs + sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') + if sector_size_str is not None and str(sector_size_str).isdigit(): + sector_size = int(sector_size_str) + else: + sector_size = 512 + + size_bytes = blocks * 1024 + blocks = (size_bytes + sector_size - 1) // sector_size + + dosfs_cmd = "mkdosfs -v -n %s -i %s -C %s %d -S %d" % \ + (label, part.fsuuid, bootimg, blocks, sector_size) + exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out)))
Derive sector_size from the WIC_SECTOR_SIZE BitBake variable. Recalculate blocks to align with the chosen sector size. While the default sector size of mkdosfs is 512 bytes. Pass -S <sector_size> to align the setting of WIC_SECTOR_SIZE. Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com> --- scripts/lib/wic/plugins/source/bootimg_efi.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) Changes for v2: - drop --sector-size, use get_bitbake_var("WIC_SECTOR_SIZE") instead. - drop value filter of sector-size. - drop creating new sub-varible for 'part'. Changes for v3: - Add -v option back for mkdosfs. - Round up the value of blocks instead of round dwon.