mirror of
https://github.com/bkerler/edl.git
synced 2024-11-14 19:14:58 -05:00
commit
0ea910eb73
3 changed files with 34 additions and 40 deletions
34
edl
34
edl
|
@ -295,8 +295,8 @@ class main(metaclass=LogBase):
|
|||
if mode == "sahara":
|
||||
cmd = conninfo["cmd"]
|
||||
data = conninfo["data"]
|
||||
if cmd == cmd_t.SAHARA_END_TRANSFER:
|
||||
if data.status == sahara_mode_t.SAHARA_MODE_MEMORY_DEBUG:
|
||||
if cmd == cmd_t.SAHARA_HELLO_REQ:
|
||||
if data.mode == sahara_mode_t.SAHARA_MODE_MEMORY_DEBUG:
|
||||
if args["memorydump"]:
|
||||
time.sleep(0.5)
|
||||
print("Device is in memory dump mode, dumping memory")
|
||||
|
@ -325,24 +325,18 @@ class main(metaclass=LogBase):
|
|||
print("Error, couldn't find suitable enprg/nprg loader :(")
|
||||
self.exit()
|
||||
else:
|
||||
self.error("Device is in an unknown sahara state, rebooting...")
|
||||
self.sahara.cmd_reset()
|
||||
data = self.cdc.read(timeout=None)
|
||||
self.debug(hexlify(data).decode('utf-8'))
|
||||
self.exit()
|
||||
elif cmd == cmd_t.SAHARA_HELLO_REQ:
|
||||
sahara_info = self.sahara.cmd_info()
|
||||
if sahara_info is not None:
|
||||
resp = self.sahara.connect()
|
||||
mode = resp["mode"]
|
||||
if "data" in resp:
|
||||
data = resp["data"]
|
||||
if mode == "sahara":
|
||||
mode = self.sahara.upload_loader()
|
||||
else:
|
||||
print("Error on sahara handshake, resetting.")
|
||||
self.sahara.cmd_reset()
|
||||
sys.exit(1)
|
||||
sahara_info = self.sahara.cmd_info()
|
||||
if sahara_info is not None:
|
||||
resp = self.sahara.connect()
|
||||
mode = resp["mode"]
|
||||
if "data" in resp:
|
||||
data = resp["data"]
|
||||
if mode == "sahara":
|
||||
mode = self.sahara.upload_loader()
|
||||
else:
|
||||
print("Error on sahara handshake, resetting.")
|
||||
self.sahara.cmd_reset()
|
||||
sys.exit(1)
|
||||
if mode == "error":
|
||||
print("Connection detected, quiting.")
|
||||
sys.exit(1)
|
||||
|
|
|
@ -431,34 +431,34 @@ class sahara(metaclass=LogBase):
|
|||
if os.path.exists("memory"):
|
||||
rmrf("memory")
|
||||
os.mkdir("memory")
|
||||
cmd, pkt = self.get_rsp()
|
||||
if cmd["cmd"] == cmd_t.SAHARA_MEMORY_DEBUG or cmd["cmd"] == cmd_t.SAHARA_64BIT_MEMORY_DEBUG:
|
||||
memory_table_addr = pkt["memory_table_addr"]
|
||||
memory_table_length = pkt["memory_table_length"]
|
||||
res = self.get_rsp()
|
||||
if res["cmd"] == cmd_t.SAHARA_MEMORY_DEBUG or res["cmd"] == cmd_t.SAHARA_64BIT_MEMORY_DEBUG:
|
||||
memory_table_addr = res["data"].memory_table_addr
|
||||
memory_table_length = res["data"].memory_table_length
|
||||
if self.bit64:
|
||||
pktsize = 8 + 8 + 8 + 20 + 20
|
||||
if memory_table_length % pktsize == 0:
|
||||
if memory_table_length != 0:
|
||||
print(
|
||||
f"Reading 64-Bit partition from {hex(memory_table_addr)} with length of " +
|
||||
"{hex(memory_table_length)}")
|
||||
f"{hex(memory_table_length)}")
|
||||
ptbldata = self.read_memory(memory_table_addr, memory_table_length)
|
||||
num_entries = len(ptbldata) // pktsize
|
||||
partitions = []
|
||||
for id_entry in range(0, num_entries):
|
||||
pd = self.ch.parttbl_64bit(ptbldata[id_entry * pktsize:(id_entry * pktsize) + pktsize])
|
||||
desc = pd["desc"].replace(b"\x00", b"").decode('utf-8')
|
||||
filename = pd["filename"].replace(b"\x00", b"").decode('utf-8')
|
||||
desc = pd.desc.replace(b"\x00", b"").decode('utf-8')
|
||||
filename = pd.filename.replace(b"\x00", b"").decode('utf-8')
|
||||
if dump_partitions and filename not in dump_partitions:
|
||||
continue
|
||||
mem_base = pd["mem_base"]
|
||||
save_pref = pd["save_pref"]
|
||||
length = pd["length"]
|
||||
mem_base = pd.mem_base
|
||||
save_pref = pd.save_pref
|
||||
length = pd.length
|
||||
partitions.append(dict(desc=desc, filename=filename, mem_base=mem_base, length=length,
|
||||
save_pref=save_pref))
|
||||
print(
|
||||
f"{filename}({desc}): Offset {hex(mem_base)}, Length {hex(length)}, " +
|
||||
"SavePref {hex(save_pref)}")
|
||||
f"SavePref {hex(save_pref)}")
|
||||
|
||||
self.dump_partitions(partitions)
|
||||
return True
|
||||
|
@ -475,13 +475,13 @@ class sahara(metaclass=LogBase):
|
|||
partitions = []
|
||||
for id_entry in range(0, num_entries):
|
||||
pd = self.parttbl(ptbldata[id_entry * pktsize:(id_entry * pktsize) + pktsize])
|
||||
desc = pd["desc"].replace(b"\x00", b"").decode('utf-8')
|
||||
filename = pd["filename"].replace(b"\x00", b"").decode('utf-8')
|
||||
desc = pd.desc.replace(b"\x00", b"").decode('utf-8')
|
||||
filename = pd.filename.replace(b"\x00", b"").decode('utf-8')
|
||||
if dump_partitions and filename not in dump_partitions:
|
||||
continue
|
||||
mem_base = pd["mem_base"]
|
||||
save_pref = pd["save_pref"]
|
||||
length = pd["length"]
|
||||
mem_base = pd.mem_base
|
||||
save_pref = pd.save_pref
|
||||
length = pd.length
|
||||
partitions.append(dict(desc=desc, filename=filename, mem_base=mem_base, length=length,
|
||||
save_pref=save_pref))
|
||||
print(f"{filename}({desc}): Offset {hex(mem_base)}, " +
|
||||
|
@ -489,8 +489,8 @@ class sahara(metaclass=LogBase):
|
|||
|
||||
self.dump_partitions(partitions)
|
||||
return True
|
||||
elif "status" in pkt:
|
||||
self.error(self.get_error_desc(pkt["status"]))
|
||||
elif res["data"].status:
|
||||
self.error(self.get_error_desc(res["data"].status))
|
||||
return False
|
||||
return False
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ class CommandHandler:
|
|||
|
||||
class req:
|
||||
save_pref = st.dword()
|
||||
msm_base = st.dword()
|
||||
mem_base = st.dword()
|
||||
length = st.dword()
|
||||
desc = st.string(20)
|
||||
filename = st.string(20)
|
||||
|
@ -317,7 +317,7 @@ class CommandHandler:
|
|||
|
||||
class req:
|
||||
save_pref = st.qword()
|
||||
msm_base = st.qword()
|
||||
mem_base = st.qword()
|
||||
length = st.qword()
|
||||
desc = st.string(20)
|
||||
filename = st.string(20)
|
||||
|
|
Loading…
Reference in a new issue