From 6d90d0ba44a00fc92861040b05f39e0ef93d9b99 Mon Sep 17 00:00:00 2001 From: Vince Chang Date: Mon, 28 Oct 2024 11:46:17 +0800 Subject: wic: add WIC_SECTOR_SIZE variable Currently WIC is unable to generate images that requires a sector size different of 512. Add WIC_SECTOR_SIZE variable to handle the sector size of 4096 for UFS. For "wic ls" command modify get_partitions() to support WIC_SECTOR_SIZE. (From OE-Core rev: 2255f28b579bc5db4138bcacbb829661ae0ee721) Signed-off-by: Vince Chang Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- scripts/lib/wic/engine.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'scripts/lib/wic/engine.py') diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index ce7e6c5d75..64b1d52882 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py @@ -232,6 +232,16 @@ class Disk: self._psector_size = None self._ptable_format = None + # define sector size + sector_size_str = get_bitbake_var('WIC_SECTOR_SIZE') + if sector_size_str is not None: + try: + self.sector_size = int(sector_size_str) + except ValueError: + self.sector_size = None + else: + self.sector_size = None + # find parted # read paths from $PATH environment variable # if it fails, use hardcoded paths @@ -258,7 +268,13 @@ class Disk: def get_partitions(self): if self._partitions is None: self._partitions = OrderedDict() - out = exec_cmd("%s -sm %s unit B print" % (self.parted, self.imagepath)) + + if self.sector_size is not None: + out = exec_cmd("export PARTED_SECTOR_SIZE=%d; %s -sm %s unit B print" % \ + (self.sector_size, self.parted, self.imagepath), True) + else: + out = exec_cmd("%s -sm %s unit B print" % (self.parted, self.imagepath)) + parttype = namedtuple("Part", "pnum start end size fstype") splitted = out.splitlines() # skip over possible errors in exec_cmd output -- cgit v1.2.3-54-g00ecf