scripts: sd_fusing: Fix to write both a/b partition
authorSangYoun Kwak <sy.kwak@samsung.com>
Thu, 11 Jul 2024 11:46:50 +0000 (20:46 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 28 Oct 2024 11:28:46 +0000 (20:28 +0900)
If sd_fusing script is executed with '--update ab' option, it should
write images to both a/b partitions.

When writing images, first, script reads image and writes to the
partition a until the image reaches the end.
Next, script reads image and writes to the partition b but it uses same
file object so there is nothing left to read. Thus, script writes
nothing to the partition b.

To fix this issue, a method call of the file object ".seek(0)" is added
before writing to the partitions. This will set cursor to the initial
position and the the image can be written to the partition b.

Change-Id: I78c1b3c77b6666a133527ba544911de8c4de44d4
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
scripts/tizen/sd_fusing.py

index bd1c6358622adefcf9783679e806234b468db508..c776a3c605cdde1e6bd9bf71634b360ab2d7ef9a 100755 (executable)
@@ -15,7 +15,7 @@ import sys
 import tarfile
 import tempfile
 
-__version__ = "1.1.6"
+__version__ = "1.1.7"
 
 Format = False
 Device = ""
@@ -1093,6 +1093,7 @@ def do_fuse_file(f, name, target):
                                    stdin=subprocess.PIPE,
                                    stdout=None, stderr=None)
         logging.notice(f"Writing {name} to {pdevice}")
+        f.seek(0)
         buf = f.read(4 << 20)
         while len(buf) > 0:
             proc_dd.stdin.write(buf)