diff mbox series

[v2] wic: Add support for variable sector size when creating ESP

Message ID 20250910033310.2424072-1-macpaul.lin@mediatek.com
State New
Headers show
Series [v2] wic: Add support for variable sector size when creating ESP | expand

Commit Message

Macpaul Lin Sept. 10, 2025, 3:33 a.m. UTC
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 | 11 +++++++++--
 1 file changed, 9 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'.

Comments

Mathieu Dubois-Briand Sept. 10, 2025, 7:43 a.m. UTC | #1
On Wed Sep 10, 2025 at 5:33 AM CEST, 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>
> ---

Hi,

Thanks for your patch.

It looks like this is breaking some builds, as WIC_SECTOR_SIZE might not
be defined.

ERROR: core-image-minimal-1.0-r0 do_image_wic: Execution of '/srv/pokybuild/yocto-worker/genericx86-64/build/build/tmp/work/genericx86_64-poky-linux/core-image-minimal/1.0/temp/run.do_image_wic.1122779' failed with exit code 1
...
|   File "/srv/pokybuild/yocto-worker/genericx86-64/build/scripts/lib/wic/partition.py", line 199, in prepare
|     plugin.do_prepare_partition(self, srcparams_dict, creator,
|     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|                                 cr_workdir, oe_builddir, bootimg_dir,
|                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|                                 kernel_dir, rootfs_dir, native_sysroot)
|                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|   File "/srv/pokybuild/yocto-worker/genericx86-64/build/scripts/lib/wic/plugins/source/bootimg_efi.py", line 419, in do_prepare_partition
|     sector_size = int(get_bitbake_var("WIC_SECTOR_SIZE"))
| TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

https://autobuilder.yoctoproject.org/valkyrie/#/builders/4/builds/2367

Can you fix this error, please?

Thanks,
Mathieu
diff mbox series

Patch

diff --git a/scripts/lib/wic/plugins/source/bootimg_efi.py b/scripts/lib/wic/plugins/source/bootimg_efi.py
index cf16705a285a..ceffb9aecb06 100644
--- a/scripts/lib/wic/plugins/source/bootimg_efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg_efi.py
@@ -415,8 +415,15 @@  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)
+        # Support variable sector size
+        sector_size = int(get_bitbake_var("WIC_SECTOR_SIZE"))
+
+        size_bytes = blocks * 1024
+        blocks = size_bytes // sector_size
+
+        dosfs_cmd = "mkdosfs -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)))