From 2d27ebf7f6ebf999f1e5cfe4fe7330201625f14c Mon Sep 17 00:00:00 2001 From: Jacek Kryszyn Date: Wed, 10 Jul 2024 16:11:21 +0200 Subject: [PATCH] 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 --- scripts/tizen/sd_fusing.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index c86bf4067f..bd1c635862 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/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): -- 2.34.1