From: Marek Szyprowski Date: Mon, 5 Aug 2024 15:42:12 +0000 (+0200) Subject: scripts: sd_fusing: Add support for writing image at specified absolute sector X-Git-Tag: accepted/tizen/unified/20241126.175211~42 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f0b44e6d2ee2b78549ac03e22b8352521946ab6;p=platform%2Fkernel%2Fu-boot.git scripts: sd_fusing: Add support for writing image at specified absolute sector Add support for writing raw images at the specified absolute sector of the target device without the need to create a MBR or GPT partition for it. Signed-off-by: Marek Szyprowski Change-Id: Ia3a8f1eb9ba12d0541700cf4e9358f33290f3ec8 --- diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index dc0015e492..a0c6bef867 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/sd_fusing.py @@ -177,6 +177,12 @@ class SdFusingTarget: sys.exit(1) return [self.binaries.get(binary, None)] + def get_raw_binary_sector(self, binary): + for entry in self.raw_binary_table: + if entry['binaries'] == binary: + return entry['start_sector']; + return 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): @@ -1081,7 +1087,33 @@ def get_device_kname(device): logging.error("kname entry not found") sys.exit(1) +def do_fuse_raw(f, name, target, sector): + argv = ['dd', 'bs=512', + 'oflag=direct', + f'seek={sector}', + 'conv=nocreat', + 'status=progress', + f"of={Device}"] + logging.debug(" ".join(argv)) + proc_dd = subprocess.Popen(argv, + bufsize=(1 << 9), + stdin=subprocess.PIPE, + stdout=None, stderr=None) + logging.notice(f"Writing {name} to {Device} at sector {sector}") + f.seek(0) + buf = f.read(1 << 9) + while len(buf) > 0: + proc_dd.stdin.write(buf) + buf = f.read(1 << 9) + proc_dd.communicate() + logging.info("Done") + #TODO: verification + def do_fuse_file(f, name, target): + sector = target.get_raw_binary_sector(name) + if sector is not None: + do_fuse_raw(f, name, target, sector) + return indexes = target.get_partition_index_list(name) if len(indexes) == 0: logging.info(f"No partition defined for {name}, skipping.")