Skip to contentSkip to conversation

wic: Add support for variable sector size when creating ESP

PATCH Superseded Macpaul Lin 2 participants 3 messages Sep 10, 2025 – Sep 11, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wic: Add support for variable sector size when creating ESP

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.

---
 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'.

scripts/lib/wic/plugins/source/bootimg_efi.py +9 -2
index cf16705a285a..ceffb9aecb06 100644
@@ -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)))
 
Signature · 1 line
2.45.2
#1 lore raw
Quoted 7 lines · Macpaul Lin via lists.openembedded.org

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.

---

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

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw
Quoted 43 lines · Mathieu Dubois-Briand
Quoted 7 lines · Macpaul Lin via lists.openembedded.org

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.

---

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
...

Quoted 10 lines

  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)

Quoted 8 lines


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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'

Quoted 7 lines

https://urldefense.com/v3/__https://autobuilder.yoctoproject.org/valkyrie/*/builders/4/builds/2367__;Iw!!CTRNKA9wMg0ARbw!kFHVngqsZV-hMHkZLpBK1OA94KV8NYcWQzI6MI5RcOKVJmidcWl6cUtJXokTi6MAYhc1VaKlXDLsGT_9GKtIgHO7u_DymXQ$

Can you fix this error, please?

Thanks,
Mathieu

Oh my god. I have only ARM environment to test.
I've checked scripts/lib/wic/engine.py
The check seems only to assign sector_size is None or the other value. Not sure if this would help for x86 platforms.
Will include the check logic in v3.

Quoted 3 lines

--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering

Thanks
Macpaul Lin