@@ -1011,6 +1011,17 @@ class Wic2(WicTestCase):
"1:0.50kiB:102400kiB:102400kiB:ext4::;",
])
+ with NamedTemporaryFile("w", suffix=".wks") as tempf:
+ # Test that a partition size can be provided in segments (512 bytes) using "s" prefix
+ tempf.write("bootloader --ptable msdos\n" \
+ "part / --source rootfs --ondisk hda --offset 1s --fixed-size 10000s --fstype=fat16\n")
+ tempf.flush()
+
+ _, partlns = self._get_wic_partitions(tempf.name, native_sysroot)
+ self.assertEqual(partlns, [
+ "1:0.50kiB:5000kiB:5000kiB:fat16::;",
+ ])
+
with NamedTemporaryFile("w", suffix=".wks") as tempf:
# Test that image creation fails if the partitions would overlap
tempf.write("bootloader --ptable gpt\n" \
@@ -51,7 +51,7 @@ class KickStartParser(ArgumentParser):
def error(self, message):
raise ArgumentError(None, message)
-def sizetype(default, size_in_bytes=False):
+def sizetype(default):
def f(arg):
"""
Custom type for ArgumentParser
@@ -68,19 +68,14 @@ def sizetype(default, size_in_bytes=False):
raise ArgumentTypeError("Invalid size: %r" % arg)
- if size_in_bytes:
- if suffix == 's' or suffix == 'S':
- return size * 512
- mult = 1024
- else:
- mult = 1
-
+ if suffix == 's' or suffix == 'S':
+ return size * 512
if suffix == "k" or suffix == "K":
- return size * mult
+ return size * 1024
if suffix == "M":
- return size * mult * 1024
+ return size * (1024 ** 2)
if suffix == "G":
- return size * mult * 1024 * 1024
+ return size * (1024 ** 3)
raise ArgumentTypeError("Invalid size: %r" % arg)
return f
@@ -149,7 +144,7 @@ class KickStart():
part.add_argument('mountpoint', nargs='?')
part.add_argument('--active', action='store_true')
part.add_argument('--align', type=int)
- part.add_argument('--offset', type=sizetype("K", True))
+ part.add_argument('--offset', type=sizetype("K"))
part.add_argument('--exclude-path', nargs='+')
part.add_argument('--include-path', nargs='+', action='append')
part.add_argument('--change-directory')
@@ -363,7 +363,7 @@ class PartitionedImage():
imager.updated_fstab_path)
# Converting kB to sectors for parted
- part.size_sec = part.disk_size * 1024 // self.sector_size
+ part.size_sec = part.disk_size // self.sector_size
def layout_partitions(self):
""" Layout the partitions, meaning calculate the position of every
@@ -422,12 +422,12 @@ class PartitionedImage():
# gaps we could enlargea the previous partition?
# Calc how much the alignment is off.
- align_sectors = self.offset % (part.align * 1024 // self.sector_size)
+ align_sectors = self.offset % (part.align // self.sector_size)
if align_sectors:
# If partition is not aligned as required, we need
# to move forward to the next alignment point
- align_sectors = (part.align * 1024 // self.sector_size) - align_sectors
+ align_sectors = (part.align // self.sector_size) - align_sectors
logger.debug("Realignment for %s%s with %s sectors, original"
" offset %s, target alignment is %sK.",
Since 938595d1dc("wic: Add 512 Byte alignment to --offset") wic parser supports "s"/"S" suffixes, that can be used to align partition on 512 byte boundary. Nevertheless, the minimum value of size is still 1Kb. Introduce support for "s"/"S" suffixes for --size/--fixes-size. This is required for some SoCs (like i.MX8M/MM, where SIT image is stored on 0x8200, and actual boot image is at 0x8400). Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io> --- meta/lib/oeqa/selftest/cases/wic.py | 11 +++++++++++ scripts/lib/wic/ksparser.py | 19 +++++++------------ scripts/lib/wic/plugins/imager/direct.py | 6 +++--- 3 files changed, 21 insertions(+), 15 deletions(-)