Init fixes V2

This commit is contained in:
Bjoern Kerler 2020-01-13 19:10:26 +01:00
parent 89274aa9e8
commit 94971949e7
3 changed files with 21 additions and 16 deletions

View file

@ -80,8 +80,8 @@ class qualcomm_firehose:
return False
return True
def xmlsend(self, wdata, response=True):
self.cdc.write(bytes(wdata,'utf-8'), self.cfg.MaxXMLSizeInBytes)
def xmlsend(self, data, response=True):
self.cdc.write(bytes(data,'utf-8'), self.cfg.MaxXMLSizeInBytes)
data = bytearray()
counter = 0
timeout = 3
@ -97,8 +97,9 @@ class qualcomm_firehose:
if counter > timeout:
break
data+=tmp
except:
break
except Exception as e:
logger.error(e)
return [False, resp, data]
try:
logger.debug("RX:"+data.decode('utf-8'))
except:
@ -522,11 +523,10 @@ class qualcomm_firehose:
"MaxPayloadSizeToTargetInBytesSupported=\"1048576\" MaxXMLSizeInBytes=\"4096\" Version=\"1\" TargetName=\"8953\" />" \
"</data>"
'''
self.cdc.read()
rsp = self.xmlsend(connectcmd)
if rsp[0] == True:
#self.cdc.read()
self.cdc.read()
if not "MemoryName" in rsp[1]:
#print(rsp[1])
rsp[1]["MemoryName"]="eMMC"

View file

@ -180,6 +180,7 @@ class usb_class():
return bytearray(tmp)
elif e.errno != None:
print(repr(e), type(e), e.errno)
self.connect()
raise(e)
else:
break

24
edl.py
View file

@ -431,13 +431,17 @@ def doconnect(cdc, loop, mode, resp, sahara):
sys.stdout.flush()
else:
logger.info("Device detected :)")
mode, resp = sahara.connect()
if mode == "" or resp == -1:
try:
mode, resp = sahara.connect()
if mode == "":
logger.info("Unknown mode. Aborting.")
cdc.close()
exit(0)
if mode == "" or resp == -1:
mode, resp = sahara.connect()
except:
if mode == "" or resp == -1:
mode, resp = sahara.connect()
if mode == "":
logger.info("Unknown mode. Aborting.")
cdc.close()
exit(0)
logger.info(f"Mode detected: {mode}")
break
@ -638,10 +642,10 @@ def do_firehose_server(mainargs, cdc, sahara):
response = "<ACK>\n"
if TargetName in secureboottbl:
v = secureboottbl[TargetName]
value = int(hexlify(fh.cmd_peek(v, 4)), 16)
value = struct.unpack("<I",fh.cmd_peek(v, 4))[0]
is_secure = False
for area in range(0, 4):
sec_boot = (value >> (area * 8)) & 0xF
sec_boot = (value >> (area * 8)) & 0xFF
pk_hashindex = sec_boot & 3
oem_pkhash = True if ((sec_boot >> 4) & 1) == 1 else False
auth_enabled = True if ((sec_boot >> 5) & 1) == 1 else False
@ -1259,10 +1263,10 @@ def handle_firehose(arguments, cdc, sahara, verbose):
else:
if TargetName in secureboottbl:
v = secureboottbl[TargetName]
value = int(hexlify(fh.cmd_peek(v, 4)), 16)
value = struct.unpack("<I",fh.cmd_peek(v, 4))[0]
is_secure = False
for area in range(0, 4):
sec_boot = (value >> (area * 8)) & 0xF
sec_boot = (value >> (area * 8))&0xFF
pk_hashindex = sec_boot & 3
oem_pkhash = True if ((sec_boot >> 4) & 1) == 1 else False
auth_enabled = True if ((sec_boot >> 5) & 1) == 1 else False