mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-11-14 11:14:56 -05:00
Compare commits
5 commits
3ddf2c84fc
...
bf3db1b727
Author | SHA1 | Date | |
---|---|---|---|
|
bf3db1b727 | ||
|
279e364838 | ||
|
e3cd58a837 | ||
|
35c5803ae0 | ||
|
2e65679cc8 |
10 changed files with 44 additions and 55 deletions
|
@ -309,7 +309,7 @@ class UsbClass(DeviceClass):
|
|||
break
|
||||
|
||||
if self.device is None:
|
||||
self.debug("Couldn't detect the device. Is it connected ?")
|
||||
# self.debug("Couldn't detect the device. Is it connected ?")
|
||||
return False
|
||||
|
||||
try:
|
||||
|
|
|
@ -521,6 +521,8 @@ class DALegacy(metaclass=LogBase):
|
|||
self.emmc = EmmcInfo(self.config, self.usbread(0x5C))
|
||||
self.sdc = SdcInfo(self.config, self.usbread(0x1C))
|
||||
self.flashconfig = ConfigInfo(self.usbread(0x26))
|
||||
if self.config.hwcode == 0x8163:
|
||||
status=self.usbread(4)
|
||||
pi = PassInfo(self.usbread(0xA))
|
||||
if pi.ack == 0x5A:
|
||||
return True
|
||||
|
|
|
@ -351,7 +351,7 @@ class LegacyExt(metaclass=LogBase):
|
|||
else:
|
||||
self.info("SEJ Mode: No meid found. Are you in brom mode ?")
|
||||
if self.config.chipconfig.gcpu_base is not None:
|
||||
if self.config.hwcode in [0x335, 0x8167, 0x8163, 0x8176]:
|
||||
if self.config.hwcode in [0x335, 0x8167, 0x8168, 0x8163, 0x8176]:
|
||||
self.info("Generating gcpu mtee2 key...")
|
||||
mtee2 = hwc.aes_hwcrypt(btype="gcpu", mode="mtee")
|
||||
if mtee2 is not None:
|
||||
|
|
|
@ -8,7 +8,7 @@ import sys
|
|||
from binascii import hexlify
|
||||
from struct import pack, unpack
|
||||
|
||||
from Cryptodome.Util.number import long_to_bytes
|
||||
from Cryptodome.Util.number import bytes_to_long, long_to_bytes
|
||||
|
||||
from mtkclient.Library.Auth.sla import generate_da_sla_signature
|
||||
from mtkclient.Library.DA.xflash.xflash_flash_param import NandExtension
|
||||
|
|
|
@ -905,7 +905,7 @@ class XmlFlashExt(metaclass=LogBase):
|
|||
else:
|
||||
self.info("SEJ Mode: No meid found. Are you in brom mode ?")
|
||||
if self.config.chipconfig.gcpu_base is not None:
|
||||
if self.config.hwcode in [0x335, 0x8167, 0x8163, 0x8176]:
|
||||
if self.config.hwcode in [0x335, 0x8167, 0x8168, 0x8163, 0x8176]:
|
||||
self.info("Generating gcpu mtee2 key...")
|
||||
mtee2 = hwc.aes_hwcrypt(btype="gcpu", mode="mtee")
|
||||
if mtee2 is not None:
|
||||
|
|
|
@ -798,7 +798,9 @@ class DAXML(metaclass=LogBase):
|
|||
return None
|
||||
|
||||
def change_usb_speed(self):
|
||||
return self.send_command(self.Cmd.cmd_can_higher_usb_speed())
|
||||
resp = self.send_command(self.Cmd.cmd_can_higher_usb_speed())
|
||||
if "Unsupported" in resp:
|
||||
return False
|
||||
|
||||
def read_partition_table(self) -> tuple:
|
||||
self.send_command(self.Cmd.cmd_read_partition_table(), noack=True)
|
||||
|
|
|
@ -91,7 +91,7 @@ class HwCrypto(metaclass=LogBase):
|
|||
elif mode == "mtee":
|
||||
if self.hwcode in [0x321]:
|
||||
return self.gcpu.mtk_gcpu_mtee_6735()
|
||||
elif self.hwcode in [0x8167, 0x8163, 0x8176]:
|
||||
elif self.hwcode in [0x8168, 0x8167, 0x8163, 0x8176]:
|
||||
return self.gcpu.mtk_gcpu_mtee_8167()
|
||||
elif btype == "dxcc":
|
||||
if mode == "fde":
|
||||
|
|
|
@ -266,7 +266,7 @@ class GCpu(metaclass=LogBase):
|
|||
self.reg.GCPU_REG_MSC = 0x80FF1800
|
||||
self.reg.GCPU_AXI = 0x887F
|
||||
self.reg.GCPU_UNK2 = 0
|
||||
elif self.hwcode == [0x8163, 0x8176]:
|
||||
elif self.hwcode == [0x8163, 0x8176, 0x8168]:
|
||||
self.write32(CLR_CLK_GATING_CTRL2, self.read32(CLR_CLK_GATING_CTRL2) | 0x8000000)
|
||||
self.reg.GCPU_REG_CTL &= 0xFFFFFFF0
|
||||
self.reg.GCPU_REG_CTL |= 0xF
|
||||
|
|
|
@ -125,63 +125,51 @@ class Port(metaclass=LogBase):
|
|||
pass
|
||||
return False
|
||||
|
||||
def run_handshake(self):
|
||||
ep_out = self.cdc.EP_OUT.write
|
||||
ep_in = self.cdc.EP_IN.read
|
||||
maxinsize = self.cdc.EP_IN.wMaxPacketSize
|
||||
|
||||
i = 0
|
||||
startcmd = b"\xa0\x0a\x50\x05"
|
||||
length = len(startcmd)
|
||||
# On preloader, send 0xa0 first
|
||||
if self.cdc.pid!=0x3:
|
||||
ep_out(startcmd[0:1])
|
||||
try:
|
||||
while i < length:
|
||||
if ep_out(startcmd[i:i+1]):
|
||||
if ep_in(maxinsize)[-1] == ~(startcmd[i]) & 0xFF:
|
||||
i += 1
|
||||
else:
|
||||
i = 0
|
||||
self.info("Device detected :)")
|
||||
return True
|
||||
except Exception as serr:
|
||||
self.debug(str(serr))
|
||||
time.sleep(0.005)
|
||||
return False
|
||||
# def run_handshake(self):
|
||||
|
||||
|
||||
|
||||
|
||||
def handshake(self, maxtries=None, loop=0):
|
||||
counter = 0
|
||||
|
||||
while not self.cdc.connected:
|
||||
try:
|
||||
if maxtries is not None and counter == maxtries:
|
||||
break
|
||||
counter += 1
|
||||
if self.cdc.connect() and self.run_handshake():
|
||||
return True
|
||||
else:
|
||||
if loop == 5:
|
||||
sys.stdout.write('\n')
|
||||
self.info("Hint:\n\nPower off the phone before connecting.\n" +
|
||||
"For brom mode, press and hold vol up, vol dwn, or all hw buttons and " +
|
||||
"connect usb.\n" +
|
||||
"For preloader mode, don't press any hw button and connect usb.\n"
|
||||
"If it is already connected and on, hold power for 10 seconds to reset.\n")
|
||||
sys.stdout.write('\n')
|
||||
if loop >= 10:
|
||||
sys.stdout.write('.')
|
||||
if loop >= 20:
|
||||
sys.stdout.write('\n')
|
||||
loop = 0
|
||||
loop += 1
|
||||
time.sleep(0.3)
|
||||
sys.stdout.flush()
|
||||
self.cdc.connect()
|
||||
ep_out = self.cdc.EP_OUT.write
|
||||
ep_in = self.cdc.EP_IN.read
|
||||
maxinsize = self.cdc.EP_IN.wMaxPacketSize
|
||||
|
||||
i = 0
|
||||
startcmd = b"\xa0\x0a\x50\x05"
|
||||
length = len(startcmd)
|
||||
# On preloader, send 0xa0 first
|
||||
if self.cdc.pid!=0x3:
|
||||
ep_out(startcmd[0:1])
|
||||
try:
|
||||
while i < length:
|
||||
if ep_out(startcmd[i:i+1]):
|
||||
if ep_in(maxinsize)[-1] == ~(startcmd[i]) & 0xFF:
|
||||
i += 1
|
||||
else:
|
||||
i = 0
|
||||
|
||||
|
||||
self.info("Device detected :)")
|
||||
return True
|
||||
|
||||
except Exception as serr:
|
||||
self.debug(str(serr))
|
||||
time.sleep(0.005)
|
||||
return False
|
||||
|
||||
|
||||
except Exception as serr:
|
||||
if "access denied" in str(serr):
|
||||
self.warning(str(serr))
|
||||
self.debug(str(serr))
|
||||
# self.debug(str(serr))
|
||||
pass
|
||||
return False
|
||||
|
||||
|
|
|
@ -160,9 +160,6 @@ class Preloader(metaclass=LogBase):
|
|||
else:
|
||||
res = self.mtk.port.handshake(maxtries=maxtries)
|
||||
if not res:
|
||||
if display:
|
||||
self.error("Status: Handshake failed, retrying...")
|
||||
self.config.set_gui_status(self.config.tr("Status: Handshake failed, retrying..."))
|
||||
self.mtk.port.close()
|
||||
tries += 1
|
||||
if tries == 1000:
|
||||
|
|
Loading…
Reference in a new issue