From: Karol Lewandowski Date: Thu, 23 May 2024 09:14:40 +0000 (+0200) Subject: sd_fusing.py: Ensure selected flashing target actually matches what is on device X-Git-Tag: accepted/tizen/unified/20241126.175211~62 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eeede887a9c79c3ecd95a786ff1bab7f667d5ab5;p=platform%2Fkernel%2Fu-boot.git sd_fusing.py: Ensure selected flashing target actually matches what is on device Currently only partition label and filesystem type are checked, if available. Change-Id: I64c43c7b80843e70876ce16ee7de24a7dc76378d Signed-off-by: Karol Lewandowski --- diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index 8aafc8aef3..a4c35c24c1 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/sd_fusing.py @@ -178,6 +178,17 @@ class SdFusingTarget: sys.exit(1) return [self.binaries.get(binary, None)] + def ensure_parttable(self): + logging.notice(f"Verifying that partition table on {Device} matches target specification") + for partnum, part in enumerate(self.part_table, 1): + bo = subprocess.check_output(["blkid", "-o", "export", Device + str(partnum)]).decode('utf-8') + if "PARTLABEL=" in bo and f"PARTLABEL={part['name']}" not in bo: + logging.error(f'On-device partition label mismatch with selected target: partlabel={part["name"]}, on-device:\n{bo}') + sys.exit(1) + if part['fstype'] not in 'raw' and f"TYPE={part['fstype']}" not in bo: + logging.error(f'On-device partition mismatch with selected target: fstype={part["fstype"]}, on-device:\n{bo}') + sys.exit(1) + def initialize_parameters(self): pass @@ -942,6 +953,7 @@ def check_partition_format(args, target): if not Format: logging.info(f"Skip formatting of {Device}".format(Device)) + target.ensure_parttable() return logging.info(f"Start formatting of {Device}") mkpart(args, target)