mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-11-14 19:25:05 -05:00
Add Read16 support, fix usb claim issue
This commit is contained in:
parent
a92d6cd88a
commit
3da49a5e1c
4 changed files with 27 additions and 15 deletions
|
@ -298,20 +298,19 @@ class usb_class(DeviceClass):
|
|||
|
||||
if self.EP_OUT is not None and self.EP_IN is not None:
|
||||
self.debug(self.configuration)
|
||||
if self.interface != 0:
|
||||
try:
|
||||
usb.util.claim_interface(self.device, 0)
|
||||
except:
|
||||
try:
|
||||
if self.device.is_kernel_driver_active(0):
|
||||
self.debug("Detaching kernel driver")
|
||||
self.device.detach_kernel_driver(0)
|
||||
except Exception as err:
|
||||
self.debug("No kernel driver supported: " + str(err))
|
||||
try:
|
||||
usb.util.claim_interface(self.device, 0)
|
||||
except:
|
||||
try:
|
||||
if self.device.is_kernel_driver_active(0):
|
||||
self.debug("Detaching kernel driver")
|
||||
self.device.detach_kernel_driver(0)
|
||||
except Exception as err:
|
||||
self.debug("No kernel driver supported: " + str(err))
|
||||
try:
|
||||
usb.util.claim_interface(self.device, 0)
|
||||
except:
|
||||
pass
|
||||
pass
|
||||
try:
|
||||
usb.util.claim_interface(self.device, self.interface)
|
||||
except:
|
||||
|
|
|
@ -42,9 +42,10 @@ class legacyext(metaclass=LogBase):
|
|||
self.da2 = None
|
||||
self.da2address = None
|
||||
|
||||
|
||||
def patch_da2(self, da2):
|
||||
da2patched = bytearray(da2)
|
||||
# Patch security
|
||||
# Patch security READ_REG16_CMD
|
||||
check_addr = find_binary(da2, b"\x08\xB5\x4F\xF4\x50\x42")
|
||||
if check_addr is not None:
|
||||
da2patched[check_addr:check_addr + 6] = b"\x08\xB5\x00\x20\x08\xBD"
|
||||
|
|
|
@ -222,14 +222,18 @@ class Preloader(metaclass=LogBase):
|
|||
self.info("SOC_ID:\t\t\t" + hexlify(socid).decode('utf-8').upper())
|
||||
return True
|
||||
|
||||
def read32(self, addr, dwords=1) -> list:
|
||||
def read(self, addr, dwords=1, length=32) -> list:
|
||||
result = []
|
||||
if self.echo(self.Cmd.READ32.value):
|
||||
cmd = self.Cmd.READ16 if length == 16 else self.Cmd.READ32
|
||||
if self.echo(cmd.value):
|
||||
if self.echo(pack(">I", addr)):
|
||||
ack = self.echo(pack(">I", dwords))
|
||||
status = self.rword()
|
||||
if ack and status <= 0xFF:
|
||||
result = self.rdword(dwords)
|
||||
if length==32:
|
||||
result = self.rdword(dwords)
|
||||
else:
|
||||
result = self.rword(dwords)
|
||||
status2 = unpack(">H", self.usbread(2))[0]
|
||||
if status2 <= 0xFF:
|
||||
return result
|
||||
|
@ -237,6 +241,12 @@ class Preloader(metaclass=LogBase):
|
|||
self.error(self.eh.status(status))
|
||||
return result
|
||||
|
||||
def read32(self, addr, dwords=1) -> list:
|
||||
return self.read(addr,dwords,32)
|
||||
|
||||
def read16(self, addr, dwords=1) -> list:
|
||||
return self.read(addr,dwords,16)
|
||||
|
||||
def write(self, addr, values, length=32) -> bool:
|
||||
cmd = self.Cmd.WRITE16 if length == 16 else self.Cmd.WRITE32
|
||||
packfmt = ">H" if length == 16 else ">I"
|
||||
|
|
|
@ -169,6 +169,7 @@ class xflashext(metaclass=LogBase):
|
|||
return None
|
||||
|
||||
def patch_da1(self, da1):
|
||||
# Patch error 0xC0020039
|
||||
self.info("Patching da1 ...")
|
||||
da1patched = bytearray(da1)
|
||||
# Patch security
|
||||
|
@ -180,6 +181,7 @@ class xflashext(metaclass=LogBase):
|
|||
return da1patched
|
||||
|
||||
def patch_da2(self, da2):
|
||||
# Patch error 0xC0030007
|
||||
self.info("Patching da2 ...")
|
||||
# open("da2.bin","wb").write(da2)
|
||||
da2patched = bytearray(da2)
|
||||
|
|
Loading…
Reference in a new issue