Additional fixes

This commit is contained in:
Bjoern Kerler 2024-01-08 19:22:00 +01:00
parent 9c7db527be
commit a041a4033c
No known key found for this signature in database
GPG key ID: A3E0FAF79F2F4578
4 changed files with 42 additions and 30 deletions

View file

@ -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))

View file

@ -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

View file

@ -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

View file

@ -419,13 +419,15 @@ class DAXFlash(metaclass=LogBase):
def get_da_version(self):
data = self.send_devctrl(self.Cmd.GET_DA_VERSION)
status = self.status()
if status == 0:
self.info(f"DA-VERSION : {data.decode('utf-8')}")
return data
else:
self.error(f"Error on getting chip id: {self.eh.status(status)}")
return None
if data != b"":
status = self.status()
if status == 0:
self.info(f"DA-VERSION : {data.decode('utf-8')}")
return data
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,19 +439,20 @@ class DAXFlash(metaclass=LogBase):
chipid = Chipid
data = self.send_devctrl(self.Cmd.GET_CHIP_ID)
chipid.hw_code, chipid.hw_sub_code, chipid.hw_version, chipid.sw_version, chipid.chip_evolution = unpack(
if data != b"":
chipid.hw_code, chipid.hw_sub_code, chipid.hw_version, chipid.sw_version, chipid.chip_evolution = unpack(
"<HHHHH",
data[:(5 * 2)])
status = self.status()
if status == 0:
self.info("HW-CODE : 0x%X" % chipid.hw_code)
self.info("HWSUB-CODE : 0x%X" % chipid.hw_sub_code)
self.info("HW-VERSION : 0x%X" % chipid.hw_version)
self.info("SW-VERSION : 0x%X" % chipid.sw_version)
self.info("CHIP-EVOLUTION : 0x%X" % chipid.chip_evolution)
return chipid
else:
self.error(f"Error on getting chip id: {self.eh.status(status)}")
status = self.status()
if status == 0:
self.info("HW-CODE : 0x%X" % chipid.hw_code)
self.info("HWSUB-CODE : 0x%X" % chipid.hw_sub_code)
self.info("HW-VERSION : 0x%X" % chipid.hw_version)
self.info("SW-VERSION : 0x%X" % chipid.sw_version)
self.info("CHIP-EVOLUTION : 0x%X" % chipid.chip_evolution)
return chipid
else:
self.error(f"Error on getting chip id: {self.eh.status(status)}")
return None
def get_ram_info(self):
@ -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
return b""
if not filename:
return b""
return False
class ShutDownModes:
NORMAL = 0