wic: Add sector size support to WIC partition and bootimg_efi plugin for UFS
PATCH 1/1 wic: Add sector size support to WIC partition and bootimg_efi plugin for UFS
Introduce --sector-size argument to ksparse.py and propagate sector_size to partition objects. Update bootimg_efi plugin to validate sector size and pass it to mkdosfs, enabling creation of EFI system partitions with variable sector sizes. This change is required to support UFS storage.
--- scripts/lib/wic/help.py | 6 ++++++ scripts/lib/wic/ksparser.py | 1 + scripts/lib/wic/partition.py | 1 + scripts/lib/wic/plugins/source/bootimg_efi.py | 18 ++++++++++++++++-- 4 files changed, 24 insertions(+), 2 deletions(-)
scripts/lib/wic/help.py +6 -0
@@ -885,6 +885,12 @@ DESCRIPTION is larger than --fixed-size and error will be raised when assembling disk image. + --sector-size: The sector size in bytes. The value must be an + integer and one of 512, 1024, or 4096. The + default is 512. This enables a variable sector + size for EFI partitions, which is supported on + devices such as eMMC and UFS storages. + --source: This option is a wic-specific option that names the source of the data that will populate the partition. The most common value for this option
scripts/lib/wic/ksparser.py +1 -0
@@ -182,6 +182,7 @@ class KickStart(): sizeexcl.add_argument('--size', type=sizetype("M"), default=0) sizeexcl.add_argument('--fixed-size', type=sizetype("M"), default=0) + part.add_argument('--sector-size', type=int, default=512) part.add_argument('--source') part.add_argument('--sourceparams') part.add_argument('--system-id', type=systemidtype)
scripts/lib/wic/partition.py +1 -0
@@ -49,6 +49,7 @@ class Partition(): self.rootfs_dir = args.rootfs_dir self.size = args.size self.fixed_size = args.fixed_size + self.sector_size = args.sector_size self.source = args.source self.sourceparams = args.sourceparams self.system_id = args.system_id
scripts/lib/wic/plugins/source/bootimg_efi.py +16 -2
@@ -415,8 +415,22 @@ 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) + # Validate part.fixed_size + if part.sector_size not in (512, 1024, 4096): + logger.debug("Invalid '--sector-size' specified (%s). " \ + "Allowed values are 512, 1024, or 4096. " \ + "Setting to default 512.", + part.sector_size) + part.sector_size = 512 + + # Support variable sector size + # mkdosfs -C expects number of blocks, which is (size in bytes) // sector_size + size_bytes = blocks * 1024 + blocks = size_bytes // part.sector_size + + dosfs_cmd = "mkdosfs -n %s -i %s -C %s %d -S %d" % \ + (label, part.fsuuid, bootimg, blocks, part.sector_size) + exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out)))
Signature · 1 line
2.45.2
Quoted 66 lines · Macpaul Lin via lists.openembedded.org
Introduce --sector-size argument to
ksparse.pyand propagatesector_sizeto partition objects. Updatebootimg_efiplugin to validate sector size and pass it to mkdosfs, enabling creation of EFI system partitions with variable sector sizes. This change is required to support UFS storage.Signed-off-by Macpaul Lin <[email protected]>--- scripts/lib/wic/help.py | 6 ++++++ scripts/lib/wic/ksparser.py | 1 + scripts/lib/wic/partition.py | 1 + scripts/lib/wic/plugins/source/bootimg_efi.py | 18 ++++++++++++++++-- 4 files changed, 24 insertions(+), 2 deletions(-)scripts/lib/wic/help.py +6
-0@@ -885,6 +885,12 @@ DESCRIPTION is larger than --fixed-size and error will be raised when assembling disk image. + --sector-size: The sector size in bytes. The value must be an + integer and one of 512, 1024, or 4096. The + default is 512. This enables a variable sector + size for EFI partitions, which is supported on + devices such as eMMC and UFS storages. + --source: This option is a wic-specific option that names the source of the data that will populate the partition. The most common value for this optionscripts/lib/wic/ksparser.py +1
-0@@ -182,6 +182,7 @@ class KickStart(): sizeexcl.add_argument('--size', type=sizetype("M"), default=0) sizeexcl.add_argument('--fixed-size', type=sizetype("M"), default=0) + part.add_argument('--sector-size', type=int, default=512) part.add_argument('--source') part.add_argument('--sourceparams') part.add_argument('--system-id', type=systemidtype)scripts/lib/wic/partition.py +1
-0@@ -49,6 +49,7 @@ class Partition(): self.rootfs_dir = args.rootfs_dir self.size = args.size self.fixed_size = args.fixed_size + self.sector_size = args.sector_size self.source = args.source self.sourceparams = args.sourceparams self.system_id = args.system_idscripts/lib/wic/plugins/source/bootimg_efi.py +2
-2@@ -415,8 +415,22 @@ 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) + # Validate part.fixed_size + if part.sector_size not in (512, 1024, 4096):
scripts/lib/wic/plugins/source/bootimg_efi.py class BootimgEFIPlugin(SourcePlugin): · line 429
Quoted 10 lines
scripts/lib/wic/plugins/source/bootimg_efi.py +10
-0+ logger.debug("Invalid '--sector-size' specified (%s). " \ + "Allowed values are 512, 1024, or 4096. " \ + "Setting to default 512.", + part.sector_size) + part.sector_size = 512 + + # Support variable sector size + # mkdosfs -C expects number of blocks, which is (size in bytes) // sector_size + size_bytes = blocks * 1024 + blocks = size_bytes // part.sector_size
I believe that this can be off by one, on the short side. E.g. if sector_size = 4096 and the original value of blocks = $n * 4 + 3, then the final blocks will end up as $n, and the last 3kB is cut off.
scripts/lib/wic/plugins/source/bootimg_efi.py class BootimgEFIPlugin(SourcePlugin): · line 432
Quoted 3 lines
scripts/lib/wic/plugins/source/bootimg_efi.py +3
-0+ + dosfs_cmd = "mkdosfs -n %s -i %s -C %s %d -S %d" % \ + (label, part.fsuuid, bootimg, blocks, part.sector_size)
The "-v" argument seems to be lost - could you please add it back?
Quoted 13 lines
scripts/lib/wic/plugins/source/bootimg_efi.py +1
-1+ exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out))) -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#223111): https://lists.openembedded.org/g/openembedded-core/message/223111
Mute This Topic: https://lists.openembedded.org/mt/115150315/6084445
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 4 lines · Macpaul Lin via lists.openembedded.org
Introduce --sector-size argument to
ksparse.pyand propagatesector_sizeto partition objects. Updatebootimg_efiplugin to validate sector size and pass it to mkdosfs, enabling creation of EFI system partitions with variable sector sizes. This change is required to support UFS storage.
For which branch is this patch?
Doesn't master already have sector-size support in:
oe-core: 2255f28b579b ("wic: add WIC_SECTOR_SIZE variable")
Quoted 66 lines
Signed-off-by Macpaul Lin <[email protected]>--- scripts/lib/wic/help.py | 6 ++++++ scripts/lib/wic/ksparser.py | 1 + scripts/lib/wic/partition.py | 1 + scripts/lib/wic/plugins/source/bootimg_efi.py | 18 ++++++++++++++++-- 4 files changed, 24 insertions(+), 2 deletions(-)scripts/lib/wic/help.py +6
-0@@ -885,6 +885,12 @@ DESCRIPTION is larger than --fixed-size and error will be raised when assembling disk image. + --sector-size: The sector size in bytes. The value must be an + integer and one of 512, 1024, or 4096. The + default is 512. This enables a variable sector + size for EFI partitions, which is supported on + devices such as eMMC and UFS storages. + --source: This option is a wic-specific option that names the source of the data that will populate the partition. The most common value for this optionscripts/lib/wic/ksparser.py +1
-0@@ -182,6 +182,7 @@ class KickStart(): sizeexcl.add_argument('--size', type=sizetype("M"), default=0) sizeexcl.add_argument('--fixed-size', type=sizetype("M"), default=0) + part.add_argument('--sector-size', type=int, default=512) part.add_argument('--source') part.add_argument('--sourceparams') part.add_argument('--system-id', type=systemidtype)scripts/lib/wic/partition.py +1
-0@@ -49,6 +49,7 @@ class Partition(): self.rootfs_dir = args.rootfs_dir self.size = args.size self.fixed_size = args.fixed_size + self.sector_size = args.sector_size self.source = args.source self.sourceparams = args.sourceparams self.system_id = args.system_idscripts/lib/wic/plugins/source/bootimg_efi.py +6
-2@@ -415,8 +415,22 @@ 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) + # Validate part.fixed_size + if part.sector_size not in (512, 1024, 4096): + logger.debug("Invalid '--sector-size' specified (%s). " \ + "Allowed values are 512, 1024, or 4096. " \ + "Setting to default 512.", + part.sector_size)
scripts/lib/wic/plugins/source/bootimg_efi.py class BootimgEFIPlugin(SourcePlugin): · line 433
Quoted 10 lines
scripts/lib/wic/plugins/source/bootimg_efi.py +10
-0+ part.sector_size = 512 + + # Support variable sector size + # mkdosfs -C expects number of blocks, which is (size in bytes) // sector_size + size_bytes = blocks * 1024 + blocks = size_bytes // part.sector_size + + dosfs_cmd = "mkdosfs -n %s -i %s -C %s %d -S %d" % \ + (label, part.fsuuid, bootimg, blocks, part.sector_size) +
If you want to do sanity testing of supplied values that should be done early in the front-end part of wic, not in the back-end plugins. Otherwise every plugin will need to perform this same check (unless you're suggesting different plugins should allow different sets of values?).
Quoted 16 lines
scripts/lib/wic/plugins/source/bootimg_efi.py +0
-0exec_native_cmd(dosfs_cmd, native_sysroot) logger.debug("mkdosfs:\n%s" % (str(out)))Signature · 11 lines
2.45.2 -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#223111): https://lists.openembedded.org/g/openembedded-core/message/223111 Mute This Topic: https://lists.openembedded.org/mt/115150315/900817 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
Quoted 12 lines · Trevor Woerner
Quoted 8 lines · Macpaul Lin via lists.openembedded.org
Introduce --sector-size argument to
ksparse.pyand propagatesector_size
to partition objects. Updatebootimg_efiplugin to validate sector size
and pass it to mkdosfs, enabling creation of EFI system partitions with
variable sector sizes. This change is required to support UFS storage.
Quoted 5 lines
For which branch is this patch?
Doesn't master already have sector-size support in:
oe-core:2255f28b579b("wic: addWIC_SECTOR_SIZEvariable")
This patch is for master branch.WIC_SECTOR_SIZE seems only applies to most of the partitions includes roofs partition. However, it doesn't applied to EFI partition because this parameter dose not apply to command 'mkdosfs' with the '-S' parameters.
I'm not familiar with how to propagate WIC_SECTOR_SIZE to this plugin. If there is a hint I could update a new patch asap.
However, shouldn't we considering of supporting 2 storages on the devices? For some boards supports both emmc and UFS. The EFI partition might exists on a boot storage and rootfs exists on the other storage?
Anyway, the key point for this patch is to add '-S' option to mkdosfs to ensure the sector size is correct.
Quoted 91 lines
Quoted 91 lines
Signed-off-by Macpaul Lin <[email protected]>---
scripts/lib/wic/help.py | 6 ++++++ scripts/lib/wic/ksparser.py | 1 + scripts/lib/wic/partition.py | 1 +scripts/lib/wic/plugins/source/bootimg_efi.py| 18
++++++++++++++++--4 files changed, 24 insertions(+), 2 deletions(-)scripts/lib/wic/help.py +0
-0@@ -885,6 +885,12 @@ DESCRIPTIONis larger than --fixed-size and error will be
raised when assembling disk image.+ --sector-size: The sector size in bytes. The value must be an
+ integer and one of 512, 1024, or 4096. The + default is 512. This enables a variable sector
+ size for EFI partitions, which is supported on
+ devices such as eMMC and UFS storages. +
--source: This option is a wic-specific option that names the
source of the data that will populate the partition. The most common value for this optionscripts/lib/wic/ksparser.py +1
-0@@ -182,6 +182,7 @@ class KickStart(): sizeexcl.add_argument('--size', type=sizetype("M"), default=0) sizeexcl.add_argument('--fixed-size', type=sizetype("M"), default=0) + part.add_argument('--sector-size', type=int, default=512) part.add_argument('--source')
part.add_argument('--sourceparams')part.add_argument('--system-id', type=systemidtype)scripts/lib/wic/partition.py +0
-0@@ -49,6 +49,7 @@ class Partition():self.rootfs_dir = args.rootfs_dir
self.size = args.size
self.fixed_size = args.fixed_size
+ self.sector_size = args.sector_size
self.source = args.source
self.sourceparams = args.sourceparams
self.system_id = args.system_idscripts/lib/wic/plugins/source/bootimg_efi.py +0
-0@@ -415,8 +415,22 @@ 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) + # Validate part.fixed_size
+ if part.sector_size not in (512, 1024, 4096):
+ logger.debug("Invalid '--sector-size' specified (%s). " \
+ "Allowed values are 512, 1024, or 4096. " \
+ "Setting to default 512.",
+ part.sector_size)
+ part.sector_size = 512
+
+ # Support variable sector size
+ # mkdosfs -C expects number of blocks, which is (size in bytes) //sector_size
+size_bytes= blocks * 1024
+ blocks =size_bytes// part.sector_size
+
+dosfs_cmd= "mkdosfs -n %s -i %s -C %s %d -S %d" % \
+ (label, part.fsuuid, bootimg, blocks, part.sector_size)
Quoted 9 lines
Quoted 1 line
+
If you want to do sanity testing of supplied values that should be done early
in the front-end part of wic, not in the back-end plugins. Otherwise every
plugin will need to perform this same check (unless you're suggesting different plugins should allow different sets of values?).
This is not for testing supplied values. It just trying to avoid user making a wrong sector size from the top wks file.
Okay I can drop supplied value checking here. But the blocks depends on the sector size, the calculation codes should be kept.
Quoted 8 lines
Quoted 8 lines
exec_native_cmd(dosfs_cmd, native_sysroot)logger.debug("mkdosfs:\n%s" % (str(out)))--
2.45.2Thanks for the review.
Will try to update the v2 patch later.
BR,
Macpaul Lin