feat: add WCN3990 Wi-Fi bringup service, battery protection, and bringup automation
Offline project checks / check (push) Canceled after 0s
Offline project checks / check (push) Canceled after 0s
- 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
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Step 2: While phone is connected in initramfs telnet, apply disarm, continue boot,
|
||||
and run controlled bringup over SSH.
|
||||
"""
|
||||
import http.server
|
||||
import os
|
||||
import socket
|
||||
import socketserver
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
TARGET_IP = "172.16.42.1"
|
||||
HOST_IP = "172.16.42.2"
|
||||
HTTP_PORT = 9877
|
||||
SSH_KEY = "/Users/shenlei/Work/sshKey/oracle_tokyo_ARM.key"
|
||||
|
||||
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():
|
||||
server = socketserver.TCPServer(("0.0.0.0", HTTP_PORT), QuietHandler)
|
||||
t = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
t.start()
|
||||
return server
|
||||
|
||||
def telnet_cmd(cmds, wait_time=1.5):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(10.0)
|
||||
s.connect((TARGET_IP, 23))
|
||||
time.sleep(0.3)
|
||||
try:
|
||||
s.recv(4096)
|
||||
except socket.timeout:
|
||||
pass
|
||||
out = ""
|
||||
for cmd in cmds:
|
||||
log(f"Telnet: {cmd}")
|
||||
s.sendall((cmd + "\n").encode("utf-8"))
|
||||
time.sleep(wait_time)
|
||||
while True:
|
||||
try:
|
||||
chunk = s.recv(4096)
|
||||
if not chunk:
|
||||
break
|
||||
out += chunk.decode("utf-8", errors="replace")
|
||||
except socket.timeout:
|
||||
break
|
||||
s.close()
|
||||
return out
|
||||
|
||||
def run_ssh(cmd, timeout=30):
|
||||
ssh_cmd = [
|
||||
"ssh",
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"-o", "UserKnownHostsFile=/dev/null",
|
||||
"-o", "ConnectTimeout=5",
|
||||
"-i", SSH_KEY,
|
||||
f"server@{TARGET_IP}",
|
||||
cmd
|
||||
]
|
||||
res = subprocess.run(ssh_cmd, capture_output=True, text=True, timeout=timeout)
|
||||
return res.returncode, res.stdout, res.stderr
|
||||
|
||||
def main():
|
||||
log("Verifying telnet port 23 is reachable...")
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(2.0)
|
||||
try:
|
||||
s.connect((TARGET_IP, 23))
|
||||
s.close()
|
||||
log("Telnet port 23 is reachable!")
|
||||
except Exception as e:
|
||||
log(f"Telnet not reachable: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
http_srv = start_http_server()
|
||||
log(f"HTTP server started on port {HTTP_PORT}")
|
||||
|
||||
disarm_cmds = [
|
||||
"cat /sys/class/power_supply/qcom-battery/capacity /sys/class/power_supply/qcom-battery/voltage_now",
|
||||
"e2fsck -fy /dev/mmcblk1p79",
|
||||
"mount_root_partition 2>/dev/null || mount /dev/mmcblk1p79 /sysroot 2>/dev/null",
|
||||
# Write foolproof install /bin/true to block any udev auto-probing
|
||||
"mkdir -p /sysroot/etc/modprobe.d",
|
||||
"echo 'install qcom_q6v5_mss /bin/true' > /sysroot/etc/modprobe.d/modem-blacklist.conf",
|
||||
"echo 'install ipa /bin/true' >> /sysroot/etc/modprobe.d/modem-blacklist.conf",
|
||||
"echo 'blacklist qcom_q6v5_mss' >> /sysroot/etc/modprobe.d/modem-blacklist.conf",
|
||||
"echo 'blacklist ipa' >> /sysroot/etc/modprobe.d/modem-blacklist.conf",
|
||||
# Clear modules-load.d
|
||||
"sed -i '/qcom_q6v5_mss/d' /sysroot/etc/modules-load.d/modem.conf 2>/dev/null",
|
||||
"sed -i '/ipa/d' /sysroot/etc/modules-load.d/modem.conf 2>/dev/null",
|
||||
# Disable ModemManager autostart
|
||||
"mv /sysroot/usr/share/dbus-1/system-services/org.freedesktop.ModemManager1.service /sysroot/usr/share/dbus-1/system-services/org.freedesktop.ModemManager1.service.disabled 2>/dev/null",
|
||||
"rm -f /sysroot/etc/runlevels/default/modemmanager 2>/dev/null",
|
||||
# Deploy updated platina-cellular
|
||||
f"wget -O /sysroot/usr/local/sbin/platina-cellular http://{HOST_IP}:{HTTP_PORT}/scripts/phone-cellular-setup.py",
|
||||
"chmod +x /sysroot/usr/local/sbin/platina-cellular",
|
||||
"cat /sysroot/etc/modprobe.d/modem-blacklist.conf",
|
||||
"sync",
|
||||
"umount /sysroot",
|
||||
"/sbin/pmos_continue_boot"
|
||||
]
|
||||
|
||||
log("Applying disarm configuration and continuing boot...")
|
||||
out = telnet_cmd(disarm_cmds, wait_time=1.0)
|
||||
log(f"Telnet output:\n{out}")
|
||||
http_srv.shutdown()
|
||||
|
||||
# Wait for OpenRC userspace SSH
|
||||
log("Waiting for OpenRC userspace boot (SSH port 22)...")
|
||||
start = time.time()
|
||||
ssh_ready = False
|
||||
while time.time() - start < 60:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(1.0)
|
||||
try:
|
||||
s.connect((TARGET_IP, 22))
|
||||
s.close()
|
||||
log(f"SUCCESS: SSH port 22 is OPEN after {int(time.time() - start)}s!")
|
||||
ssh_ready = True
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(1)
|
||||
|
||||
if not ssh_ready:
|
||||
log("ERROR: Timed out waiting for SSH port 22.")
|
||||
sys.exit(1)
|
||||
|
||||
time.sleep(3)
|
||||
log("Testing SSH login to server@172.16.42.1...")
|
||||
code, out, err = run_ssh("uname -a; uptime; cat /sys/class/power_supply/qcom-battery/voltage_now")
|
||||
log(f"SSH test (code={code}):\n{out.strip()}\n{err.strip()}")
|
||||
|
||||
# Verify blacklisted modules are NOT loaded
|
||||
code, out, err = run_ssh("lsmod | grep -E 'qcom_q6v5_mss|ipa'")
|
||||
log(f"Check blacklisted modules (expect empty):\n{out.strip()}")
|
||||
|
||||
# Controlled bringup
|
||||
log("\n--- Step 1: Check battery gate ---")
|
||||
code, out, err = run_ssh("sudo /usr/local/sbin/platina-cellular --battery-check")
|
||||
log(f"Battery gate:\n{out.strip()}")
|
||||
|
||||
log("\n--- Step 2: Start rmtfs and load modules safely ---")
|
||||
code, out, err = run_ssh("sudo rc-service rmtfs start; sudo /usr/local/sbin/platina-cellular --load-modules")
|
||||
log(f"Load modules:\n{out.strip()}")
|
||||
|
||||
time.sleep(3)
|
||||
log("\n--- Step 3: Check IPA sysfs endpoints ---")
|
||||
code, out, err = run_ssh("cat /sys/devices/platform/soc@0/14780000.ipa/modem/tx_endpoint_id 2>/dev/null; echo '---'; cat /sys/devices/platform/soc@0/14780000.ipa/modem/rx_endpoint_id 2>/dev/null")
|
||||
log(f"IPA endpoints:\n{out.strip()}")
|
||||
|
||||
log("\n--- Step 4: Lock RF bands (LTE B1,B3) and bring online ---")
|
||||
code, out, err = run_ssh("sudo /usr/local/sbin/platina-cellular --optimize-rf --rat lte --bands 1,3; sudo /usr/local/sbin/platina-cellular --online")
|
||||
log(f"RF lock and online:\n{out.strip()}")
|
||||
|
||||
time.sleep(3)
|
||||
log("\n--- Step 5: Activate cellular data ---")
|
||||
code, out, err = run_ssh("sudo /usr/local/sbin/platina-cellular --auto --once")
|
||||
log(f"Cellular data setup:\n{out.strip()}")
|
||||
|
||||
log("\n--- Step 6: Check ip route and ping ---")
|
||||
code, out, err = run_ssh("ip route; ping -c 3 -I rmnet_ipa0 1.1.1.1 2>&1 || ping -c 3 1.1.1.1 2>&1")
|
||||
log(f"Connectivity test:\n{out.strip()}")
|
||||
|
||||
log("\n--- Step 7: Check EasyTier mesh status ---")
|
||||
code, out, err = run_ssh("sudo /usr/local/sbin/platina-mesh --status 2>&1")
|
||||
log(f"EasyTier mesh status:\n{out.strip()}")
|
||||
|
||||
log("\n=== Controlled bringup completed successfully! ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user