Skip to content

Commit

Permalink
Fix auth, add brom config
Browse files Browse the repository at this point in the history
  • Loading branch information
bkerler committed Jul 5, 2024
1 parent e34fc91 commit fb5118d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
22 changes: 14 additions & 8 deletions mtkclient/Library/DA/xflash/extension/xflash.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,20 @@ def cmd(self, cmd):
return False

def custom_read(self, addr, length):
if self.cmd(XCmd.CUSTOM_READ):
self.xsend(data=addr, is64bit=True)
self.xsend(length)
data = self.xread()
status = self.status()
if status == 0:
return data
return b""
data = bytearray()
pos = 0
while pos<length:
if self.cmd(XCmd.CUSTOM_READ):
self.xsend(data=addr+pos, is64bit=True)
sz = min(length,0x10000)
self.xsend(sz)
tmp = self.xread()
data.extend(tmp)
pos += len(tmp)
status = self.status()
if status != 0:
break
return data[:length]

def custom_readregister(self, addr):
if self.cmd(XCmd.CUSTOM_READREGISTER):
Expand Down
4 changes: 2 additions & 2 deletions mtkclient/Library/DA/xflash/xflash_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def __init__(self, mtk, daconfig, loglevel=logging.INFO):

try:
from mtkclient.Library.Exploit.kamakiripl import KamakiriPl
self.kamakiri_pl = KamakiriPl(self.mtk, loglevel)
# self.kamakiri_pl = None
# self.kamakiri_pl = KamakiriPl(self.mtk, loglevel)
self.kamakiri_pl = None
except Exception:
self.kamakiri_pl = None

Expand Down
3 changes: 1 addition & 2 deletions mtkclient/Library/Port.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ def handshake(self, maxtries=None, loop=0):
if maxtries is not None and counter == maxtries:
break
counter += 1
self.cdc.connected = self.cdc.connect()
if self.cdc.connected and self.run_handshake():
if self.cdc.connect() and self.run_handshake():
return True
else:
if loop == 5:
Expand Down
3 changes: 3 additions & 0 deletions mtkclient/Library/mtk_preloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ def init(self, maxtries=None, display=True):
self.send_auth(authdata)
else:
self.error(f"Couldn't find auth file {self.config.auth}")
elif self.config.is_brom and self.config.target_config["daa"]:
self.warning("Auth file is required. Use --auth option.")
if self.config.cert is not None and self.config.is_brom and self.config.target_config["daa"]:
if os.path.exists(self.config.cert):
certdata = open(self.config.cert, "rb").read()
Expand Down Expand Up @@ -640,6 +642,7 @@ def send_auth(self, auth):
pos += size
self.usbwrite(b"")
time.sleep(0.035)
crc = self.rword()
status = self.rword()
if 0x0 <= status <= 0xFF:
return True
Expand Down
30 changes: 29 additions & 1 deletion mtkclient/config/brom_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,34 @@ def __init__(self, var1=None, watchdog=None, uart=None, brom_payload_addr=None,
description="Dimensity 9000/9000+"
# loader="mt6983_payload.bin"
),
# Dimensity 7020/930 - MT6855 - Motorola XT2415V
0x1129: Chipconfig(
var1=0xA,
watchdog=0x1c007000,
uart=0x11001000,
brom_payload_addr=0x100A00,
da_payload_addr=0x201000,
pl_payload_addr=0x40200000,
gcpu_base=0x10050000,
dxcc_base=0x10210000,
sej_base=0x1000a000,
cqdma_base=0x10212000,
ap_dma_mem=0x11300800 + 0x1a0,
# blacklist=[(0x102848, 0x0), (0x00106B60, 0x0)],
# blacklist_count=0x0000000A,
# send_ptr=(0x102888, 0xE79C),
# ctrl_buffer=0x00102A9C,
# cmd_handler=0x0000F569,
# brom_register_access=(0xeba4, 0xec5c),
meid_addr=0x1008EC,
socid_addr=0x100934,
# prov_addr=0x1066C0,
damode=DAmodes.XML,
dacode=0x1129,
name="MT6855",
description="Dimensity 8100"
# loader="mt6893_payload.bin"
),
# Dimensity 1100 - MT6895 Dimensity 8200 - Vivo V27 Pro
0x1172: Chipconfig(
var1=0xA,
Expand All @@ -1441,7 +1469,7 @@ def __init__(self, var1=None, watchdog=None, uart=None, brom_payload_addr=None,
socid_addr=0x100934,
# prov_addr=0x1066C0,
damode=DAmodes.XML,
dacode=0x6895,
dacode=0x1172,
name="MT6895",
description="Dimensity 8100"
# loader="mt6893_payload.bin"
Expand Down

0 comments on commit fb5118d

Please sign in to comment.