Bring up nokia-sparkler SMP/cpufreq/lk2nd/cam/haptics, fix timer and EDL USB timeout
- Add 0013 early-SCM 4-core SMP + cpufreq kernel patch and clock-frequency DT nodes - Complete nokia-sparkler lk2nd port, boot/X11 session startup, 180-deg cached camera, and 157 Hz haptic audio - Replace root-only timer backend with permissionless sxmo_timer.sh and keypad/hook cancellation - Fix EDL Firehose rawmode ACK, USB active-config preservation, *+# hint, and 30 s default USB timeout - Sync a1120 (cocojamboo) prebuilts, docs, tests, and verified checksums in check-rebuild.sh
This commit is contained in:
1 parent
ab53423e33
commit
d7992904bf
56 files changed
+31850
-28281
No files matched your search
Vendored
+149
-96
@@ -5,34 +5,43 @@ import os
|
||||
from Library.utils import *
|
||||
|
||||
class xmlparser():
|
||||
def getresponse(self,input):
|
||||
lines=input.split(b"<?xml")
|
||||
content = {}
|
||||
for line in lines:
|
||||
if line==b'':
|
||||
def _iter_roots(self, raw):
|
||||
raw_bytes = bytes(raw)
|
||||
first_xml = raw_bytes.find(b"<?xml")
|
||||
if first_xml == -1:
|
||||
return []
|
||||
roots = []
|
||||
for chunk in raw_bytes[first_xml:].split(b"<?xml"):
|
||||
if not chunk:
|
||||
continue
|
||||
line=b"<?xml"+line
|
||||
parser = ET.XMLParser(encoding="utf-8")
|
||||
tree = ET.fromstring(line, parser=parser)
|
||||
e = ET.ElementTree(tree).getroot()
|
||||
for atype in e.findall('response'):
|
||||
part = b"<?xml" + chunk
|
||||
end = part.find(b"</data>")
|
||||
if end != -1:
|
||||
part = part[:end + len(b"</data>")]
|
||||
part = part.strip(b"\x00 \t\r\n")
|
||||
if not part:
|
||||
continue
|
||||
try:
|
||||
parser = ET.XMLParser(encoding="utf-8")
|
||||
roots.append(ET.fromstring(part, parser=parser))
|
||||
except ET.ParseError:
|
||||
continue
|
||||
return roots
|
||||
|
||||
def getresponse(self, input):
|
||||
content = {}
|
||||
for root in self._iter_roots(input):
|
||||
for atype in root.findall('response'):
|
||||
for field in atype.attrib:
|
||||
content[field]=atype.attrib[field]
|
||||
content[field] = atype.attrib[field]
|
||||
return content
|
||||
|
||||
def getlog(self,input):
|
||||
lines=input.split(b"<?xml")
|
||||
def getlog(self, input):
|
||||
data = ''
|
||||
for line in lines:
|
||||
if line==b'':
|
||||
continue
|
||||
line=b"<?xml"+line
|
||||
parser = ET.XMLParser(encoding="utf-8")
|
||||
tree = ET.fromstring(line, parser=parser)
|
||||
e = ET.ElementTree(tree).getroot()
|
||||
for atype in e.findall('log'):
|
||||
for root in self._iter_roots(input):
|
||||
for atype in root.findall('log'):
|
||||
if 'value' in atype.attrib:
|
||||
data+=atype.attrib['value']
|
||||
data += atype.attrib['value']
|
||||
return data
|
||||
|
||||
class qualcomm_firehose:
|
||||
@@ -245,89 +254,133 @@ class qualcomm_firehose:
|
||||
return False
|
||||
return False
|
||||
|
||||
def cmd_read_buffer(self,physical_partition_number,start_sector,num_partition_sectors,Display=True):
|
||||
def _begin_raw_read(self, xml_cmd, bytes_to_read):
|
||||
"""Send a <read> command and handle optional initial ACK XML packets.
|
||||
|
||||
Standard Qualcomm Firehose loaders (8k.mbn, 2720v.mbn) answer <read>
|
||||
with <response value="ACK" rawmode="true" /> before streaming raw
|
||||
sectors, whereas FIH programmers (8110.mbn, 2720.mbn, 800t.mbn) stream
|
||||
raw sector data immediately.
|
||||
"""
|
||||
self.cdc.write(xml_cmd, self.cfg.MaxXMLSizeInBytes)
|
||||
sector_size = self.cfg.SECTOR_SIZE_IN_BYTES
|
||||
max_chunk = max(sector_size, self.cfg.MaxPayloadSizeToTargetInBytes)
|
||||
read_size = min(bytes_to_read, max_chunk) if bytes_to_read > 0 else max_chunk
|
||||
pending = bytearray()
|
||||
while True:
|
||||
if pending:
|
||||
pkt = bytes(pending)
|
||||
pending = bytearray()
|
||||
else:
|
||||
pkt = bytes(self.cdc.read(read_size))
|
||||
if not pkt:
|
||||
return False, bytearray(), "empty response from device"
|
||||
raw = pkt.lstrip(b"\x00 \t\r\n")
|
||||
end_idx = pkt.find(b"</data>")
|
||||
is_xml = (
|
||||
raw.startswith(b"<?xml")
|
||||
and end_idx != -1
|
||||
and (b"<response" in pkt[:end_idx] or b"<log" in pkt[:end_idx])
|
||||
)
|
||||
if not is_xml:
|
||||
return True, bytearray(pkt), ""
|
||||
|
||||
split_at = end_idx + len(b"</data>")
|
||||
xml_part = pkt[:split_at]
|
||||
tail = pkt[split_at:]
|
||||
if tail and (len(tail) >= sector_size or tail.strip(b"\x00 \t\r\n")):
|
||||
leftover = bytearray(tail)
|
||||
else:
|
||||
leftover = bytearray()
|
||||
|
||||
log_msg = self.xml.getlog(xml_part)
|
||||
resp = self.xml.getresponse(xml_part)
|
||||
if not resp:
|
||||
if leftover and leftover.lstrip(b"\x00 \t\r\n").startswith(b"<?xml"):
|
||||
pending = leftover
|
||||
continue
|
||||
if self.getstatus(resp):
|
||||
return True, leftover, log_msg
|
||||
return False, bytearray(), log_msg or xml_part.decode("utf-8", "replace")
|
||||
|
||||
def _read_raw_sectors(self, physical_partition_number, start_sector, num_partition_sectors, on_chunk, Display=True):
|
||||
if Display:
|
||||
print(f"\nReading from physical partition {str(physical_partition_number)}, sector {str(start_sector)}, sectors {str(num_partition_sectors)}")
|
||||
data=f"<?xml version=\"1.0\" ?><data><read SECTOR_SIZE_IN_BYTES=\"{self.cfg.SECTOR_SIZE_IN_BYTES}\""+\
|
||||
f" num_partition_sectors=\"{num_partition_sectors}\""+\
|
||||
f" physical_partition_number=\"{physical_partition_number}\""+\
|
||||
f" start_sector=\"{start_sector}\"/>\n</data>"
|
||||
rsp=self.xmlsend(data, True)
|
||||
resData=bytearray()
|
||||
if (rsp[0])==True:
|
||||
bytesToRead=self.cfg.SECTOR_SIZE_IN_BYTES*num_partition_sectors
|
||||
total=bytesToRead
|
||||
dataread=0
|
||||
old=0
|
||||
prog=0
|
||||
if Display:
|
||||
print_progress(prog, 100, prefix='Progress:', suffix='Complete', bar_length=50)
|
||||
while(bytesToRead>0):
|
||||
tmp=self.cdc.read(self.cfg.MaxPayloadSizeToTargetInBytes)
|
||||
bytesToRead-=len(tmp)
|
||||
dataread+=len(tmp)
|
||||
resData+=tmp
|
||||
data = (
|
||||
f"<?xml version=\"1.0\" ?><data><read SECTOR_SIZE_IN_BYTES=\"{self.cfg.SECTOR_SIZE_IN_BYTES}\""
|
||||
f" num_partition_sectors=\"{num_partition_sectors}\""
|
||||
f" physical_partition_number=\"{physical_partition_number}\""
|
||||
f" start_sector=\"{start_sector}\"/>\n</data>"
|
||||
)
|
||||
bytes_to_read = self.cfg.SECTOR_SIZE_IN_BYTES * num_partition_sectors
|
||||
ok, initial_raw, err_info = self._begin_raw_read(data, bytes_to_read)
|
||||
if not ok:
|
||||
print(f"Error:{err_info}")
|
||||
return False
|
||||
max_chunk = max(self.cfg.SECTOR_SIZE_IN_BYTES, self.cfg.MaxPayloadSizeToTargetInBytes)
|
||||
total = bytes_to_read
|
||||
dataread = 0
|
||||
old = 0
|
||||
prog = 0
|
||||
if Display:
|
||||
print_progress(prog, 100, prefix='Progress:', suffix='Complete', bar_length=50)
|
||||
if initial_raw and bytes_to_read > 0:
|
||||
chunk = initial_raw[:bytes_to_read]
|
||||
on_chunk(chunk)
|
||||
bytes_to_read -= len(chunk)
|
||||
dataread += len(chunk)
|
||||
if total > 0:
|
||||
prog = int(float(dataread) / float(total) * float(100))
|
||||
if (prog > old):
|
||||
if prog > old:
|
||||
if Display:
|
||||
print_progress(prog, 100, prefix='Progress:', suffix='Complete', bar_length=50)
|
||||
old = prog
|
||||
if Display and prog!=100:
|
||||
print_progress(100, 100, prefix='Progress:', suffix='Complete', bar_length=50)
|
||||
time.sleep(0.2)
|
||||
info, rsp = self.wait_response()
|
||||
if rsp.get("value")=="ACK":
|
||||
return resData
|
||||
else:
|
||||
print(f"Error:{info}")
|
||||
return ""
|
||||
else:
|
||||
print(f"Error:{rsp[2]}")
|
||||
return ""
|
||||
return ""
|
||||
|
||||
def cmd_read(self,physical_partition_number,start_sector,num_partition_sectors,filename,Display=True):
|
||||
if Display:
|
||||
print(f"\nReading from physical partition {str(physical_partition_number)}, sector {str(start_sector)}, sectors {str(num_partition_sectors)}")
|
||||
with open(filename,"wb") as wf:
|
||||
data=f"<?xml version=\"1.0\" ?><data><read SECTOR_SIZE_IN_BYTES=\"{self.cfg.SECTOR_SIZE_IN_BYTES}\""+\
|
||||
f" num_partition_sectors=\"{num_partition_sectors}\""+\
|
||||
f" physical_partition_number=\"{physical_partition_number}\""+\
|
||||
f" start_sector=\"{start_sector}\"/>\n</data>"
|
||||
rsp=self.xmlsend(data, True)
|
||||
if (rsp[0])==True:
|
||||
bytesToRead=self.cfg.SECTOR_SIZE_IN_BYTES*num_partition_sectors
|
||||
total=bytesToRead
|
||||
dataread=0
|
||||
old=0
|
||||
prog=0
|
||||
while bytes_to_read > 0:
|
||||
tmp = self.cdc.read(min(bytes_to_read, max_chunk))
|
||||
if not tmp:
|
||||
print("Error:Short read from device")
|
||||
return False
|
||||
chunk = tmp[:bytes_to_read]
|
||||
on_chunk(chunk)
|
||||
bytes_to_read -= len(chunk)
|
||||
dataread += len(chunk)
|
||||
prog = int(float(dataread) / float(total) * float(100))
|
||||
if prog > old:
|
||||
if Display:
|
||||
print_progress(prog, 100, prefix='Progress:', suffix='Complete', bar_length=50)
|
||||
while(bytesToRead>0):
|
||||
tmp=self.cdc.read(self.cfg.MaxPayloadSizeToTargetInBytes)
|
||||
bytesToRead-=len(tmp)
|
||||
dataread+=len(tmp)
|
||||
#resData+=tmp
|
||||
wf.write(tmp)
|
||||
prog = int(float(dataread) / float(total) * float(100))
|
||||
if (prog > old):
|
||||
if Display:
|
||||
print_progress(prog, 100, prefix='Progress:', suffix='Complete', bar_length=50)
|
||||
old = prog
|
||||
#time.sleep(0.05)
|
||||
if Display and prog!=100:
|
||||
print_progress(100, 100, prefix='Progress:', suffix='Complete', bar_length=50)
|
||||
time.sleep(0.2)
|
||||
info, rsp = self.wait_response()
|
||||
if rsp.get("value")=="ACK":
|
||||
return tmp
|
||||
else:
|
||||
print(f"Error:{info}")
|
||||
return ""
|
||||
else:
|
||||
print(f"Error:{rsp[1]}")
|
||||
return ""
|
||||
old = prog
|
||||
if Display and prog != 100:
|
||||
print_progress(100, 100, prefix='Progress:', suffix='Complete', bar_length=50)
|
||||
time.sleep(0.2)
|
||||
info, rsp = self.wait_response()
|
||||
if rsp.get("value") == "ACK":
|
||||
return True
|
||||
print(f"Error:{info}")
|
||||
return False
|
||||
|
||||
def cmd_read_buffer(self, physical_partition_number, start_sector, num_partition_sectors, Display=True):
|
||||
resData = bytearray()
|
||||
if not self._read_raw_sectors(
|
||||
physical_partition_number,
|
||||
start_sector,
|
||||
num_partition_sectors,
|
||||
resData.extend,
|
||||
Display=Display,
|
||||
):
|
||||
return ""
|
||||
return resData
|
||||
|
||||
def cmd_read(self, physical_partition_number, start_sector, num_partition_sectors, filename, Display=True):
|
||||
with open(filename, "wb") as wf:
|
||||
if not self._read_raw_sectors(
|
||||
physical_partition_number,
|
||||
start_sector,
|
||||
num_partition_sectors,
|
||||
wf.write,
|
||||
Display=Display,
|
||||
):
|
||||
return ""
|
||||
return True
|
||||
|
||||
def connect(self,lvl):
|
||||
v = b'-1'
|
||||
|
||||
Vendored
+1
-1
@@ -260,7 +260,7 @@ class qualcomm_sahara():
|
||||
|
||||
def connect(self):
|
||||
try:
|
||||
v = self.cdc.read()
|
||||
v = self.cdc.read(timeout=2000)
|
||||
if b"<?xml" in v:
|
||||
return "Firehose"
|
||||
elif v[0]==0x01:
|
||||
|
||||
Vendored
+19
-7
@@ -1,6 +1,9 @@
|
||||
import usb.core # pyusb
|
||||
import usb.util
|
||||
|
||||
DEFAULT_USB_TIMEOUT_MS = 30000
|
||||
|
||||
|
||||
class usb_class():
|
||||
|
||||
def log(self,level,msg):
|
||||
@@ -10,10 +13,11 @@ class usb_class():
|
||||
else:
|
||||
print(msg)
|
||||
|
||||
def __init__(self,vid=0x05c6, pid=0x9008, Debug=False):
|
||||
def __init__(self,vid=0x05c6, pid=0x9008, Debug=False, timeout_ms=DEFAULT_USB_TIMEOUT_MS):
|
||||
self.vid=vid
|
||||
self.pid=pid
|
||||
self.debug=Debug
|
||||
self.timeout_ms=timeout_ms
|
||||
self.connected=False
|
||||
|
||||
def connect(self):
|
||||
@@ -28,8 +32,13 @@ class usb_class():
|
||||
except:
|
||||
pass
|
||||
|
||||
self.device.set_configuration()
|
||||
self.configuration = self.device.get_active_configuration()
|
||||
try:
|
||||
self.configuration = self.device.get_active_configuration()
|
||||
except usb.core.USBError:
|
||||
self.configuration = None
|
||||
if self.configuration is None:
|
||||
self.device.set_configuration()
|
||||
self.configuration = self.device.get_active_configuration()
|
||||
self.log(2, self.configuration)
|
||||
for itf_num in [0]:
|
||||
itf = usb.util.find_descriptor(self.configuration,
|
||||
@@ -56,20 +65,23 @@ class usb_class():
|
||||
lambda e: \
|
||||
usb.util.endpoint_direction(e.bEndpointAddress) == \
|
||||
usb.util.ENDPOINT_IN)
|
||||
self.device.default_timeout = self.timeout_ms
|
||||
self.connected=True
|
||||
return True
|
||||
|
||||
def write(self,command,pktsize=64):
|
||||
def write(self,command,pktsize=64,timeout=None):
|
||||
eff_timeout=self.timeout_ms if timeout is None else timeout
|
||||
pos=0
|
||||
if command==b'':
|
||||
self.device.write(self.EP_OUT, b'')
|
||||
self.device.write(self.EP_OUT, b'', eff_timeout)
|
||||
else:
|
||||
while pos<len(command):
|
||||
self.device.write(self.EP_OUT,command[pos:pos+pktsize])
|
||||
self.device.write(self.EP_OUT,command[pos:pos+pktsize],eff_timeout)
|
||||
pos+=pktsize
|
||||
|
||||
def read(self,length=0x80000,timeout=None):
|
||||
eff_timeout=self.timeout_ms if timeout is None else timeout
|
||||
tmp=b''
|
||||
while (bytearray(tmp) == b''):
|
||||
tmp=self.device.read(self.EP_IN, length,timeout)
|
||||
tmp=self.device.read(self.EP_IN, length, eff_timeout)
|
||||
return bytearray(tmp)
|
||||
Reference in new issue
Block a user