mirror of
https://github.com/bkerler/edl.git
synced 2024-11-24 08:27:58 -05:00
Normative code
This commit is contained in:
parent
1a1bec8671
commit
3b9a6927fb
10 changed files with 27 additions and 30 deletions
|
@ -172,7 +172,7 @@ class serial_class(DeviceClass):
|
||||||
bytestoread = resplen - len(info)
|
bytestoread = resplen - len(info)
|
||||||
extend(info)
|
extend(info)
|
||||||
if b"<?xml " in info:
|
if b"<?xml " in info:
|
||||||
while not b"response " in res or res[-7:] != b"</data>":
|
while b"response " not in res or res[-7:] != b"</data>":
|
||||||
extend(epr(1))
|
extend(epr(1))
|
||||||
return res
|
return res
|
||||||
bytestoread = resplen
|
bytestoread = resplen
|
||||||
|
|
|
@ -575,11 +575,11 @@ def main():
|
||||||
op2 = oneplus(None, projid="20889", serial=serial, ATOBuild=0, Flash_Mode=0, cf=0)
|
op2 = oneplus(None, projid="20889", serial=serial, ATOBuild=0, Flash_Mode=0, cf=0)
|
||||||
op2.ops.device_timestamp = int(device_timestamp)
|
op2.ops.device_timestamp = int(device_timestamp)
|
||||||
# 20889 OP N10 5G Europe
|
# 20889 OP N10 5G Europe
|
||||||
print(f"./edl.py rawxml \"<?xml version=\\\"1.0\\\" ?><data><setprocstart /></data>\"")
|
print('./edl.py rawxml "<?xml version=\\"1.0\\" ?><data><setprocstart /></data>"')
|
||||||
# Response should be : <?xml version="1.0" ?><data><response value=1 device_timestamp="%llu" /></data>
|
# Response should be : <?xml version="1.0" ?><data><response value=1 device_timestamp="%llu" /></data>
|
||||||
pk, token = op2.generatetoken(False)
|
pk, token = op2.generatetoken(False)
|
||||||
print(
|
print(
|
||||||
f"./edl.py rawxml \"<?xml version=\\\"1.0\\\" ?><data><setswprojmodel " +
|
'./edl.py rawxml "<?xml version=\\"1.0\\" ?><data><setswprojmodel ' +
|
||||||
f"token=\\\"{token}\\\" pk=\\\"{pk}\\\" /></data>\" --debugmode")
|
f"token=\\\"{token}\\\" pk=\\\"{pk}\\\" /></data>\" --debugmode")
|
||||||
elif args["setprojmodel_verify"]:
|
elif args["setprojmodel_verify"]:
|
||||||
projid = args["--projid"][0]
|
projid = args["--projid"][0]
|
||||||
|
@ -618,8 +618,7 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
def test_setswprojmodel_verify():
|
def test_setswprojmodel_verify():
|
||||||
deviceresp = b"RX:<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\nRX:<data>\nRX:<response value=\"ACK\" " + \
|
deviceresp = b'RX:<?xml version="1.0" encoding="UTF-8" ?>\nRX:<data>\nRX:<response value="ACK" device_timestamp="2507003650" /></data>\n<?xmlversion="1.0" ? ><data><setprocstart /></data>'
|
||||||
b"device_timestamp=\"2507003650\" /></data>\n<?xmlversion=\"1.0\" ? ><data><setprocstart /></data>"
|
|
||||||
projid = "20889"
|
projid = "20889"
|
||||||
op = oneplus(None, projid=projid, serial=123456)
|
op = oneplus(None, projid=projid, serial=123456)
|
||||||
data = deviceresp.decode('utf-8')
|
data = deviceresp.decode('utf-8')
|
||||||
|
|
|
@ -328,7 +328,7 @@ class firehose(metaclass=LogBase):
|
||||||
def cmd_reset(self, mode="reset"):
|
def cmd_reset(self, mode="reset"):
|
||||||
if mode is None:
|
if mode is None:
|
||||||
mode = "reset"
|
mode = "reset"
|
||||||
data = "<?xml version=\"1.0\" ?><data><power value=\"" + mode + "\"/></data>"
|
data = f'<?xml version="1.0" ?><data><power value="{mode}"/></data>'
|
||||||
val = self.xmlsend(data)
|
val = self.xmlsend(data)
|
||||||
try:
|
try:
|
||||||
v = None
|
v = None
|
||||||
|
@ -361,7 +361,7 @@ class firehose(metaclass=LogBase):
|
||||||
return val.error
|
return val.error
|
||||||
|
|
||||||
def cmd_nop(self):
|
def cmd_nop(self):
|
||||||
data = "<?xml version=\"1.0\" ?><data><nop /></data>"
|
data = '<?xml version="1.0" ?><data><nop /></data>'
|
||||||
resp = self.xmlsend(data, True)
|
resp = self.xmlsend(data, True)
|
||||||
self.debug(resp.data.hex())
|
self.debug(resp.data.hex())
|
||||||
info = b""
|
info = b""
|
||||||
|
@ -1241,7 +1241,7 @@ class firehose(metaclass=LogBase):
|
||||||
if len(imei) != 16:
|
if len(imei) != 16:
|
||||||
self.info("IMEI must be 16 digits")
|
self.info("IMEI must be 16 digits")
|
||||||
return False
|
return False
|
||||||
data = "<?xml version=\"1.0\" ?><data><writeIMEI len=\"16\"/></data>"
|
data = '<?xml version="1.0" ?><data><writeIMEI len="16"/></data>'
|
||||||
val = self.xmlsend(data)
|
val = self.xmlsend(data)
|
||||||
if val.resp:
|
if val.resp:
|
||||||
self.info("writeIMEI succeeded.")
|
self.info("writeIMEI succeeded.")
|
||||||
|
@ -1251,7 +1251,7 @@ class firehose(metaclass=LogBase):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def cmd_getstorageinfo(self):
|
def cmd_getstorageinfo(self):
|
||||||
data = "<?xml version=\"1.0\" ?><data><getstorageinfo physical_partition_number=\"0\"/></data>"
|
data = '<?xml version="1.0" ?><data><getstorageinfo physical_partition_number="0"/></data>'
|
||||||
val = self.xmlsend(data)
|
val = self.xmlsend(data)
|
||||||
if val.data == '' and val.log == '' and val.resp:
|
if val.data == '' and val.log == '' and val.resp:
|
||||||
return None
|
return None
|
||||||
|
@ -1266,7 +1266,7 @@ class firehose(metaclass=LogBase):
|
||||||
if len(v) > 1:
|
if len(v) > 1:
|
||||||
res[v[0]] = v[1]
|
res[v[0]] = v[1]
|
||||||
else:
|
else:
|
||||||
if "\"storage_info\"" in value:
|
if '"storage_info"' in value:
|
||||||
try:
|
try:
|
||||||
info = value.replace("INFO:", "")
|
info = value.replace("INFO:", "")
|
||||||
si = json.loads(info)["storage_info"]
|
si = json.loads(info)["storage_info"]
|
||||||
|
@ -1524,7 +1524,7 @@ class firehose(metaclass=LogBase):
|
||||||
def cmd_test(self, cmd):
|
def cmd_test(self, cmd):
|
||||||
token = "1234"
|
token = "1234"
|
||||||
pk = "1234"
|
pk = "1234"
|
||||||
data = "<?xml version=\"1.0\" ?>\n<data>\n<" + cmd + " token=\"" + token + "\" pk=\"" + pk + "\" />\n</data>"
|
data = f'<?xml version="1.0" ?>\n<data>\n<{cmd} token="{token}" pk="{pk}" />\n</data>'
|
||||||
val = self.xmlsend(data)
|
val = self.xmlsend(data)
|
||||||
if val.resp:
|
if val.resp:
|
||||||
if b"raw hex token" in val[2]:
|
if b"raw hex token" in val[2]:
|
||||||
|
@ -1534,7 +1534,7 @@ class firehose(metaclass=LogBase):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def cmd_getstorageinfo_string(self):
|
def cmd_getstorageinfo_string(self):
|
||||||
data = "<?xml version=\"1.0\" ?><data><getstorageinfo /></data>"
|
data = '<?xml version="1.0" ?><data><getstorageinfo /></data>'
|
||||||
val = self.xmlsend(data)
|
val = self.xmlsend(data)
|
||||||
if val.resp:
|
if val.resp:
|
||||||
self.info(f"GetStorageInfo:\n--------------------\n")
|
self.info(f"GetStorageInfo:\n--------------------\n")
|
||||||
|
|
|
@ -194,7 +194,6 @@ AB_SLOT_INACTIVE_VAL = 0x0
|
||||||
AB_SLOT_ACTIVE = 1
|
AB_SLOT_ACTIVE = 1
|
||||||
AB_SLOT_INACTIVE = 0
|
AB_SLOT_INACTIVE = 0
|
||||||
|
|
||||||
|
|
||||||
PART_ATT_PRIORITY_BIT = 48
|
PART_ATT_PRIORITY_BIT = 48
|
||||||
PART_ATT_ACTIVE_BIT = 50
|
PART_ATT_ACTIVE_BIT = 50
|
||||||
PART_ATT_MAX_RETRY_CNT_BIT = 51
|
PART_ATT_MAX_RETRY_CNT_BIT = 51
|
||||||
|
@ -350,7 +349,6 @@ class gpt(metaclass=LogBase):
|
||||||
def parseheader(self, gptdata, sectorsize=512):
|
def parseheader(self, gptdata, sectorsize=512):
|
||||||
return self.gpt_header(gptdata[sectorsize:sectorsize + 0x5C])
|
return self.gpt_header(gptdata[sectorsize:sectorsize + 0x5C])
|
||||||
|
|
||||||
|
|
||||||
def parse(self, gptdata, sectorsize=512):
|
def parse(self, gptdata, sectorsize=512):
|
||||||
self.header = self.gpt_header(gptdata[sectorsize:sectorsize + 0x5C])
|
self.header = self.gpt_header(gptdata[sectorsize:sectorsize + 0x5C])
|
||||||
self.sectorsize = sectorsize
|
self.sectorsize = sectorsize
|
||||||
|
@ -415,7 +413,8 @@ class gpt(metaclass=LogBase):
|
||||||
mstr = "\nGPT Table:\n-------------\n"
|
mstr = "\nGPT Table:\n-------------\n"
|
||||||
for partitionname in self.partentries:
|
for partitionname in self.partentries:
|
||||||
partition = self.partentries[partitionname]
|
partition = self.partentries[partitionname]
|
||||||
active = ((partition.flags >> (AB_FLAG_OFFSET*8))&0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE
|
active = ((partition.flags >> (
|
||||||
|
AB_FLAG_OFFSET * 8)) & 0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE
|
||||||
mstr += ("{:20} Offset 0x{:016x}, Length 0x{:016x}, Flags 0x{:016x}, UUID {}, Type {}, Active {}\n".format(
|
mstr += ("{:20} Offset 0x{:016x}, Length 0x{:016x}, Flags 0x{:016x}, UUID {}, Type {}, Active {}\n".format(
|
||||||
partition.name + ":", partition.sector * self.sectorsize, partition.sectors * self.sectorsize,
|
partition.name + ":", partition.sector * self.sectorsize, partition.sectors * self.sectorsize,
|
||||||
partition.flags, partition.unique, partition.type, active))
|
partition.flags, partition.unique, partition.type, active))
|
||||||
|
|
|
@ -50,7 +50,7 @@ def pt32_walk(data, ttbr, skip):
|
||||||
i += 1
|
i += 1
|
||||||
if i <= skip:
|
if i <= skip:
|
||||||
continue
|
continue
|
||||||
if type(fl) == pt.pt_desc:
|
if isinstance(fl, pt.pt_desc):
|
||||||
print("")
|
print("")
|
||||||
print("Second level (va = %08x)" % va)
|
print("Second level (va = %08x)" % va)
|
||||||
print("---------------------------------------------")
|
print("---------------------------------------------")
|
||||||
|
|
|
@ -17,7 +17,6 @@ parent_dir = os.path.dirname(current_dir)
|
||||||
sys.path.insert(0, parent_dir)
|
sys.path.insert(0, parent_dir)
|
||||||
from edlclient.Library.utils import LogBase, print_progress
|
from edlclient.Library.utils import LogBase, print_progress
|
||||||
|
|
||||||
|
|
||||||
MAX_STORE_SIZE = 1024 * 1024 * 1024 * 2 # 2 GBs
|
MAX_STORE_SIZE = 1024 * 1024 * 1024 * 2 # 2 GBs
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,7 @@ class SierraKeygen(metaclass=LogBase):
|
||||||
devicegeneration = "MDM9x30_V1"
|
devicegeneration = "MDM9x30_V1"
|
||||||
else:
|
else:
|
||||||
devicegeneration = "MDM9x30"
|
devicegeneration = "MDM9x30"
|
||||||
elif "9X40" in revision and not "9X40C" in revision:
|
elif "9X40" in revision and "9X40C" not in revision:
|
||||||
devicegeneration = "MDM9x40"
|
devicegeneration = "MDM9x40"
|
||||||
elif "9X50" in revision:
|
elif "9X50" in revision:
|
||||||
if "NTG9X50" in revision:
|
if "NTG9X50" in revision:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Challenge/Response Generator for Sierra Wireless Cards V1.2
|
# Challenge/Response Generator for Sierra Wireless Cards V1.2
|
||||||
(c) B. Kerler 2019-2023
|
(c) B. Kerler 2019-2024
|
||||||
GPLv3 License
|
GPLv3 License
|
||||||
|
|
||||||
## Why
|
## Why
|
||||||
|
|
Loading…
Reference in a new issue