Files
mi8-platina-linux/scripts/deploy_and_test_ipa_r20.py
T
shenlei 530a3690da
Offline project checks / check (push) Canceled after 0s
feat: add WCN3990 Wi-Fi bringup service, battery protection, and bringup automation
- Add phone-dsp.openrc to initialize Hexagon DSP, rmtfs, pd-mapper, and ath10k_snoc
- Update phone-battery-guard threshold to 80% with power supply node fallbacks
- Enhance phone-cellular-setup with battery gate checks, RF locks, and unit tests
- Include bringup, flashing, and inspection automation scripts for platina
- Update candidate IPA v2.6 patches and package locks
2026-11-12 14:54:23 +09:00

134 lines
4.3 KiB
Python

#!/usr/bin/env python3
"""
Deploy ipa_r20.ko.zst to Xiaomi Mi 8 Lite (platina) and verify rmnet_ipa0 & cellular connectivity.
"""
import http.server
import os
import socket
import socketserver
import subprocess
import sys
import threading
import time
TARGET_IP = "172.16.42.1"
TARGET_PORT = 23
HOST_IP = "172.16.42.2"
HTTP_PORT = 8765
EXPECTED_SHA256 = "d7d3e0ec6c4fe77a720ad8357af8c2ac8bf2d48f73dbf69ede784a6795a3c738"
LOCAL_MODULE = "/tmp/ipa_r20.ko.zst"
def log(msg):
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
class QuietHandler(http.server.SimpleHTTPRequestHandler):
def log_message(self, format, *args):
pass
def start_http_server():
os.chdir("/tmp")
server = socketserver.TCPServer((HOST_IP, HTTP_PORT), QuietHandler)
server_thread = threading.Thread(target=server.serve_forever, daemon=True)
server_thread.start()
log(f"HTTP server serving /tmp on http://{HOST_IP}:{HTTP_PORT}/")
return server
def telnet_cmd(cmd, wait_time=2.0, verbose=True):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(10.0)
s.connect((TARGET_IP, TARGET_PORT))
time.sleep(0.5)
try:
s.recv(4096)
except socket.timeout:
pass
if verbose:
log(f"TELNET CMD: {cmd}")
s.sendall((cmd + "\n").encode("utf-8"))
time.sleep(wait_time)
output = b""
while True:
try:
chunk = s.recv(4096)
if not chunk:
break
output += chunk
except socket.timeout:
break
s.close()
res = output.decode("utf-8", errors="replace")
if verbose:
log(f"OUTPUT:\n{res.strip()}")
return res
def main():
if not os.path.exists(LOCAL_MODULE):
log(f"ERROR: {LOCAL_MODULE} not found!")
return 1
httpd = start_http_server()
# 1. Mount root filesystem
log("Mounting /dev/mmcblk1p79 to /mnt...")
telnet_cmd("mkdir -p /mnt && mount /dev/mmcblk1p79 /mnt")
# 2. Download new module
log(f"Downloading ipa_r20.ko.zst from http://{HOST_IP}:{HTTP_PORT}/...")
telnet_cmd(f"wget -q -O /tmp/ipa_r20.ko.zst http://{HOST_IP}:{HTTP_PORT}/ipa_r20.ko.zst")
# 3. Verify sha256
log("Verifying sha256 on target...")
out = telnet_cmd("sha256sum /tmp/ipa_r20.ko.zst")
if EXPECTED_SHA256 not in out:
log(f"ERROR: sha256 mismatch! Expected {EXPECTED_SHA256}")
return 1
log("SHA256 verification PASSED on target!")
# 4. Install module to both rootfs and current initramfs
log("Installing module to /mnt/usr/lib/modules/... and /lib/modules/...")
telnet_cmd("mkdir -p /mnt/usr/lib/modules/7.2.12-sdm660/kernel/drivers/net/ipa /lib/modules/7.2.12-sdm660/kernel/drivers/net/ipa")
telnet_cmd("cp /tmp/ipa_r20.ko.zst /mnt/usr/lib/modules/7.2.12-sdm660/kernel/drivers/net/ipa/ipa.ko.zst")
telnet_cmd("cp /tmp/ipa_r20.ko.zst /lib/modules/7.2.12-sdm660/kernel/drivers/net/ipa/ipa.ko.zst")
telnet_cmd("sha256sum /lib/modules/7.2.12-sdm660/kernel/drivers/net/ipa/ipa.ko.zst /mnt/usr/lib/modules/7.2.12-sdm660/kernel/drivers/net/ipa/ipa.ko.zst")
# 5. depmod
log("Updating module dependencies...")
telnet_cmd("depmod -a 7.2.12-sdm660")
# 6. Modprobe IPA
log("Loading r20 IPA module: modprobe -v ipa...")
res = telnet_cmd("modprobe -v ipa", wait_time=3.0)
# 7. Check dmesg
log("Inspecting kernel log...")
dmesg_out = telnet_cmd("dmesg | tail -n 35")
# 8. Check rmnet_ipa0 interface
log("Checking rmnet_ipa0 network device...")
ip_out = telnet_cmd("ip link show rmnet_ipa0")
if "rmnet_ipa0" not in ip_out:
log("WARNING: rmnet_ipa0 not listed in ip link yet. Checking all interfaces...")
telnet_cmd("ip link")
# 9. Wait 65s for runtime autosuspend stability test
log("Running 65s idle stress test to verify autosuspend stability...")
for sec in range(1, 14):
time.sleep(5)
print(f".{sec*5}s", end="", flush=True)
print()
# 10. Check dmesg for crashes
log("Checking dmesg for any kernel oops or panic...")
dmesg_after = telnet_cmd("dmesg | tail -n 35")
if "Unable to handle kernel NULL pointer dereference" in dmesg_after or "Oops:" in dmesg_after:
log("FAILURE: Kernel crash detected in dmesg!")
return 1
log("SUCCESS: Zero kernel crashes during 65s autosuspend test!")
return 0
if __name__ == "__main__":
sys.exit(main())