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:
Executable
+107
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Long-running robust watcher for phone SSH connection over en21.
|
||||
Continuously clears route reject flags, monitors Oerrs, and connects SSH as soon as reachable.
|
||||
"""
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
TARGET_IP = "172.16.42.1"
|
||||
SSH_KEY = "/Users/shenlei/Work/sshKey/oracle_tokyo_ARM.key"
|
||||
|
||||
def log(msg):
|
||||
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
||||
|
||||
def run_cmd(cmd):
|
||||
res = subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
||||
return res.stdout.strip()
|
||||
|
||||
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("=== Robust SSH Bringup Monitor Started ===")
|
||||
log("Monitoring for cable replug and SSH response on 172.16.42.1:22...")
|
||||
|
||||
last_notify = 0
|
||||
while True:
|
||||
# Check if en21 exists and has IP
|
||||
ifconfig = run_cmd("ifconfig en21 2>/dev/null")
|
||||
if "status: active" in ifconfig and "172.16.42.2" in ifconfig:
|
||||
# Test TCP port 22
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(1.0)
|
||||
try:
|
||||
s.connect((TARGET_IP, 22))
|
||||
s.close()
|
||||
log(f">>> SUCCESS: Connected to {TARGET_IP}:22! <<<")
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Periodically ensure manual config
|
||||
if time.time() - last_notify > 15:
|
||||
run_cmd('networksetup -setmanual "Xiaomi Mi 8 Lite" 172.16.42.2 255.255.255.0 172.16.42.1 2>/dev/null')
|
||||
last_notify = time.time()
|
||||
# Check Oerrs
|
||||
stats = run_cmd("netstat -I en21 | grep Link")
|
||||
log(f"Waiting for replug... Current en21 stats: {stats}")
|
||||
elif "status: active" in ifconfig:
|
||||
run_cmd('networksetup -setmanual "Xiaomi Mi 8 Lite" 172.16.42.2 255.255.255.0 172.16.42.1 2>/dev/null')
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
time.sleep(1)
|
||||
log("Logging into phone via SSH...")
|
||||
code, out, err = run_ssh("uname -a; uptime; cat /sys/class/power_supply/qcom-battery/voltage_now; cat /sys/class/power_supply/qcom-battery/capacity; cat /sys/class/power_supply/qcom-battery/status")
|
||||
log(f"System status (code={code}):\n{out}")
|
||||
|
||||
log("\n--- Checking blacklisted modules (expect empty) ---")
|
||||
code, out, err = run_ssh("lsmod | grep -E 'qcom_q6v5_mss|ipa'")
|
||||
log(f"Loaded modem modules:\n{out}")
|
||||
|
||||
log("\n--- Step 1: Check Battery Gate Policy ---")
|
||||
code, out, err = run_ssh("sudo /usr/local/sbin/platina-cellular --battery-gate")
|
||||
log(f"Battery gate result (code={code}):\n{out}")
|
||||
|
||||
log("\n--- Step 2: Start rmtfs and load modem/IPA modules safely ---")
|
||||
code, out, err = run_ssh("sudo rc-service rmtfs start; sudo /usr/local/sbin/platina-cellular --load-modules")
|
||||
log(f"Load modules result (code={code}):\n{out}")
|
||||
|
||||
log("\n--- Step 3: Verify IPA sysfs endpoints (expect fixed TX: 3, RX: 16) ---")
|
||||
code, out, err = run_ssh("cat /sys/devices/platform/soc@0/14780000.ipa/modem/tx_endpoint_id; cat /sys/devices/platform/soc@0/14780000.ipa/modem/rx_endpoint_id")
|
||||
log(f"IPA sysfs endpoints (code={code}):\n{out}")
|
||||
|
||||
log("\n--- Step 4: Lock RAT to LTE and bands to China Unicom (1,3), 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 result (code={code}):\n{out}")
|
||||
|
||||
log("\n--- Step 5: Activate cellular data connection ---")
|
||||
code, out, err = run_ssh("sudo /usr/local/sbin/platina-cellular --auto --once")
|
||||
log(f"Cellular data setup (code={code}):\n{out}")
|
||||
|
||||
log("\n--- Step 6: Test cellular data path ping ---")
|
||||
code, out, err = run_ssh("ip addr show rmnet_ipa0 2>/dev/null; ip route; ping -c 4 -I rmnet_ipa0 1.1.1.1 2>/dev/null || ping -c 4 1.1.1.1")
|
||||
log(f"Connectivity test (code={code}):\n{out}")
|
||||
|
||||
log("\n--- Step 7: Check EasyTier mesh status and ping Tokyo node ---")
|
||||
code, out, err = run_ssh("sudo rc-service easytier status || sudo rc-service easytier start; sudo /usr/local/sbin/platina-mesh --status; ping -c 4 192.168.20.2")
|
||||
log(f"EasyTier mesh status (code={code}):\n{out}")
|
||||
|
||||
log("\n=== Complete Platina Bringup Successful! ===")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user