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
150 lines
5.6 KiB
Python
Executable File
150 lines
5.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Reboot phone from Fastboot and monitor every step of the boot process:
|
|
USB enumeration, en21 link status, ARP resolution, and SSH bringup.
|
|
"""
|
|
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("=== Live Boot & Bringup Initiated ===")
|
|
|
|
# 1. Verify fastboot device
|
|
fb = run_cmd("fastboot devices")
|
|
if not fb:
|
|
log("ERROR: No fastboot device detected!")
|
|
return 1
|
|
log(f"Fastboot device present: {fb}")
|
|
|
|
# 2. Issue fastboot reboot
|
|
log("Issuing 'fastboot reboot' to boot natively from eMMC...")
|
|
res = subprocess.run(["fastboot", "reboot"], capture_output=True, text=True)
|
|
log(f"fastboot reboot: {res.stdout.strip()} {res.stderr.strip()}")
|
|
|
|
# 3. Monitor boot stages
|
|
log("Monitoring boot stages...")
|
|
start = time.time()
|
|
usb_seen = False
|
|
en21_active = False
|
|
ssh_up = False
|
|
|
|
while time.time() - start < 180:
|
|
elapsed = int(time.time() - start)
|
|
|
|
# Check USB
|
|
usb = run_cmd("ioreg -p IOUSB -w0 | grep -i xiaomi")
|
|
if usb and not usb_seen:
|
|
log(f"[{elapsed}s] USB gadget detected on Mac: {usb}")
|
|
usb_seen = True
|
|
|
|
# Check en21
|
|
ifconfig = run_cmd("ifconfig en21 2>/dev/null")
|
|
if "status: active" in ifconfig and not en21_active:
|
|
log(f"[{elapsed}s] en21 carrier is ACTIVE!")
|
|
en21_active = True
|
|
# Configure manual IP
|
|
run_cmd('networksetup -setmanual "Xiaomi Mi 8 Lite" 172.16.42.2 255.255.255.0 172.16.42.1 2>/dev/null')
|
|
|
|
# Check connectivity
|
|
if en21_active:
|
|
# Check port 22
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
s.settimeout(0.5)
|
|
try:
|
|
s.connect((TARGET_IP, 22))
|
|
s.close()
|
|
log(f">>> [{elapsed}s] SUCCESS: SSH PORT 22 IS OPEN! <<<")
|
|
ssh_up = True
|
|
break
|
|
except Exception:
|
|
pass
|
|
|
|
# Check port 23
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
s.settimeout(0.5)
|
|
try:
|
|
s.connect((TARGET_IP, 23))
|
|
s.close()
|
|
log(f">>> [{elapsed}s] Telnet port 23 IS OPEN! <<<")
|
|
except Exception:
|
|
pass
|
|
|
|
if elapsed % 10 == 0 and elapsed > 0:
|
|
stats = run_cmd("netstat -I en21 2>/dev/null | grep Link")
|
|
arp = run_cmd("arp -an | grep 172.16.42.1")
|
|
log(f"[{elapsed}s] Stats: {stats} | ARP: {arp}")
|
|
|
|
time.sleep(1)
|
|
|
|
if not ssh_up:
|
|
log("ERROR: Timed out waiting for SSH port 22.")
|
|
return 1
|
|
|
|
time.sleep(2)
|
|
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())
|