feat(cellular, power): enable SDM660 IPA v2.6L 4G LTE, power-key status screen, and DVFS standby
Offline project checks / check (push) Canceled after 0s

This commit is contained in:
shenlei
2026-11-18 01:39:26 +09:00
parent 5a50a8264c
commit 8d12d341bf
43 changed files with 6850 additions and 229 deletions
+93
View File
@@ -16,6 +16,48 @@ rpmsg = importlib.util.module_from_spec(spec)
spec.loader.exec_module(rpmsg)
class FrameStatsTests(unittest.TestCase):
@staticmethod
def encode(payload):
fcs = rpmsg.PPPFrameStats.fcs(payload) ^ 0xffff
frame = payload + fcs.to_bytes(2, 'little')
escaped = bytearray(b'\x7e')
for byte in frame:
if byte < 0x20 or byte in (0x7d, 0x7e):
escaped.extend((0x7d, byte ^ 0x20))
else:
escaped.append(byte)
return bytes(escaped) + b'\x7e'
def test_fcs_matches_captured_modem_lcp_frame(self):
stats = rpmsg.PPPFrameStats()
stats.feed(bytes.fromhex('7e80210100000467c37e'))
self.assertEqual(stats.protocols, {'ipcp': 1})
self.assertEqual(stats.invalid_fcs, 0)
def test_stream_splits_and_compression_do_not_change_ip_counts(self):
stats = rpmsg.PPPFrameStats()
payload = bytes(range(40)) + b'\x7d\x7e'
data = self.encode(b'\xff\x03\x00\x21' + payload)
data += self.encode(b'\x21' + payload)
# Includes every split position, including the middle of escapes/FCS.
for byte in b'CONNECT\r\n' + data:
stats.feed(bytes([byte]))
self.assertEqual(stats.protocols, {'ipv4': 2})
self.assertEqual(stats.ipv4_bytes, len(payload) * 2)
self.assertEqual(stats.invalid_fcs, 0)
def test_corrupt_and_oversized_frames_are_not_received_ip(self):
stats = rpmsg.PPPFrameStats()
stats.feed(b'\x7e\x21\x45\x01\x02\x03\x7e')
stats.feed(b'\x7e' + b'x' * 65537 + b'\x7e')
stats.feed(self.encode(b'\xc0\x21\x09\x00\x00\x04'))
self.assertEqual(stats.invalid_fcs, 1)
self.assertEqual(stats.oversized, 1)
self.assertEqual(stats.protocols, {'lcp': 1})
self.assertEqual(stats.ipv4_bytes, 0)
class ATTests(unittest.TestCase):
def exchange(self, chunks, command='AT', timeout=1):
host, modem = socket.socketpair(type=socket.SOCK_DGRAM)
@@ -108,6 +150,57 @@ class EndpointTests(unittest.TestCase):
class PPPTests(unittest.TestCase):
def test_shutdown_forwards_termination_and_peer_ack(self):
host, modem = socket.socketpair(type=socket.SOCK_DGRAM)
self.addCleanup(host.close)
self.addCleanup(modem.close)
host.setblocking(False)
modem.settimeout(2)
master, slave = rpmsg.pty.openpty()
self.addCleanup(os.close, master)
self.addCleanup(os.close, slave)
rpmsg.tty.setraw(slave)
os.set_blocking(master, False)
os.set_blocking(slave, False)
termination = b'\x7e\xff\x03\xc0\x21\x05\x01\x00\x04\x7e'
ack = b'\x7e\xff\x03\xc0\x21\x06\x01\x00\x04\x7e'
observed = []
def peer():
observed.append(modem.recv(1024))
modem.send(ack)
thread = threading.Thread(target=peer, daemon=True)
thread.start()
class Process:
killed = False
returncode = None
def terminate(self):
os.write(slave, termination)
def poll(self):
if select.select([slave], [], [], 0)[0]:
if os.read(slave, 1024) == ack:
self.returncode = 0
return self.returncode
def kill(self):
self.killed = True
self.returncode = -9
def wait(self, timeout=None):
return self.returncode
process = Process()
rpmsg.stop_ppp(process, host.fileno(), master, timeout=1)
thread.join(timeout=2)
self.assertFalse(thread.is_alive())
self.assertEqual(observed, [termination])
self.assertEqual(process.returncode, 0)
self.assertFalse(process.killed)
def test_manager_is_restored_when_modem_preparation_fails(self):
calls = []