mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-11-14 11:14:56 -05:00
Compare commits
5 commits
cc4cc1a87c
...
4f57cf9ee3
Author | SHA1 | Date | |
---|---|---|---|
|
4f57cf9ee3 | ||
|
77255c45bc | ||
|
e3cd58a837 | ||
|
35c5803ae0 | ||
|
2e65679cc8 |
4 changed files with 35 additions and 53 deletions
|
@ -27,10 +27,7 @@ release the buttons.
|
||||||
### Use Re LiveDVD (everything ready to go, based on Ubuntu):
|
### Use Re LiveDVD (everything ready to go, based on Ubuntu):
|
||||||
User: user, Password:user (based on Ubuntu 22.04 LTS)
|
User: user, Password:user (based on Ubuntu 22.04 LTS)
|
||||||
|
|
||||||
[Live DVD V4](https://www.androidfilehost.com/?fid=15664248565197184488)
|
[Live DVD V6](https://www.androidfilehost.com/?fid=1109791587270922802)
|
||||||
|
|
||||||
[Live DVD V4 Mirror](https://drive.google.com/file/d/10OEw1d-Ul_96MuT3WxQ3iAHoPC4NhM_X/view?usp=sharing)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
|
@ -309,7 +309,7 @@ class UsbClass(DeviceClass):
|
||||||
break
|
break
|
||||||
|
|
||||||
if self.device is None:
|
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
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -125,63 +125,51 @@ class Port(metaclass=LogBase):
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def run_handshake(self):
|
# 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 handshake(self, maxtries=None, loop=0):
|
def handshake(self, maxtries=None, loop=0):
|
||||||
counter = 0
|
counter = 0
|
||||||
|
|
||||||
while not self.cdc.connected:
|
while not self.cdc.connected:
|
||||||
try:
|
try:
|
||||||
if maxtries is not None and counter == maxtries:
|
if maxtries is not None and counter == maxtries:
|
||||||
break
|
break
|
||||||
counter += 1
|
counter += 1
|
||||||
if self.cdc.connect() and self.run_handshake():
|
self.cdc.connect()
|
||||||
return True
|
ep_out = self.cdc.EP_OUT.write
|
||||||
else:
|
ep_in = self.cdc.EP_IN.read
|
||||||
if loop == 5:
|
maxinsize = self.cdc.EP_IN.wMaxPacketSize
|
||||||
sys.stdout.write('\n')
|
|
||||||
self.info("Hint:\n\nPower off the phone before connecting.\n" +
|
i = 0
|
||||||
"For brom mode, press and hold vol up, vol dwn, or all hw buttons and " +
|
startcmd = b"\xa0\x0a\x50\x05"
|
||||||
"connect usb.\n" +
|
length = len(startcmd)
|
||||||
"For preloader mode, don't press any hw button and connect usb.\n"
|
# On preloader, send 0xa0 first
|
||||||
"If it is already connected and on, hold power for 10 seconds to reset.\n")
|
if self.cdc.pid!=0x3:
|
||||||
sys.stdout.write('\n')
|
ep_out(startcmd[0:1])
|
||||||
if loop >= 10:
|
try:
|
||||||
sys.stdout.write('.')
|
while i < length:
|
||||||
if loop >= 20:
|
if ep_out(startcmd[i:i+1]):
|
||||||
sys.stdout.write('\n')
|
if ep_in(maxinsize)[-1] == ~(startcmd[i]) & 0xFF:
|
||||||
loop = 0
|
i += 1
|
||||||
loop += 1
|
else:
|
||||||
time.sleep(0.3)
|
i = 0
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
||||||
|
self.info("Device detected :)")
|
||||||
|
return True
|
||||||
|
|
||||||
|
except Exception as serr:
|
||||||
|
self.debug(str(serr))
|
||||||
|
time.sleep(0.005)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
except Exception as serr:
|
except Exception as serr:
|
||||||
if "access denied" in str(serr):
|
if "access denied" in str(serr):
|
||||||
self.warning(str(serr))
|
self.warning(str(serr))
|
||||||
self.debug(str(serr))
|
# self.debug(str(serr))
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -160,9 +160,6 @@ class Preloader(metaclass=LogBase):
|
||||||
else:
|
else:
|
||||||
res = self.mtk.port.handshake(maxtries=maxtries)
|
res = self.mtk.port.handshake(maxtries=maxtries)
|
||||||
if not res:
|
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()
|
self.mtk.port.close()
|
||||||
tries += 1
|
tries += 1
|
||||||
if tries == 1000:
|
if tries == 1000:
|
||||||
|
|
Loading…
Reference in a new issue