From: Jacek Kryszyn Date: Mon, 23 Sep 2024 04:01:29 +0000 (+0200) Subject: scripts: sd_fusing: get rid of user_partition attribute X-Git-Tag: accepted/tizen/unified/20241101.174134~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=56750a7a8fe678c125f2a75eec45039b73b692a7;p=platform%2Fkernel%2Fu-boot.git scripts: sd_fusing: get rid of user_partition attribute The SdFusingTarget class has the user_partition attribute which informs about the index of the user partition in the part_table. It has to be set manually for each target. This change removes the attribute and adds calculation of the index. Change-Id: I2a0827dac255bd4715ab04cd050e8fd9d14edb40 Signed-off-by: Jacek Kryszyn --- diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index e894e01af7..3368dbbe90 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/sd_fusing.py @@ -125,14 +125,20 @@ class SdFusingTarget: self.device = device total_size = device_size(device) - if hasattr(self, 'user_partition'): + # find user partition and calculate its size + n = None + for i, p in enumerate(self.part_table): + if p['name'] == 'user': + n = i; + break + + if n is not None: self.user_size = total_size - self.reserved_space - \ reduce(lambda x, y: x + (y["size"] or 0), self.part_table, 0) if self.user_size < 100: logging.error(f"Not enough space for user data ({self.user_size}). Use larger storage.") raise OSError(errno.ENOSPC, os.strerror(errno.ENOSPC), device) - # self.user_partition counts from 0 - self.part_table[self.user_partition]["size"] = self.user_size + self.part_table[n]["size"] = self.user_size self.label = Label(self.part_table, ltype) self.binaries = self._get_binaries('binaries') @@ -295,7 +301,6 @@ class Rpi3(InitParams, SdFusingTarget): def __init__(self, device, args): self.reserved_space = 12 - self.user_partition = 4 super().__init__(device, "dos") class OdroidC4(InitParams, SdFusingTarget): @@ -329,7 +334,6 @@ class OdroidC4(InitParams, SdFusingTarget): def __init__(self, device, args): self.reserved_space = 12 - self.user_partition = 4 super().__init__(device, "dos") class Rpi4Super(InitParams, SdFusingTargetAB): @@ -368,7 +372,6 @@ class Rpi4Super(InitParams, SdFusingTargetAB): def __init__(self, device, args): self.reserved_space = 8 - self.user_partition = 4 self.update = args.update super().__init__(device, "gpt") self.with_super = True @@ -415,7 +418,6 @@ class Rpi4(InitParams, SdFusingTargetAB): def __init__(self, device, args): self.reserved_space = 5 - self.user_partition = 4 self.update = args.update super().__init__(device, "gpt") @@ -469,7 +471,6 @@ class Rpi4AoT(InitParams, SdFusingTargetAB): def __init__(self, device, args): self.reserved_space = 5 - self.user_partition = 4 self.update = args.update super().__init__(device, "gpt") @@ -507,7 +508,6 @@ class RV64(InitParams, SdFusingTarget): ] def __init__(self, device, args): - self.user_partition = 6 self.reserved_space = 5 self.apply_partition_sizes(args.partition_sizes) super().__init__(device, 'gpt') @@ -559,7 +559,6 @@ class VF2(InitParams, SdFusingTargetAB): ] def __init__(self, device, args): - self.user_partition = 6 self.reserved_space = 5 self.update = args.update self.apply_partition_sizes(args.partition_sizes) @@ -606,7 +605,6 @@ class VF2Super(InitParams, SdFusingTargetAB): ] def __init__(self, device, args): - self.user_partition = 6 self.reserved_space = 5 self.update = args.update super().__init__(device, 'gpt') @@ -661,7 +659,6 @@ class LicheePi4A(InitParams, SdFusingTargetAB): ] def __init__(self, device, args): - self.user_partition = 4 self.reserved_space = 5 self.update = args.update self.apply_partition_sizes(args.partition_sizes) @@ -711,7 +708,6 @@ class LicheePi4ASuper(InitParams, SdFusingTargetAB): def __init__(self, device, args): self.reserved_space = 8 - self.user_partition = 4 self.update = args.update super().__init__(device, 'gpt') self.with_super = True @@ -796,7 +792,6 @@ class BpiF3(InitParams, SdFusingTargetAB): ] def __init__(self, device, args): - self.user_partition = 6 self.reserved_space = 5 self.update = args.update self.apply_partition_sizes(args.partition_sizes)