This commit is contained in:
Bjoern Kerler 2022-06-28 20:22:53 +02:00
parent 5584cdcd7b
commit e018243c2c
No known key found for this signature in database
GPG key ID: 52E823BB96A55380
5 changed files with 62 additions and 61 deletions

4
edl
View file

@ -96,8 +96,8 @@ Description:
Options:
--loader=filename Use specific EDL loader, disable autodetection [default: None]
--vid=vid Set usb vendor id used for EDL [default: -1]
--pid=pid Set usb product id used for EDL [default: -1]
--vid=vid Set usb vendor image_id used for EDL [default: -1]
--pid=pid Set usb product image_id used for EDL [default: -1]
--lun=lun Set lun to read/write from (UFS memory only)
--maxpayload=bytes Set the maximum payload for EDL [default: 0x100000]
--sectorsize=bytes Set default sector size

View file

@ -114,9 +114,9 @@ class sahara(metaclass=LogBase):
pkt = self.ch.pkt_cmd_hdr(v)
if pkt.cmd == cmd_t.SAHARA_HELLO_REQ:
rsp = self.ch.pkt_hello_req(v)
self.pktsize = rsp.max_cmd_len
self.version = float(str(rsp.version) + "." + str(rsp.version_min))
self.info(f"Protocol version: {self.version}")
self.pktsize = rsp.cmd_packet_length
self.version = rsp.version
self.info(f"Protocol version: {rsp.version}, Version supported: {rsp.version_supported}")
return {"mode":"sahara", "cmd":cmd_t.SAHARA_HELLO_REQ, "data":rsp}
elif pkt.cmd == cmd_t.SAHARA_END_TRANSFER:
rsp = self.ch.pkt_image_end(v)
@ -159,7 +159,7 @@ class sahara(metaclass=LogBase):
if res["cmd"] == cmd_t.SAHARA_END_TRANSFER:
if "data" in res:
pkt = res["data"]
self.error(self.get_error_desc(pkt.status))
self.error(self.get_error_desc(pkt.image_tx_status))
return False
elif res["cmd"] == cmd_t.SAHARA_CMD_READY:
return True
@ -327,7 +327,7 @@ class sahara(metaclass=LogBase):
elif cmd == cmd_t.SAHARA_END_TRANSFER:
if "data" in res:
pkt = res["data"]
if pkt.status == status_t.SAHARA_NAK_INVALID_CMD:
if pkt.image_tx_status == status_t.SAHARA_NAK_INVALID_CMD:
self.error("Invalid Transfer command received.")
return False
else:
@ -352,7 +352,7 @@ class sahara(metaclass=LogBase):
elif res["cmd"] == cmd_t.SAHARA_END_TRANSFER:
if "data" in res:
pkt=res["data"]
self.error(self.get_error_desc(pkt.status))
self.error(self.get_error_desc(pkt.image_tx_status))
return False
def read_memory(self, addr, bytestoread, display=False, wf=None):
@ -492,8 +492,8 @@ class sahara(metaclass=LogBase):
self.dump_partitions(partitions)
return True
elif res["data"].status:
self.error(self.get_error_desc(res["data"].status))
elif res["data"].image_tx_status:
self.error(self.get_error_desc(res["data"].image_tx_status))
return False
return False
@ -537,7 +537,7 @@ class sahara(metaclass=LogBase):
if loop == 0:
self.info("32-Bit mode detected.")
pkt = resp["data"]
self.id = pkt.id
self.id = pkt.image_id
if self.id == 0x7:
self.mode = "nandprg"
if loop == 0:
@ -564,7 +564,7 @@ class sahara(metaclass=LogBase):
datalen -= data_len
elif cmd == cmd_t.SAHARA_END_TRANSFER:
pkt = resp["data"]
if pkt.status == status_t.SAHARA_STATUS_SUCCESS:
if pkt.image_tx_status == status_t.SAHARA_STATUS_SUCCESS:
if self.cmd_done():
self.info("Loader successfully uploaded.")
else:
@ -572,7 +572,7 @@ class sahara(metaclass=LogBase):
sys.exit(1)
return self.mode
else:
self.error(self.get_error_desc(pkt.status))
self.error(self.get_error_desc(pkt.image_tx_status))
return "error"
else:
self.error("Unknown response received on uploading loader.")
@ -601,6 +601,6 @@ class sahara(metaclass=LogBase):
return payload
elif cmd == cmd_t.SAHARA_END_TRANSFER:
pkt = res["data"]
self.error(self.get_error_desc(pkt.status))
self.error(self.get_error_desc(pkt.image_tx_status))
return None
return res

View file

@ -30,24 +30,24 @@ class cmd_t:
class cmd_t_version:
SAHARA_HELLO_REQ = 0x1
SAHARA_HELLO_RSP = 1.0
SAHARA_READ_DATA = 1.0
SAHARA_END_TRANSFER = 1.0
SAHARA_DONE_REQ = 1.0
SAHARA_DONE_RSP = 1.0
SAHARA_RESET_REQ = 1.0
SAHARA_RESET_RSP = 1.0
SAHARA_MEMORY_DEBUG = 2.0
SAHARA_MEMORY_READ = 2.0
SAHARA_CMD_READY = 2.1
SAHARA_SWITCH_MODE = 2.1
SAHARA_EXECUTE_REQ = 2.1
SAHARA_EXECUTE_RSP = 2.1
SAHARA_EXECUTE_DATA = 2.1
SAHARA_64BIT_MEMORY_DEBUG = 2.5
SAHARA_64BIT_MEMORY_READ = 2.5
SAHARA_64BIT_MEMORY_READ_DATA = 2.8
SAHARA_RESET_STATE_MACHINE_ID = 2.9
SAHARA_HELLO_RSP = 1
SAHARA_READ_DATA = 1
SAHARA_END_TRANSFER = 1
SAHARA_DONE_REQ = 1
SAHARA_DONE_RSP = 1
SAHARA_RESET_REQ = 1
SAHARA_RESET_RSP = 1
SAHARA_MEMORY_DEBUG = 2
SAHARA_MEMORY_READ = 2
SAHARA_CMD_READY = 2
SAHARA_SWITCH_MODE = 2
SAHARA_EXECUTE_REQ = 2
SAHARA_EXECUTE_RSP = 2
SAHARA_EXECUTE_DATA = 2
SAHARA_64BIT_MEMORY_DEBUG = 2
SAHARA_64BIT_MEMORY_READ = 2
SAHARA_64BIT_MEMORY_READ_DATA = 2
SAHARA_RESET_STATE_MACHINE_ID = 2
class exec_cmd_t:
SAHARA_EXEC_CMD_NOP = 0x00
@ -58,7 +58,8 @@ class exec_cmd_t:
SAHARA_EXEC_CMD_SWITCH_TO_STREAM_DLOAD = 0x05
SAHARA_EXEC_CMD_READ_DEBUG_DATA = 0x06
SAHARA_EXEC_CMD_GET_SOFTWARE_VERSION_SBL = 0x07
SAHARA_EXEC_CMD_GET_COMMAND_ID_LIST = 0x08
SAHARA_EXEC_CMD_GET_TRAINING_DATA = 0x09
class sahara_mode_t:
SAHARA_MODE_IMAGE_TX_PENDING = 0x0
@ -168,8 +169,8 @@ class CommandHandler:
cmd = st.dword()
len = st.dword()
version = st.dword()
version_min = st.dword()
max_cmd_len = st.dword()
version_supported = st.dword()
cmd_packet_length = st.dword()
mode = st.dword()
reserved1 = st.dword()
reserved2 = st.dword()
@ -199,7 +200,7 @@ class CommandHandler:
class req:
cmd = st.dword()
len = st.dword()
id = st.dword()
image_id = st.dword()
data_offset = st.dword()
data_len = st.dword()
@ -266,7 +267,7 @@ class CommandHandler:
class req:
cmd = st.dword()
len = st.dword()
id = st.dword()
image_id = st.dword()
status = st.dword()
return req
@ -279,7 +280,7 @@ class CommandHandler:
class req:
cmd = st.dword()
len = st.dword()
status = st.dword()
image_tx_status = st.dword()
return req

View file

@ -820,7 +820,7 @@ class Streaming(metaclass=LogBase):
self.settings = SettingsOpt(self, chipset)
if self.settings.bad_loader:
self.error(
"Loader id doesn't match device, please fix config and patch loader. Rebooting.")
"Loader image_id doesn't match device, please fix config and patch loader. Rebooting.")
self.reset()
return False
self.nanddevice = NandDevice(self.settings)
@ -856,7 +856,7 @@ class Streaming(metaclass=LogBase):
self.settings.num_pages_per_blk / 1024 * self.settings.PAGESIZE / 1024))
val = resp[1].flashId.decode('utf-8') if resp[1].flashId[0] != 0x65 else ""
self.info("Flash memory: %s %s, %s (vendor: 0x%02X id: 0x%02X)" % (self.settings.flash_mfr, val,
self.info("Flash memory: %s %s, %s (vendor: 0x%02X image_id: 0x%02X)" % (self.settings.flash_mfr, val,
self.settings.flash_descr,
self.settings.flash_pid,
self.settings.flash_fid))

View file

@ -70,14 +70,14 @@ diagerror = {
nvitem_type = [
("item", "H"),
("rawdata", "128s"),
("status", "H")
("image_tx_status", "H")
]
subnvitem_type = [
("item", "H"),
("index", "H"),
("rawdata", "128s"),
("status", "H")
("image_tx_status", "H")
]
@ -337,7 +337,7 @@ class qcdiag(metaclass=LogBase):
e = ElementTree.parse(nvxml).getroot()
for atype in e.findall("nv"):
name = atype.get("name")
identifier = int(atype.get("id"))
identifier = int(atype.get("image_id"))
self.nvlist[identifier] = name
def prettyprint(self, data):
@ -460,27 +460,27 @@ class qcdiag(metaclass=LogBase):
return res
def DecodeNVItems(self, nvitem):
if nvitem.status == 0x1:
if nvitem.image_tx_status == 0x1:
return "Internal DMSS use"
elif nvitem.status == 0x2:
elif nvitem.image_tx_status == 0x2:
return "Unrecognized command"
elif nvitem.status == 0x3:
elif nvitem.image_tx_status == 0x3:
return "NV memory full"
elif nvitem.status == 0x4:
elif nvitem.image_tx_status == 0x4:
return "Command failed"
elif nvitem.status == 0x5:
elif nvitem.image_tx_status == 0x5:
return "Inactive Item"
elif nvitem.status == 0x6:
elif nvitem.image_tx_status == 0x6:
return "Bad Parameter"
elif nvitem.status == 0x7:
elif nvitem.image_tx_status == 0x7:
return "Item was read-only"
elif nvitem.status == 0x8:
elif nvitem.image_tx_status == 0x8:
return "Item not defined for this target"
elif nvitem.status == 0x9:
elif nvitem.image_tx_status == 0x9:
return "No more free memory"
elif nvitem.status == 0xA:
elif nvitem.image_tx_status == 0xA:
return "Internal use"
elif nvitem.status == 0x0:
elif nvitem.image_tx_status == 0x0:
return "OK"
return ""
@ -495,7 +495,7 @@ class qcdiag(metaclass=LogBase):
ItemNumber = hex(item) + ": "
returnanswer = "NVItem " + ItemNumber + info
print(returnanswer)
if nvitem.status == 0:
if nvitem.image_tx_status == 0:
print("-----------------------------------------")
print(self.prettyprint(nvitem.data))
else:
@ -513,7 +513,7 @@ class qcdiag(metaclass=LogBase):
ItemNumber = hex(item) + "," + hex(index) + ": "
returnanswer = "NVItem " + ItemNumber + info
print(returnanswer)
if nvitem.status == 0:
if nvitem.image_tx_status == 0:
print("-----------------------------------------")
print(self.prettyprint(nvitem.data))
else:
@ -532,10 +532,10 @@ class qcdiag(metaclass=LogBase):
old = prog
res, nvitem = self.read_nvitem(item)
if res != False:
if nvitem.status != 0x5:
nvitem.status = self.DecodeNVItems(nvitem)
if nvitem.image_tx_status != 0x5:
nvitem.image_tx_status = self.DecodeNVItems(nvitem)
nvitems.append(dict(id=nvitem.item, name=nvitem.name, data=hexlify(nvitem.data).decode("utf-8"),
status=nvitem.status))
status=nvitem.image_tx_status))
else:
errors += nvitem + "\n"
pos += 1
@ -573,7 +573,7 @@ class qcdiag(metaclass=LogBase):
if item in self.nvlist:
name = self.nvlist[item]
data = self.unpackdata(res["rawdata"])
res = nvitem(res["item"], 0, data, res["status"], name)
res = nvitem(res["item"], 0, data, res["image_tx_status"], name)
return [True, res]
elif data[0] == 0x14:
return [False, f"Error 0x14 trying to read nvitem {hex(item)}."]
@ -595,7 +595,7 @@ class qcdiag(metaclass=LogBase):
if item in self.nvlist:
name = self.nvlist[item]
data = self.unpackdata(res["rawdata"])
res = nvitem(res["item"], index, data, res["status"], name)
res = nvitem(res["item"], index, data, res["image_tx_status"], name)
return [True, res]
elif data[0] == 0x14:
return [False, f"Error 0x14 trying to read nvitem {hex(item)}."]