From: Marek Szyprowski Date: Thu, 28 Mar 2024 19:23:46 +0000 (+0100) Subject: tizen: sd_fusing.py: add support for partition start & size specified in sectors X-Git-Tag: accepted/tizen/unified/20241126.175211~91 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24e81de0e6c11ff703c151a57ce1c1b1bbd12002;p=platform%2Fkernel%2Fu-boot.git tizen: sd_fusing.py: add support for partition start & size specified in sectors Add support for specifying partition's start & size in sectors and adjust lba-start parameter (first allowed sector of the first partition) to 34, what is the minimal possible value for the GPT layout. This doesn't affect any start or size of the partitions specified in MBytes, because according to sfdisk manual, they are always aligned to 1MB. Signed-off-by: Marek Szyprowski Change-Id: I8fdccb896072a9cddfe7e185f6650eb0471caae2 --- diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index 5c8b47b6b4..ceecb0cbf5 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/sd_fusing.py @@ -60,14 +60,30 @@ class Partition: def __init__(self, name, size, start=None, ptype=None, fstype="raw", bootable=False, **kwargs): self.name = name self.size = size + self.size_sectors = kwargs.get("size_sectors", None) self.start = start + self.start_sector = kwargs.get("start_sector", None) self.ptype = ptype self.bootable = bootable + if type(self.size_sectors) == int and self.size_sectors >= 0: + if type(self.size) == int and self.size >= 0: + logging.warning(f"partition:{name} overriding size to the value obtained from size_sectors") + # size is used to calculate free space, so adjust it here + self.size = (self.size_sectors * 512 - 1) / (1024*1024) + 1 + if type(self.start_sector) == int and self.start_sector >= 0: + if type(self.start) == int and self.start >= 0: + logging.warning(f"partition:{name} overriding start to the value obtained from start_sector") + self.size = None + def __str__(self): output = [] - if self.start: + if self.start_sector: + output.append(f"start={self.start_sector}") + elif self.start: output.append(f"start={self.start}MiB") - if type(self.size) == int and self.size >= 0: + if type(self.size_sectors) == int and self.size_sectors >= 0: + output.append(f"size={self.size_sectors}") + elif type(self.size) == int and self.size >= 0: output.append(f"size={self.size}MiB") if self.name: output.append(f"name={self.name}") @@ -89,6 +105,8 @@ class Label: self.part_table.append(Partition(**part)) def __str__(self): output = f"label: {self.ltype}\n" + if self.ltype == 'gpt': + output += f"first-lba: 34\n" for part in self.part_table: output += str(part) return output