From: Jacek Kryszyn Date: Wed, 10 Jul 2024 14:11:21 +0000 (+0200) Subject: scripts: sd_fusing: Modifiy size of slots on super X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3a3bd39d7c2369d170ecbe4ac48025293f51d372;p=platform%2Fkernel%2Ftizen-fusing-scripts.git scripts: sd_fusing: Modifiy size of slots on super Size of a slot on the super partition is now determined using value given in the partition table of the rpi4s target. This way it is guaranteed that the super.img will fit on the designated partition. Change-Id: Icdf07228156d7ac78322767c906f502abfa03c79 Signed-off-by: Jacek Kryszyn --- diff --git a/sd_fusing.py b/sd_fusing.py index c86bf40..bd1c635 100755 --- a/sd_fusing.py +++ b/sd_fusing.py @@ -331,7 +331,6 @@ class Rpi4Super(InitParams, SdFusingTargetAB): self.update = args.update super().__init__(device, "gpt") self.with_super = True - self.super_alignment = 1048576 class Rpi4(InitParams, SdFusingTargetAB): long_name = "Raspberry Pi 4" @@ -571,7 +570,6 @@ class VF2Super(InitParams, SdFusingTargetAB): self.update = args.update super().__init__(device, 'gpt') self.with_super = True - self.super_alignment = 1048576 class LicheePi4A(InitParams, SdFusingTargetAB): long_name = "LicheePi4A" @@ -672,7 +670,6 @@ class LicheePi4ASuper(InitParams, SdFusingTargetAB): self.update = args.update super().__init__(device, 'gpt') self.with_super = True - self.super_alignment = 1048576 class X86emu(SdFusingTarget): @@ -1110,7 +1107,19 @@ def do_fuse_file(f, name, target): def do_fuse_image_super(tmpd, target): metadata_slots = 2 metadata_size = 65536 + header_size = 1024 * 1024 # default alignment used in lpmake + super_size = 0 + for p in target.label.part_table: + if p.name == "super": + super_size = p.size * 1024 * 1024 # size of parts is in MiB. Change to B + break + + if super_size == 0: + logging.error(f"No information found about super partition, cannot create image") + sys.exit(1) + + group_size = int((super_size - header_size) / 2); hal_path = os.path.join(tmpd, 'hal.img') rootfs_path = os.path.join(tmpd, 'rootfs.img') super_path = os.path.join(tmpd, 'super.img') @@ -1120,22 +1129,12 @@ def do_fuse_image_super(tmpd, target): rootfs_size = os.stat(rootfs_path).st_size except FileNotFoundError as e: fn = os.path.split(e.filename)[-1] - logging.warning(f"{fn} is missing, skipping super partition image") - return - - group_size = 2 * (hal_size + rootfs_size) - super_size = 2 * group_size - - # calculate additional space needed for metadata. - # There are 2 metadata slots having 65536 B each. 131072 B in total - additional_space = (metadata_slots * metadata_size) / target.super_alignment + logging.error(f"{fn} is missing, cannot create super partition image") + sys.exit(1) - if additional_space > 1: - # if metadata takes more than super alignment, add 1 MiB to super - super_size += 1024*1024 - else: - # if metadata takes less than super alignment, add alignment size to super - super_size += target.super_alignment + if group_size < hal_size + rootfs_size: + logging.error(f"rootfs and hal are too big to fit in a slot on a super partition") + sys.exit(1) argv = ["lpmake", "-F", f"-o={super_path}", @@ -1159,6 +1158,7 @@ def do_fuse_image_super(tmpd, target): if proc.returncode != 0: logging.error("Failed to create super.img") + sys.exit(1) do_fuse_image(super_path, target) def do_fuse_image_tarball(tarball, tmpd, target):