mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-11-14 19:25:05 -05:00
Additional fixes
This commit is contained in:
parent
9c7db527be
commit
a041a4033c
4 changed files with 42 additions and 30 deletions
|
@ -157,13 +157,13 @@ class DAconfig(metaclass=LogBase):
|
|||
loaders.append(os.path.join(root, file))
|
||||
loaders = sorted(loaders)[::-1]
|
||||
for loader in loaders:
|
||||
self.parse_da_loader(loader)
|
||||
self.parse_da_loader(loader, self.dasetup)
|
||||
else:
|
||||
if not os.path.exists(loader):
|
||||
self.warning("Couldn't open " + loader)
|
||||
else:
|
||||
self.info("Using custom loader: " + loader)
|
||||
self.parse_da_loader(loader)
|
||||
self.parse_da_loader(loader, self.dasetup)
|
||||
|
||||
def m_extract_emi(self, data):
|
||||
idx = data.find(b"\x4D\x4D\x4D\x01\x38\x00\x00\x00")
|
||||
|
@ -211,7 +211,7 @@ class DAconfig(metaclass=LogBase):
|
|||
self.emiver = 0
|
||||
self.emi = None
|
||||
|
||||
def parse_da_loader(self, loader):
|
||||
def parse_da_loader(self, loader:str, dasetup:dict):
|
||||
try:
|
||||
with open(loader, 'rb') as bootldr:
|
||||
# data = bootldr.read()
|
||||
|
@ -229,11 +229,11 @@ class DAconfig(metaclass=LogBase):
|
|||
da.v6 = v6
|
||||
# if da.hw_code == 0x8127 and "5.1824" not in loader:
|
||||
# continue
|
||||
if da.hw_code not in self.dasetup:
|
||||
if da.hw_code not in dasetup:
|
||||
if da.hw_code != 0:
|
||||
self.dasetup[da.hw_code] = [da]
|
||||
dasetup[da.hw_code] = [da]
|
||||
else:
|
||||
for ldr in self.dasetup[da.hw_code]:
|
||||
for ldr in dasetup[da.hw_code]:
|
||||
found = False
|
||||
if da.hw_version == ldr.hw_version:
|
||||
if da.sw_version == ldr.sw_version:
|
||||
|
@ -242,7 +242,7 @@ class DAconfig(metaclass=LogBase):
|
|||
break
|
||||
if not found:
|
||||
if da.hw_code != 0:
|
||||
self.dasetup[da.hw_code].append(da)
|
||||
dasetup[da.hw_code].append(da)
|
||||
return True
|
||||
except Exception as e:
|
||||
self.error("Couldn't open loader: " + loader + ". Reason: " + str(e))
|
||||
|
|
|
@ -1117,7 +1117,7 @@ class DALegacy(metaclass=LogBase):
|
|||
self.mtk.daloader.progress.show_progress("Read", length, length, display)
|
||||
rq.put(None)
|
||||
worker.join(60)
|
||||
return b""
|
||||
return True
|
||||
else:
|
||||
buffer = bytearray()
|
||||
bytestoread = length
|
||||
|
|
|
@ -195,6 +195,11 @@ class xflashext(metaclass=LogBase):
|
|||
self.info("Patching da2 ...")
|
||||
# open("da2.bin","wb").write(da2)
|
||||
da2patched = bytearray(da2)
|
||||
# Patch huawei security, rma state
|
||||
pos = 0
|
||||
huawei = find_binary(da2, b"\x01\x2B\x03\xD1\x01\x23", pos)
|
||||
if huawei is not None:
|
||||
da2patched[huawei:huawei + 4] = b"\x00\x00\x00\x00"
|
||||
# Patch oppo security
|
||||
oppo = 0
|
||||
pos = 0
|
||||
|
|
|
@ -419,6 +419,7 @@ class DAXFlash(metaclass=LogBase):
|
|||
|
||||
def get_da_version(self):
|
||||
data = self.send_devctrl(self.Cmd.GET_DA_VERSION)
|
||||
if data != b"":
|
||||
status = self.status()
|
||||
if status == 0:
|
||||
self.info(f"DA-VERSION : {data.decode('utf-8')}")
|
||||
|
@ -426,6 +427,7 @@ class DAXFlash(metaclass=LogBase):
|
|||
else:
|
||||
self.error(f"Error on getting chip id: {self.eh.status(status)}")
|
||||
return None
|
||||
return None
|
||||
|
||||
def get_chip_id(self):
|
||||
class Chipid:
|
||||
|
@ -437,6 +439,7 @@ class DAXFlash(metaclass=LogBase):
|
|||
|
||||
chipid = Chipid
|
||||
data = self.send_devctrl(self.Cmd.GET_CHIP_ID)
|
||||
if data != b"":
|
||||
chipid.hw_code, chipid.hw_sub_code, chipid.hw_version, chipid.sw_version, chipid.chip_evolution = unpack(
|
||||
"<HHHHH",
|
||||
data[:(5 * 2)])
|
||||
|
@ -783,8 +786,10 @@ class DAXFlash(metaclass=LogBase):
|
|||
def readflash(self, addr, length, filename, parttype=None, display=True) -> bytes:
|
||||
global rq
|
||||
partinfo = self.getstorage(parttype, length)
|
||||
if not partinfo:
|
||||
if not partinfo and not filename:
|
||||
return b""
|
||||
elif not partinfo:
|
||||
return False
|
||||
self.mtk.daloader.progress.clear()
|
||||
storage, parttype, length = partinfo
|
||||
self.get_packet_length()
|
||||
|
@ -823,10 +828,10 @@ class DAXFlash(metaclass=LogBase):
|
|||
self.mtk.daloader.progress.show_progress("Read", total, total, display)
|
||||
rq.put(None)
|
||||
worker.join(60)
|
||||
return b""
|
||||
return True
|
||||
rq.put(None)
|
||||
worker.join(60)
|
||||
return b"ACK"
|
||||
return True
|
||||
else:
|
||||
buffer = bytearray()
|
||||
while length > 0:
|
||||
|
@ -841,7 +846,9 @@ class DAXFlash(metaclass=LogBase):
|
|||
if display:
|
||||
self.mtk.daloader.progress.show_progress("Read", total, total, display)
|
||||
return buffer
|
||||
if not filename:
|
||||
return b""
|
||||
return False
|
||||
|
||||
class ShutDownModes:
|
||||
NORMAL = 0
|
||||
|
|
Loading…
Reference in a new issue