Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v3] wic: Add support for variable sector size when creating ESP
@ 2025-09-15  6:41 Macpaul Lin
  2025-09-17 14:46 ` [OE-core] " Trevor Woerner
  0 siblings, 1 reply; 2+ messages in thread
From: Macpaul Lin @ 2025-09-15  6:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Alexandre Belloni, Alexander Kanavin,
	Richard Purdie, Otavio Salvador, openembedded-core
  Cc: Bear Wang, Pablo Sun, Ramax Lo, Macpaul Lin, Macpaul Lin,
	MediaTek Chromebook Upstream

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-17 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15  6:41 [PATCH v3] wic: Add support for variable sector size when creating ESP Macpaul Lin
2025-09-17 14:46 ` [OE-core] " Trevor Woerner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox