mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-11-14 03:04:54 -05:00
Minor bugfixes, beautify
This commit is contained in:
parent
491f930424
commit
8e46df657c
9 changed files with 39 additions and 6 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,6 +1,8 @@
|
|||
__pycache__
|
||||
# Compiled python modules.
|
||||
*.pyc
|
||||
.idea
|
||||
DA_*.bin
|
||||
|
||||
# Setuptools distribution folder.
|
||||
/dist/
|
||||
|
|
|
@ -653,9 +653,11 @@ class DA_handler(metaclass=LogBase):
|
|||
partitionname = args.partitionname
|
||||
parttype = args.parttype
|
||||
filename = args.filename
|
||||
self.mtk.config.hwparam_path = os.path.dirname(filename)
|
||||
self.da_read(partitionname=partitionname, parttype=parttype, filename=filename)
|
||||
elif cmd == "rl":
|
||||
directory = args.directory
|
||||
self.mtk.config.hwparam_path = directory
|
||||
parttype = args.parttype
|
||||
if args.skip:
|
||||
skip = args.skip.split(",")
|
||||
|
@ -664,12 +666,14 @@ class DA_handler(metaclass=LogBase):
|
|||
self.da_rl(directory=directory, parttype=parttype, skip=skip)
|
||||
elif cmd == "rf":
|
||||
filename = args.filename
|
||||
self.mtk.config.hwparam_path = os.path.dirname(filename)
|
||||
parttype = args.parttype
|
||||
self.da_rf(filename=filename, parttype=parttype)
|
||||
elif cmd == "rs":
|
||||
start = getint(args.startsector)
|
||||
sectors = getint(args.sectors)
|
||||
filename = args.filename
|
||||
self.mtk.config.hwparam_path = os.path.dirname(filename)
|
||||
parttype = args.parttype
|
||||
if self.da_rs(start=start, sectors=sectors, filename=filename, parttype=parttype):
|
||||
print(f"Dumped sector {str(start)} with sector count {str(sectors)} as {filename}.")
|
||||
|
@ -679,6 +683,7 @@ class DA_handler(metaclass=LogBase):
|
|||
start = getint(args.offset)
|
||||
length = getint(args.length)
|
||||
filename = args.filename
|
||||
self.mtk.config.hwparam_path = os.path.dirname(filename)
|
||||
parttype = args.parttype
|
||||
if self.da_ro(start=start, length=length, filename=filename, parttype=parttype):
|
||||
print(f"Dumped offset {hex(start)} with length {hex(length)} as {filename}.")
|
||||
|
@ -804,6 +809,7 @@ class DA_handler(metaclass=LogBase):
|
|||
data = args.data
|
||||
self.da_poke(addr=addr, data=data, filename=filename)
|
||||
elif subcmd == "generatekeys":
|
||||
self.mtk.config.hwparam_path = "."
|
||||
mtk.daloader.keys()
|
||||
elif subcmd == "dumpbrom":
|
||||
filename = f"brom_{hex(mtk.daloader.config.hwcode)[2:]}.bin"
|
||||
|
|
|
@ -210,7 +210,7 @@ class DAloader(metaclass=LogBase):
|
|||
self.flashmode = damodes.XFLASH
|
||||
if self.mtk.config.chipconfig.damode == damodes.XFLASH:
|
||||
self.flashmode = damodes.XFLASH
|
||||
elif self.mtk.config.chipconfig.damode == damodes.XML:
|
||||
elif self.mtk.config.chipconfig.damode == damodes.XML or self.daconfig.da_loader.v6:
|
||||
self.flashmode = damodes.XML
|
||||
if self.flashmode == damodes.XFLASH:
|
||||
self.da = DAXFlash(self.mtk, self.daconfig, self.loglevel)
|
||||
|
|
|
@ -35,6 +35,20 @@ class XMLCmd(metaclass=LogBase):
|
|||
cmd = self.create_cmd("NOTIFY-INIT-HW")
|
||||
return cmd
|
||||
|
||||
def cmd_security_set_flash_policy(self,host_offset: int = 0x8000000,
|
||||
length: int = 0x100000):
|
||||
"""
|
||||
<?xml version="1.0" encoding="utf-8"?><da><version>1.0</version><command>CMD:SECURITY-SET-FLASH-POLICY</command><arg>
|
||||
<source_file>MEM://0x8000000:0x100000</source_file></arg></da>
|
||||
"""
|
||||
content = {
|
||||
"arg": [
|
||||
f"<source_file>MEM://{hex(host_offset)}:{hex(length)}</source_file>"
|
||||
]
|
||||
}
|
||||
cmd = self.create_cmd("SECURITY-SET-FLASH-POLICY", content)
|
||||
return cmd
|
||||
|
||||
def cmd_boot_to(self, at_addr: int = 0x40000000, jmp_addr: int = 0x40000000, host_offset: int = 0x7fe83c09a04c,
|
||||
length: int = 0x50c78):
|
||||
"""
|
||||
|
|
|
@ -442,7 +442,7 @@ class DAXML(metaclass=LogBase):
|
|||
if cmd == "CMD:START":
|
||||
return True
|
||||
else:
|
||||
cmd, result = self.get_command_result()
|
||||
cmd, startresult = self.get_command_result()
|
||||
self.error(result)
|
||||
return False
|
||||
else:
|
||||
|
|
|
@ -143,8 +143,10 @@ def disasm(code, cpu, mode, bigendian, size):
|
|||
print("CPU and/or mode not supported!")
|
||||
exit(0)
|
||||
|
||||
instr = [f"{i.mnemonic}\t{i.op_str}" for i in cs.disasm(code, size)]
|
||||
# print("0x%x:\t%s\t%s" % (i.address, i.mnemonic, i.op_str))
|
||||
instr = []
|
||||
for i in cs.disasm(code, size):
|
||||
# print("0x%x:\t%s\t%s" % (i.address, i.mnemonic, i.op_str))
|
||||
instr.append("%s\t%s" % (i.mnemonic, i.op_str))
|
||||
return instr
|
||||
|
||||
|
||||
|
|
|
@ -1336,6 +1336,9 @@ class Preloader(metaclass=LogBase):
|
|||
time.sleep(0.035)
|
||||
try:
|
||||
res = self.rword(2)
|
||||
if isinstance(res, list) and res == []:
|
||||
self.error("No reply from da loader.")
|
||||
return False
|
||||
if isinstance(res, list):
|
||||
checksum, status = res
|
||||
if gen_chksum != checksum and checksum != 0:
|
||||
|
|
|
@ -3,10 +3,15 @@
|
|||
import os
|
||||
import sys
|
||||
from struct import unpack
|
||||
import inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(os.path.dirname(current_dir))
|
||||
sys.path.insert(0, parent_dir)
|
||||
from mtkclient.config.payloads import pathconfig
|
||||
from mtkclient.Library.utils import read_object
|
||||
from mtkclient.Library.utils import find_binary
|
||||
|
||||
|
||||
entry_region = [
|
||||
('m_buf', 'I'),
|
||||
('m_len', 'I'),
|
||||
|
|
|
@ -8,6 +8,7 @@ pyside6 >= 6.4.0.1
|
|||
mock >= 4.0.3
|
||||
pyserial >= 3.5
|
||||
flake8
|
||||
fusepy
|
||||
unicorn
|
||||
keystone-engine
|
||||
capstone
|
||||
unicorn
|
||||
fusepy
|
||||
|
|
Loading…
Reference in a new issue