diff options
author | Leonid <l.sawin@samsung.com> | 2023-10-13 09:18:40 +0200 |
---|---|---|
committer | Jaehoon Chung <jh80.chung@samsung.com> | 2023-10-20 03:59:17 +0000 |
commit | d2f1268ab6a8ae40b2e2ed644ab1399825fba7d7 (patch) | |
tree | ce41f361785be30e603d62f1a4a890903dec0fb1 | |
parent | a098c6d5b28016028e21f0814dc1c077ab3833e0 (diff) | |
download | u-boot-d2f1268ab6a8ae40b2e2ed644ab1399825fba7d7.tar.gz u-boot-d2f1268ab6a8ae40b2e2ed644ab1399825fba7d7.tar.bz2 u-boot-d2f1268ab6a8ae40b2e2ed644ab1399825fba7d7.zip |
scripts: add --partition-size feat to sd_fusing.py
The idea is to alter partition sizes via
overriding part_table prior to SdFusingTarget.__init__
to avoid hardcoding it every time you need such a change.
Implemented in SdFusingTarget.apply_partition_sizes
Currently only called (and tested) for RV64 target
Change-Id: Ia070359b47b9c3bfbbdb7881ddf43fb16d2df4a3
Signed-off-by: Leonid <l.sawin@samsung.com>
(cherry picked from commit 304aa532036b5c81553787dfcb33dc6376ad6e91)
-rwxr-xr-x | scripts/tizen/sd_fusing.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index bf2428d398..7cd72be073 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/sd_fusing.py @@ -106,6 +106,23 @@ class SdFusingTarget: self.label = Label(self.part_table, ltype) self.binaries = self._get_binaries('binaries') + def apply_partition_sizes(self, partition_sizes): + if partition_sizes is None or len(partition_sizes) == 0: + return 0 + resized_total = 0 + for name, size in partition_sizes.items(): + resized_count = 0 + for part in self.part_table: + if part['name'] == name: + psize = part['size'] + part['size'] = size + logging.debug(f"overriding partition:{name}, old-size:{psize} MiB new-size:{size} MiB") + resized_count = resized_count + 1 + if resized_count == 0: + logging.error(f"partition:{name} not found when attempting to apply_partition_sizes") + resized_total = resized_total + resized_count + return resized_total + def _get_binaries(self, key): binaries = {} for i, p in enumerate(self.part_table): @@ -338,6 +355,7 @@ class RV64(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') class VF2(RV64): @@ -717,6 +735,10 @@ if __name__ == '__main__': parser.add_argument("--log-level", dest="log_level", default="warning", help="Verbosity, possible values: debug, info, warning, " "error, critical (default: warning)") + parser.add_argument("--partition-size", type=str, action="extend", dest="partition_sizes", + nargs='*', + help="override default partition size (in MiB) (used with --format), " + "may be used multiple times, for example: --partition-size hal_a=256") parser.add_argument("--size", type=int, default=8192, help="size of the backing file to create (in MiB)") parser.add_argument("-t", "--target", required=True, @@ -739,6 +761,18 @@ if __name__ == '__main__': if args.device is None: parser.error('-d/--device argument is required for normal operation') + if args.partition_sizes is not None: + partition_sizes = {} + for eqstr in args.partition_sizes: + ptstr = eqstr.split('=') + if len(ptstr) == 2: + name = ptstr[0] + size = int(ptstr[1]) + partition_sizes[name] = size + else: + parser.error('--partition-size must follow the name=size pattern') + args.partition_sizes = partition_sizes + conh = ColorStreamHandler(format='%(asctime)s.%(msecs)d %(debuginfo)s%(levelname)-8s %(message)s', cformat='%(asctime)s.%(msecs)d %(debuginfo)s%(levelcolor)s%(message)s', datefmt='%Y-%m-%dT%H:%M:%S') |