mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-11-14 19:25:05 -05:00
Fix legacy write flash
This commit is contained in:
parent
64049911fc
commit
4290a5c436
1 changed files with 8 additions and 1 deletions
|
@ -1524,9 +1524,14 @@ class DALegacy(metaclass=LogBase):
|
|||
length, parttype = self.get_parttype(length, parttype)
|
||||
storage = self.get_storage()
|
||||
fh = False
|
||||
|
||||
fill = 0
|
||||
if filename is not None:
|
||||
fh = open(filename, "rb")
|
||||
fsize = os.stat(filename).st_size
|
||||
length = min(fsize, length)
|
||||
if length % 512 != 0:
|
||||
fill = 512 - (length % 512)
|
||||
length += fill
|
||||
fh.seek(offset)
|
||||
self.mtk.daloader.progress.show_progress("Write", 0, length, display)
|
||||
self.usbwrite(self.Cmd.SDMMC_WRITE_DATA_CMD)
|
||||
|
@ -1544,6 +1549,8 @@ class DALegacy(metaclass=LogBase):
|
|||
count = min(0x100000, length - offset)
|
||||
if fh:
|
||||
data = bytearray(fh.read(count))
|
||||
if len(data) < count:
|
||||
data.extend(b"\x00" * fill)
|
||||
else:
|
||||
data = wdata[offset:offset + count]
|
||||
self.usbwrite(data)
|
||||
|
|
Loading…
Reference in a new issue