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
137 lines
5.7 KiB
Python
Executable File
137 lines
5.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Watch for Fastboot device on USB, automatically fastboot boot the bulletproof
|
|
boot image, wait for OpenRC userspace, and execute complete cellular and mesh bringup.
|
|
"""
|
|
import os
|
|
import re
|
|
import socket
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
TARGET_IP = "172.16.42.1"
|
|
SSH_KEY = "/Users/shenlei/Work/sshKey/oracle_tokyo_ARM.key"
|
|
BOOT_IMG = "artifacts/candidate-20261110-r17-cellular/boot-bulletproof-direct.img"
|
|
|
|
def log(msg):
|
|
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
|
|
|
def reset_mac_network():
|
|
service = "Xiaomi Mi 8 Lite"
|
|
log(f"Resetting macOS '{service}' network service...")
|
|
try:
|
|
subprocess.run(["networksetup", "-setnetworkserviceenabled", service, "off"], capture_output=True, timeout=5)
|
|
time.sleep(1)
|
|
subprocess.run(["networksetup", "-setnetworkserviceenabled", service, "on"], capture_output=True, timeout=5)
|
|
time.sleep(1)
|
|
subprocess.run(["networksetup", "-setmanual", service, "172.16.42.2", "255.255.255.0", "172.16.42.1"], capture_output=True, timeout=5)
|
|
log("macOS network service reset completed.")
|
|
except Exception as e:
|
|
log(f"Warning: Failed to reset macOS network service: {e}")
|
|
|
|
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("=== Fastboot Watcher & Bulletproof Bringup Initiated ===")
|
|
log("Waiting for phone in Fastboot mode (please replug USB cable if needed)...")
|
|
|
|
fastboot_device = None
|
|
while True:
|
|
try:
|
|
res = subprocess.run(["fastboot", "devices"], capture_output=True, text=True, timeout=3)
|
|
lines = [l.strip() for l in res.stdout.splitlines() if l.strip()]
|
|
if lines:
|
|
fastboot_device = lines[0].split()[0]
|
|
log(f">>> Fastboot device DETECTED: {fastboot_device} <<<")
|
|
break
|
|
except Exception:
|
|
pass
|
|
time.sleep(1)
|
|
|
|
# 1. Boot bulletproof image
|
|
log(f"1. Booting bulletproof kernel image ({BOOT_IMG})...")
|
|
res = subprocess.run(["fastboot", "boot", BOOT_IMG], capture_output=True, text=True, timeout=30)
|
|
log(f"fastboot boot output:\n{res.stdout.strip()}\n{res.stderr.strip()}")
|
|
if res.returncode != 0:
|
|
log(f"ERROR: fastboot boot failed with code {res.returncode}")
|
|
return 1
|
|
|
|
log("Boot image sent successfully! Waiting for phone to boot into OpenRC...")
|
|
time.sleep(8)
|
|
reset_mac_network()
|
|
|
|
log("2. Waiting for SSH port 22 on 172.16.42.1...")
|
|
start = time.time()
|
|
ssh_up = False
|
|
while time.time() - start < 120:
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
s.settimeout(1.0)
|
|
try:
|
|
s.connect((TARGET_IP, 22))
|
|
s.close()
|
|
log(f"SUCCESS: Phone SSH port 22 is OPEN after {int(time.time() - start)}s!")
|
|
ssh_up = True
|
|
break
|
|
except Exception:
|
|
pass
|
|
time.sleep(1)
|
|
|
|
if not ssh_up:
|
|
log("ERROR: Timed out waiting for SSH port 22.")
|
|
return 1
|
|
|
|
time.sleep(3)
|
|
log("3. Logging into phone via SSH and checking system status...")
|
|
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.strip()}")
|
|
|
|
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.strip()}")
|
|
|
|
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.strip()}")
|
|
|
|
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.strip()}")
|
|
|
|
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.strip()}")
|
|
|
|
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.strip()}")
|
|
|
|
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.strip()}")
|
|
|
|
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.strip()}")
|
|
|
|
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.strip()}")
|
|
|
|
log("\n=== Complete Platina Bringup Successful! ===")
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|