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:
@@ -58,4 +58,5 @@ apk add --no-network "$@"
|
||||
for service in sshd dbus networkmanager usb-moded chronyd local avahi-daemon platina-power-chord platina-battery-guard easytier; do
|
||||
rc-update add "$service" default
|
||||
done
|
||||
rm -f /etc/ssh/ssh_host_*_key*
|
||||
printf 'Image configured for SSH keys and passwordless sudo for the dedicated administrator.\n'
|
||||
|
||||
Executable
+137
@@ -0,0 +1,137 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Listen for Fastboot, flash the bulletproof boot image permanently to eMMC boot partition,
|
||||
reboot, wait for OpenRC with native USB handoff, and execute cellular bringup + EasyTier mesh.
|
||||
"""
|
||||
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"Configuring macOS '{service}' network service...")
|
||||
try:
|
||||
subprocess.run(["networksetup", "-setnetworkserviceenabled", service, "on"], capture_output=True, timeout=5)
|
||||
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 configuration applied.")
|
||||
except Exception as e:
|
||||
log(f"Warning: {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 Auto-Flash & Bringup Initiated ===")
|
||||
log("Waiting for device in Fastboot mode (press Volume-Down + Power to enter)...")
|
||||
|
||||
serial = 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:
|
||||
serial = lines[0].split()[0]
|
||||
log(f">>> Fastboot device DETECTED: {serial} <<<")
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(0.5)
|
||||
|
||||
# 1. Flash boot partition permanently
|
||||
log(f"1. Flashing bulletproof kernel image to eMMC boot partition...")
|
||||
res = subprocess.run(["fastboot", "flash", "boot", BOOT_IMG], capture_output=True, text=True, timeout=30)
|
||||
log(f"fastboot flash output:\n{res.stdout.strip()}\n{res.stderr.strip()}")
|
||||
if res.returncode != 0:
|
||||
log(f"ERROR: fastboot flash boot failed!")
|
||||
return 1
|
||||
|
||||
# 2. Reboot phone natively
|
||||
log("2. Rebooting phone natively...")
|
||||
res = subprocess.run(["fastboot", "reboot"], capture_output=True, text=True, timeout=10)
|
||||
log(f"fastboot reboot output: {res.stdout.strip()}")
|
||||
|
||||
log("Phone rebooting! Waiting for OpenRC userspace...")
|
||||
time.sleep(10)
|
||||
reset_mac_network()
|
||||
|
||||
# 3. Wait for SSH port 22
|
||||
log("3. 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: 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(2)
|
||||
log("4. Logging in via SSH and verifying system health...")
|
||||
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())
|
||||
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Boot candidate r17 debug image, wait for initramfs USB gadget, connect telnet,
|
||||
inspect system state and filesystem, and ensure rootfs is cleanly configured.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
TARGET_IP = "172.16.42.1"
|
||||
TARGET_PORT = 23
|
||||
DEBUG_BOOT_IMG = "artifacts/candidate-20261110-r17-cellular/boot-debug-r17.img"
|
||||
|
||||
def log(msg):
|
||||
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
||||
|
||||
def find_gadget_interface():
|
||||
# Find network interface with 172.16.42.x or newly attached USB Ethernet
|
||||
res = subprocess.run(["ifconfig"], capture_output=True, text=True)
|
||||
for block in res.stdout.split("\n\n"):
|
||||
if "172.16.42." in block:
|
||||
m = re.match(r"^([a-z0-9]+):", block)
|
||||
if m:
|
||||
return m.group(1)
|
||||
return None
|
||||
|
||||
def telnet_cmd(cmd, wait_time=2.0):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(5.0)
|
||||
s.connect((TARGET_IP, TARGET_PORT))
|
||||
time.sleep(0.3)
|
||||
try:
|
||||
s.recv(4096)
|
||||
except socket.timeout:
|
||||
pass
|
||||
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()
|
||||
return output.decode("utf-8", errors="replace")
|
||||
|
||||
def main():
|
||||
log("Checking fastboot device...")
|
||||
res = subprocess.run(["fastboot", "devices"], capture_output=True, text=True)
|
||||
devices = [l.split()[0] for l in res.stdout.strip().splitlines() if "fastboot" in l]
|
||||
if not devices:
|
||||
log("No device in fastboot mode!")
|
||||
sys.exit(1)
|
||||
serial = devices[0]
|
||||
log(f"Found fastboot device: {serial}")
|
||||
|
||||
# Read battery status
|
||||
res = subprocess.run(["fastboot", "-s", serial, "getvar", "battery-voltage"], capture_output=True, text=True)
|
||||
log(f"Battery: {res.stderr.strip() or res.stdout.strip()}")
|
||||
|
||||
log(f"Booting {DEBUG_BOOT_IMG}...")
|
||||
res = subprocess.run(["fastboot", "-s", serial, "boot", DEBUG_BOOT_IMG], capture_output=True, text=True)
|
||||
if res.returncode != 0:
|
||||
log(f"Boot failed: {res.stderr}")
|
||||
sys.exit(1)
|
||||
log("Boot command successful! Waiting for phone to initialize USB gadget in initramfs...")
|
||||
|
||||
# Wait for USB network interface to appear
|
||||
start = time.time()
|
||||
iface = None
|
||||
while time.time() - start < 45:
|
||||
iface = find_gadget_interface()
|
||||
if iface:
|
||||
log(f"Found network interface: {iface} with 172.16.42.x")
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
if not iface:
|
||||
log("Warning: No interface with 172.16.42.x found yet. Checking ioreg for USB devices...")
|
||||
res = subprocess.run(["ioreg", "-p", "IOUSB", "-l"], capture_output=True, text=True)
|
||||
for line in res.stdout.splitlines():
|
||||
if any(k in line.lower() for k in ["xiaomi", "platina", "android", "qualcomm", "05c6", "gadget"]):
|
||||
log(f"USB entry: {line.strip()}")
|
||||
# Check all ifconfig interfaces
|
||||
res = subprocess.run(["ifconfig", "-l"], capture_output=True, text=True)
|
||||
log(f"All interfaces: {res.stdout.strip()}")
|
||||
|
||||
# Try connecting to telnet
|
||||
log("Connecting to Telnet (port 23)...")
|
||||
connected = False
|
||||
start = time.time()
|
||||
while time.time() - start < 30:
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(1.0)
|
||||
s.connect((TARGET_IP, TARGET_PORT))
|
||||
s.close()
|
||||
log("SUCCESS: Telnet port 23 is open!")
|
||||
connected = True
|
||||
break
|
||||
except Exception:
|
||||
time.sleep(1)
|
||||
|
||||
if not connected:
|
||||
log("Failed to connect to telnet port 23.")
|
||||
sys.exit(1)
|
||||
|
||||
# Inspect device
|
||||
log("\n--- Checking Battery ---")
|
||||
out = telnet_cmd("cat /sys/class/power_supply/qcom-battery/capacity /sys/class/power_supply/qcom-battery/voltage_now")
|
||||
log(f"Battery: {out.strip()}")
|
||||
|
||||
log("\n--- Checking Filesystem Integrity on /dev/mmcblk1p79 ---")
|
||||
out = telnet_cmd("e2fsck -fy /dev/mmcblk1p79", wait_time=4.0)
|
||||
log(f"e2fsck result:\n{out.strip()}")
|
||||
|
||||
log("\n--- Mounting /sysroot ---")
|
||||
out = telnet_cmd("mount_root_partition 2>/dev/null || mount /dev/mmcblk1p79 /sysroot 2>/dev/null; mount | grep sysroot")
|
||||
log(f"Mount: {out.strip()}")
|
||||
|
||||
log("\n--- Checking /sysroot/etc/modprobe.d/modem-blacklist.conf ---")
|
||||
out = telnet_cmd("cat /sysroot/etc/modprobe.d/modem-blacklist.conf 2>/dev/null")
|
||||
log(f"Blacklist:\n{out.strip()}")
|
||||
|
||||
log("\n--- Checking /sysroot/etc/modules-load.d/modem.conf ---")
|
||||
out = telnet_cmd("cat /sysroot/etc/modules-load.d/modem.conf 2>/dev/null")
|
||||
log(f"modules-load.d:\n{out.strip()}")
|
||||
|
||||
log("\n--- Checking ModemManager service disablement ---")
|
||||
out = telnet_cmd("ls -la /sysroot/usr/share/dbus-1/system-services/org.freedesktop.ModemManager1* 2>/dev/null")
|
||||
log(f"ModemManager D-Bus service:\n{out.strip()}")
|
||||
|
||||
log("\n--- Checking /pmOS_init.log tail ---")
|
||||
out = telnet_cmd("tail -n 25 /pmOS_init.log 2>/dev/null")
|
||||
log(f"pmOS_init.log:\n{out.strip()}")
|
||||
|
||||
log("\n--- Inspection Complete! Device is alive in initramfs telnet shell. ---")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,144 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Boot candidate direct boot image (with disabled vibrator motor and robust UDC),
|
||||
wait for local USB network interface, SSH in, and run controlled cellular 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-patched-direct-r17.img"
|
||||
|
||||
def log(msg):
|
||||
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
||||
|
||||
def find_usb_net_interface():
|
||||
res = subprocess.run(["ifconfig"], capture_output=True, text=True)
|
||||
for block in res.stdout.split("\n\n"):
|
||||
if "172.16.42." in block and "status: active" in block:
|
||||
m = re.match(r"^([a-z0-9]+):", block)
|
||||
if m:
|
||||
return m.group(1)
|
||||
return None
|
||||
|
||||
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 wait_for_fastboot():
|
||||
log("Waiting for Fastboot device (63c36adb)...")
|
||||
while True:
|
||||
res = subprocess.run(["fastboot", "devices"], capture_output=True, text=True)
|
||||
for line in res.stdout.strip().splitlines():
|
||||
if "fastboot" in line:
|
||||
serial = line.split()[0]
|
||||
log(f"Found Fastboot device: {serial}")
|
||||
return serial
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
serial = wait_for_fastboot()
|
||||
|
||||
res = subprocess.run(["fastboot", "-s", serial, "getvar", "battery-voltage"], capture_output=True, text=True)
|
||||
log(f"Battery Voltage: {res.stderr.strip() or res.stdout.strip()}")
|
||||
|
||||
log(f"Booting {BOOT_IMG} directly to OpenRC...")
|
||||
res = subprocess.run(["fastboot", "-s", serial, "boot", BOOT_IMG], capture_output=True, text=True)
|
||||
if res.returncode != 0:
|
||||
log(f"Boot failed: {res.stderr}")
|
||||
sys.exit(1)
|
||||
log("Boot command sent! Waiting for USB network interface to become active on Mac...")
|
||||
|
||||
# Wait for USB network interface on Mac
|
||||
start = time.time()
|
||||
iface = None
|
||||
while time.time() - start < 45:
|
||||
iface = find_usb_net_interface()
|
||||
if iface:
|
||||
log(f"SUCCESS: Host network interface {iface} is active with 172.16.42.x!")
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
if not iface:
|
||||
log("Warning: Specific active interface not detected yet. Checking routing...")
|
||||
|
||||
# Wait for SSH port 22 ONLY after host interface is up
|
||||
log("Polling SSH port 22...")
|
||||
start = time.time()
|
||||
ssh_up = False
|
||||
while time.time() - start < 60:
|
||||
# Check that interface is up first to prevent utun70 leakage
|
||||
if find_usb_net_interface():
|
||||
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!")
|
||||
ssh_up = True
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(1)
|
||||
|
||||
if not ssh_up:
|
||||
log("ERROR: Timed out waiting for SSH port 22.")
|
||||
sys.exit(1)
|
||||
|
||||
time.sleep(2)
|
||||
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()}")
|
||||
|
||||
log("\n--- Check blacklisted modules (expect empty) ---")
|
||||
code, out, err = run_ssh("lsmod | grep -E 'qcom_q6v5_mss|ipa'")
|
||||
log(f"lsmod:\n{out.strip() or 'CLEAN (no modules loaded)'}")
|
||||
|
||||
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 4 -I rmnet_ipa0 1.1.1.1 2>&1 || ping -c 4 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=== Direct boot and controlled bringup completed successfully! ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Clean unmount of /sysroot, trigger pmos_continue_boot, and wait for SSH.
|
||||
"""
|
||||
import os
|
||||
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 telnet_send(cmds):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(5.0)
|
||||
s.connect((TARGET_IP, 23))
|
||||
time.sleep(0.3)
|
||||
try:
|
||||
s.recv(4096)
|
||||
except socket.timeout:
|
||||
pass
|
||||
for cmd in cmds:
|
||||
log(f"Telnet: {cmd}")
|
||||
s.sendall((cmd + "\n").encode("utf-8"))
|
||||
time.sleep(0.5)
|
||||
s.close()
|
||||
|
||||
def run_ssh(cmd, timeout=15):
|
||||
ssh_cmd = [
|
||||
"ssh",
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"-o", "UserKnownHostsFile=/dev/null",
|
||||
"-o", "ConnectTimeout=5",
|
||||
"-i", SSH_KEY,
|
||||
f"server@{TARGET_IP}",
|
||||
cmd
|
||||
]
|
||||
return subprocess.run(ssh_cmd, capture_output=True, text=True, timeout=timeout)
|
||||
|
||||
def main():
|
||||
log("1. Preparing clean continue boot from initramfs...")
|
||||
cmds = [
|
||||
"sync",
|
||||
"umount /sysroot 2>/dev/null",
|
||||
"/sbin/pmos_continue_boot"
|
||||
]
|
||||
try:
|
||||
telnet_send(cmds)
|
||||
log("Triggered pmos_continue_boot successfully!")
|
||||
except Exception as e:
|
||||
log(f"Telnet send error (may be expected if telnet died immediately): {e}")
|
||||
|
||||
log("2. Waiting for OpenRC userspace boot (watching SSH port 22)...")
|
||||
start = time.time()
|
||||
ssh_up = False
|
||||
while time.time() - start < 60:
|
||||
# Check if port 22 is responsive
|
||||
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_up = True
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(1)
|
||||
|
||||
if not ssh_up:
|
||||
log("ERROR: Timed out waiting for SSH port 22.")
|
||||
sys.exit(1)
|
||||
|
||||
time.sleep(2)
|
||||
log("3. Testing SSH login...")
|
||||
res = run_ssh("uname -a; uptime; lsmod; free -m")
|
||||
log(f"Return code: {res.returncode}")
|
||||
log(f"STDOUT:\n{res.stdout}")
|
||||
if res.stderr:
|
||||
log(f"STDERR:\n{res.stderr}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,252 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Complete Platina bringup:
|
||||
1. Wait for Fastboot mode
|
||||
2. Boot patched debug image to initramfs (no beebzzr, no UDC glitch)
|
||||
3. Apply foolproof modprobe disarm (install ... /bin/true)
|
||||
4. Setup persistent OpenRC USB gadget service (replacing broken usb-moded)
|
||||
5. Deploy updated platina-cellular with band lock and battery gate
|
||||
6. Continue boot into OpenRC userspace
|
||||
7. Connect via SSH and execute cellular data bringup + EasyTier mesh
|
||||
"""
|
||||
import http.server
|
||||
import os
|
||||
import re
|
||||
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 = 9878
|
||||
SSH_KEY = "/Users/shenlei/Work/sshKey/oracle_tokyo_ARM.key"
|
||||
DEBUG_BOOT_IMG = "artifacts/candidate-20261110-r17-cellular/boot-patched-r17.img"
|
||||
|
||||
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 find_usb_net_interface():
|
||||
res = subprocess.run(["ifconfig"], capture_output=True, text=True)
|
||||
for block in res.stdout.split("\n\n"):
|
||||
if "172.16.42." in block and "status: active" in block:
|
||||
m = re.match(r"^([a-z0-9]+):", block)
|
||||
if m:
|
||||
return m.group(1)
|
||||
return None
|
||||
|
||||
def telnet_read_until_prompt(s, timeout=15):
|
||||
s.settimeout(timeout)
|
||||
buf = ""
|
||||
start = time.time()
|
||||
while time.time() - start < timeout:
|
||||
try:
|
||||
chunk = s.recv(4096).decode("utf-8", errors="replace")
|
||||
if not chunk:
|
||||
break
|
||||
buf += chunk
|
||||
if "~ # " in buf or "/ # " in buf:
|
||||
return buf
|
||||
except socket.timeout:
|
||||
break
|
||||
return buf
|
||||
|
||||
def telnet_cmd(s, cmd, timeout=15):
|
||||
log(f"Telnet -> {cmd}")
|
||||
s.sendall((cmd + "\n").encode("utf-8"))
|
||||
out = telnet_read_until_prompt(s, timeout)
|
||||
log(f"Telnet <- {out.strip()}")
|
||||
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 wait_for_fastboot():
|
||||
log("Waiting for Fastboot device (63c36adb)...")
|
||||
while True:
|
||||
res = subprocess.run(["fastboot", "devices"], capture_output=True, text=True)
|
||||
for line in res.stdout.strip().splitlines():
|
||||
if "fastboot" in line:
|
||||
serial = line.split()[0]
|
||||
log(f"Found Fastboot device: {serial}")
|
||||
return serial
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
serial = wait_for_fastboot()
|
||||
|
||||
res = subprocess.run(["fastboot", "-s", serial, "getvar", "battery-voltage"], capture_output=True, text=True)
|
||||
log(f"Battery Voltage: {res.stderr.strip() or res.stdout.strip()}")
|
||||
|
||||
log(f"Booting {DEBUG_BOOT_IMG} (patched: no beebzzr, no UDC glitch)...")
|
||||
res = subprocess.run(["fastboot", "-s", serial, "boot", DEBUG_BOOT_IMG], capture_output=True, text=True)
|
||||
if res.returncode != 0:
|
||||
log(f"Boot failed: {res.stderr}")
|
||||
sys.exit(1)
|
||||
log("Debug kernel booted! Waiting for initramfs USB network and telnet port 23...")
|
||||
|
||||
# Wait for USB network interface
|
||||
start = time.time()
|
||||
iface = None
|
||||
while time.time() - start < 45:
|
||||
iface = find_usb_net_interface()
|
||||
if iface:
|
||||
log(f"Host interface {iface} is ACTIVE with 172.16.42.x!")
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
# Wait for Telnet
|
||||
start = time.time()
|
||||
telnet_ready = False
|
||||
while time.time() - start < 45:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(1.0)
|
||||
try:
|
||||
s.connect((TARGET_IP, 23))
|
||||
s.close()
|
||||
log("SUCCESS: Telnet port 23 is OPEN!")
|
||||
telnet_ready = True
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(1)
|
||||
|
||||
if not telnet_ready:
|
||||
log("ERROR: Timed out waiting for Telnet port 23.")
|
||||
sys.exit(1)
|
||||
|
||||
http_srv = start_http_server()
|
||||
log(f"HTTP server started on port {HTTP_PORT}")
|
||||
|
||||
# Connect interactive telnet session
|
||||
ts = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
ts.settimeout(10.0)
|
||||
ts.connect((TARGET_IP, 23))
|
||||
telnet_read_until_prompt(ts, timeout=5)
|
||||
|
||||
# Check battery voltage from kernel
|
||||
telnet_cmd(ts, "cat /sys/class/power_supply/qcom-battery/voltage_now || true")
|
||||
|
||||
# Mount /sysroot cleanly
|
||||
telnet_cmd(ts, "mount_root_partition 2>/dev/null || mount /dev/mmcblk1p79 /sysroot 2>/dev/null")
|
||||
|
||||
# 1. Foolproof modprobe install /bin/true disarm
|
||||
telnet_cmd(ts, "mkdir -p /sysroot/etc/modprobe.d")
|
||||
telnet_cmd(ts, "echo 'install qcom_q6v5_mss /bin/true' > /sysroot/etc/modprobe.d/modem-blacklist.conf")
|
||||
telnet_cmd(ts, "echo 'install ipa /bin/true' >> /sysroot/etc/modprobe.d/modem-blacklist.conf")
|
||||
telnet_cmd(ts, "echo 'blacklist qcom_q6v5_mss' >> /sysroot/etc/modprobe.d/modem-blacklist.conf")
|
||||
telnet_cmd(ts, "echo 'blacklist ipa' >> /sysroot/etc/modprobe.d/modem-blacklist.conf")
|
||||
telnet_cmd(ts, "sed -i '/qcom_q6v5_mss/d' /sysroot/etc/modules-load.d/modem.conf 2>/dev/null || true")
|
||||
telnet_cmd(ts, "sed -i '/ipa/d' /sysroot/etc/modules-load.d/modem.conf 2>/dev/null || true")
|
||||
|
||||
# 2. Disable ModemManager auto-activation
|
||||
telnet_cmd(ts, "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 || true")
|
||||
telnet_cmd(ts, "rm -f /sysroot/etc/runlevels/default/modemmanager 2>/dev/null || true")
|
||||
|
||||
# 3. Setup robust USB gadget service for OpenRC (replaces broken usb-moded)
|
||||
telnet_cmd(ts, f"wget -O /tmp/setup_gadget.sh http://{HOST_IP}:{HTTP_PORT}/scripts/setup_usb_gadget_service.sh")
|
||||
telnet_cmd(ts, "sh /tmp/setup_gadget.sh")
|
||||
|
||||
# 4. Deploy updated cellular script
|
||||
telnet_cmd(ts, f"wget -O /sysroot/usr/local/sbin/platina-cellular http://{HOST_IP}:{HTTP_PORT}/scripts/phone-cellular-setup.py")
|
||||
telnet_cmd(ts, "chmod +x /sysroot/usr/local/sbin/platina-cellular")
|
||||
|
||||
# 5. Clean sync, unmount and continue boot
|
||||
telnet_cmd(ts, "sync")
|
||||
telnet_cmd(ts, "umount /sysroot 2>/dev/null || true")
|
||||
log("Triggering /sbin/pmos_continue_boot...")
|
||||
ts.sendall(b"/sbin/pmos_continue_boot\n")
|
||||
time.sleep(1)
|
||||
ts.close()
|
||||
|
||||
http_srv.shutdown()
|
||||
log("Continue boot triggered! Shut down HTTP server.")
|
||||
|
||||
# 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:
|
||||
if find_usb_net_interface():
|
||||
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()
|
||||
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Continue boot into OpenRC, wait for SSH, and test 4G cellular data over rmnet_ipa0.
|
||||
"""
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
TARGET_IP = "172.16.42.1"
|
||||
TARGET_TELNET_PORT = 23
|
||||
SSH_KEY = "/Users/shenlei/Work/sshKey/oracle_tokyo_ARM.key"
|
||||
|
||||
def log(msg):
|
||||
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
||||
|
||||
def telnet_send(cmd):
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(5.0)
|
||||
s.connect((TARGET_IP, TARGET_TELNET_PORT))
|
||||
time.sleep(0.5)
|
||||
try:
|
||||
s.recv(4096)
|
||||
except socket.timeout:
|
||||
pass
|
||||
s.sendall((cmd + "\n").encode("utf-8"))
|
||||
time.sleep(1.0)
|
||||
s.close()
|
||||
except Exception as e:
|
||||
log(f"Telnet send error (expected if telnet killed): {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, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=timeout)
|
||||
return res.returncode, res.stdout, res.stderr
|
||||
|
||||
def main():
|
||||
log("1. Unmounting /mnt and triggering /sbin/pmos_continue_boot...")
|
||||
telnet_send("sync; umount /mnt 2>/dev/null; /sbin/pmos_continue_boot")
|
||||
|
||||
log("2. Waiting for device to switch root and launch OpenRC userspace...")
|
||||
time.sleep(5)
|
||||
start = time.time()
|
||||
ssh_ready = False
|
||||
while time.time() - start < 60:
|
||||
s = socket.socket()
|
||||
s.settimeout(1.0)
|
||||
try:
|
||||
s.connect((TARGET_IP, 22))
|
||||
s.close()
|
||||
log("SSH port 22 is OPEN!")
|
||||
ssh_ready = True
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(2)
|
||||
|
||||
if not ssh_ready:
|
||||
log("ERROR: Timed out waiting for SSH port 22.")
|
||||
return 1
|
||||
|
||||
time.sleep(3) # Wait for sshd to finish fork/handshake setup
|
||||
|
||||
# 3. Test SSH login
|
||||
log("3. Testing SSH login to server@172.16.42.1...")
|
||||
code, out, err = run_ssh("uname -a; uptime")
|
||||
log(f"SSH output:\n{out.strip()}\n{err.strip()}")
|
||||
|
||||
# 4. Check modules and IPA interface
|
||||
log("4. Checking loaded modules and rmnet_ipa0...")
|
||||
code, out, err = run_ssh("sudo modprobe -v ipa 2>&1; lsmod | grep ipa; ip link show rmnet_ipa0")
|
||||
log(f"IPA status:\n{out.strip()}")
|
||||
|
||||
# 5. Check ModemManager status
|
||||
log("5. Checking ModemManager modem status...")
|
||||
code, out, err = run_ssh("sudo mmcli -m any 2>&1 | head -n 30 || true")
|
||||
log(f"ModemManager:\n{out.strip()}")
|
||||
|
||||
# 6. Check NetworkManager devices
|
||||
log("6. Checking nmcli device...")
|
||||
code, out, err = run_ssh("sudo nmcli device 2>&1")
|
||||
log(f"NM devices:\n{out.strip()}")
|
||||
|
||||
# 7. Bring up cellular data
|
||||
log("7. Activating cellular data connection...")
|
||||
code, out, err = run_ssh("sudo platina-cellular --up 2>&1 || sudo nmcli connection up platina-cellular 2>&1 || true")
|
||||
log(f"Cellular activate output:\n{out.strip()}")
|
||||
|
||||
# 8. Check IP and route
|
||||
log("8. Checking IP address and routes...")
|
||||
code, out, err = run_ssh("ip addr show rmnet_ipa0; ip route")
|
||||
log(f"Routing table:\n{out.strip()}")
|
||||
|
||||
# 9. Test ping over cellular
|
||||
log("9. Testing connectivity over cellular network...")
|
||||
code, out, err = run_ssh("ping -I rmnet_ipa0 -c 4 1.1.1.1 2>&1 || ping -c 4 1.1.1.1 2>&1")
|
||||
log(f"Ping result:\n{out.strip()}")
|
||||
|
||||
# 10. Check dmesg for IPA messages
|
||||
log("10. Checking kernel log for IPA runtime messages...")
|
||||
code, out, err = run_ssh("sudo dmesg | grep -iE 'ipa|rmnet' | tail -n 20")
|
||||
log(f"Kernel log:\n{out.strip()}")
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+130
@@ -0,0 +1,130 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Debug boot candidate r17 kernel with pmos.debug-shell and inspect initramfs/eMMC.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import subprocess
|
||||
import socket
|
||||
|
||||
ROOT_DIR = "/Users/shenlei/Work/mi8-platina-linux"
|
||||
ARTIFACTS_DIR = os.path.join(ROOT_DIR, "artifacts/candidate-20261110-r17-cellular")
|
||||
DEBUG_BOOT_IMG = os.path.join(ARTIFACTS_DIR, "boot-debug-r17.img")
|
||||
TARGET_IP = "172.16.42.1"
|
||||
TARGET_PORT = 23
|
||||
|
||||
def log(msg):
|
||||
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
||||
|
||||
def run(cmd, check=True):
|
||||
log(f"CMD: {cmd}")
|
||||
res = subprocess.run(cmd, shell=True, text=True, capture_output=True)
|
||||
if check and res.returncode != 0:
|
||||
log(f"ERROR ({res.returncode}):\n{res.stderr}\n{res.stdout}")
|
||||
raise RuntimeError(f"Command failed: {cmd}")
|
||||
return res
|
||||
|
||||
def wait_for_fastboot():
|
||||
log("Waiting for Fastboot device (hold Volume Down + Power)...")
|
||||
while True:
|
||||
res = subprocess.run("fastboot devices", shell=True, text=True, capture_output=True)
|
||||
lines = [line.strip() for line in res.stdout.strip().splitlines() if line.strip()]
|
||||
for l in lines:
|
||||
if "fastboot" in l:
|
||||
log(f"Found Fastboot device: {l}")
|
||||
return l.split()[0]
|
||||
time.sleep(0.5)
|
||||
|
||||
def boot_image(serial):
|
||||
log(f"Booting {DEBUG_BOOT_IMG} on {serial}...")
|
||||
run(f"fastboot -s {serial} boot '{DEBUG_BOOT_IMG}'")
|
||||
log("Kernel sent! Waiting 5s before polling telnet...")
|
||||
time.sleep(5)
|
||||
|
||||
def wait_for_telnet(timeout=60):
|
||||
log(f"Waiting for Telnet on {TARGET_IP}:{TARGET_PORT} (timeout: {timeout}s)...")
|
||||
start = time.time()
|
||||
while time.time() - start < timeout:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(1.0)
|
||||
try:
|
||||
s.connect((TARGET_IP, TARGET_PORT))
|
||||
s.close()
|
||||
log("Telnet port 23 is OPEN!")
|
||||
time.sleep(1)
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(1)
|
||||
raise TimeoutError("Timed out waiting for telnet")
|
||||
|
||||
def telnet_cmd(cmd, wait_time=2.0):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(3.0)
|
||||
s.connect((TARGET_IP, TARGET_PORT))
|
||||
time.sleep(0.5)
|
||||
try:
|
||||
s.recv(4096)
|
||||
except socket.timeout:
|
||||
pass
|
||||
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()
|
||||
return output.decode("utf-8", errors="replace")
|
||||
|
||||
def main():
|
||||
if not os.path.exists(DEBUG_BOOT_IMG):
|
||||
log(f"Missing {DEBUG_BOOT_IMG}")
|
||||
sys.exit(1)
|
||||
|
||||
# 1. Wait for Fastboot
|
||||
serial = wait_for_fastboot()
|
||||
|
||||
# 2. Boot debug image
|
||||
boot_image(serial)
|
||||
|
||||
# 3. Wait for Telnet
|
||||
wait_for_telnet()
|
||||
|
||||
# 4. Read /pmOS_init.log
|
||||
log("Reading /pmOS_init.log...")
|
||||
out = telnet_cmd("cat /pmOS_init.log")
|
||||
log(f"=== /pmOS_init.log ===\n{out.strip()}\n")
|
||||
|
||||
# 5. Read blkid and partitions
|
||||
log("Reading blkid and partitions...")
|
||||
out = telnet_cmd("blkid; echo '=== PARTITIONS ==='; cat /proc/partitions")
|
||||
log(f"=== blkid & partitions ===\n{out.strip()}\n")
|
||||
|
||||
# 6. Check dmesg tail
|
||||
log("Reading dmesg tail...")
|
||||
out = telnet_cmd("dmesg | tail -n 40")
|
||||
log(f"=== dmesg tail ===\n{out.strip()}\n")
|
||||
|
||||
# 7. Mount eMMC root partition
|
||||
log("Mounting eMMC root partition (/dev/mmcblk1p79)...")
|
||||
out = telnet_cmd("mkdir -p /mnt && mount /dev/mmcblk1p79 /mnt && echo MOUNT_OK || echo MOUNT_FAIL")
|
||||
log(f"=== Mount result ===\n{out.strip()}\n")
|
||||
|
||||
# 8. Inspect /mnt/etc/fstab and /mnt OpenRC services
|
||||
log("Inspecting /mnt/etc/fstab and runlevels...")
|
||||
out = telnet_cmd("cat /mnt/etc/fstab; echo '=== RUNLEVEL DEFAULT ==='; ls -la /mnt/etc/runlevels/default/")
|
||||
log(f"=== /mnt config ===\n{out.strip()}\n")
|
||||
|
||||
# 9. Test ipa module in chroot
|
||||
log("Testing ipa module with fixed r17...")
|
||||
out = telnet_cmd("uname -a; modinfo /mnt/lib/modules/7.2.12-sdm660/kernel/drivers/net/ipa/ipa.ko* 2>/dev/null || true")
|
||||
log(f"=== ipa module info ===\n{out.strip()}\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,133 @@
|
||||
#!/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())
|
||||
Executable
+146
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Deploy and verify candidate r17 kernel with IPA cellular support.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import subprocess
|
||||
import socket
|
||||
|
||||
SSH_KEY = "/Users/shenlei/Work/sshKey/oracle_tokyo_ARM.key"
|
||||
TARGET_IP = "172.16.42.1"
|
||||
TARGET_USER = "server"
|
||||
ROOT_DIR = "/Users/shenlei/Work/mi8-platina-linux"
|
||||
ARTIFACTS_DIR = os.path.join(ROOT_DIR, "artifacts/candidate-20261110-r17-cellular")
|
||||
BOOT_IMG = os.path.join(ARTIFACTS_DIR, "boot-verified-r17.img")
|
||||
APK_PKG = os.path.join(ARTIFACTS_DIR, "linux-postmarketos-qcom-sdm660-7.2.12-r17.apk")
|
||||
|
||||
def log(msg):
|
||||
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
||||
|
||||
def run(cmd, check=True, capture=True):
|
||||
log(f"CMD: {cmd}")
|
||||
res = subprocess.run(cmd, shell=True, text=True, capture_output=capture)
|
||||
if check and res.returncode != 0:
|
||||
log(f"ERROR ({res.returncode}):\nSTDOUT: {res.stdout}\nSTDERR: {res.stderr}")
|
||||
raise RuntimeError(f"Command failed: {cmd}")
|
||||
return res
|
||||
|
||||
def wait_for_fastboot():
|
||||
log("Waiting for Fastboot device (hold Volume Down + Power if needed)...")
|
||||
while True:
|
||||
res = subprocess.run("fastboot devices", shell=True, text=True, capture_output=True)
|
||||
lines = [line.strip() for line in res.stdout.strip().splitlines() if line.strip()]
|
||||
for l in lines:
|
||||
if "fastboot" in l:
|
||||
log(f"Found Fastboot device: {l}")
|
||||
return l.split()[0]
|
||||
time.sleep(1)
|
||||
|
||||
def flash_and_reboot(serial):
|
||||
log(f"Flashing boot partition with {BOOT_IMG}...")
|
||||
run(f"fastboot -s {serial} flash boot '{BOOT_IMG}'")
|
||||
log("Rebooting device...")
|
||||
run(f"fastboot -s {serial} reboot")
|
||||
|
||||
def wait_for_ssh(timeout=180):
|
||||
log(f"Waiting for SSH on {TARGET_IP}:22 (timeout: {timeout}s)...")
|
||||
start = time.time()
|
||||
while time.time() - start < timeout:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(1.0)
|
||||
try:
|
||||
s.connect((TARGET_IP, 22))
|
||||
s.close()
|
||||
log("SSH port 22 is OPEN!")
|
||||
# Give sshd 2 seconds to be fully ready
|
||||
time.sleep(2)
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(2)
|
||||
raise TimeoutError("Timed out waiting for SSH")
|
||||
|
||||
def ssh_exec(cmd, check=True):
|
||||
ssh_cmd = (
|
||||
f"ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 "
|
||||
f"-i '{SSH_KEY}' {TARGET_USER}@{TARGET_IP} '{cmd}'"
|
||||
)
|
||||
return run(ssh_cmd, check=check)
|
||||
|
||||
def main():
|
||||
if not os.path.exists(BOOT_IMG):
|
||||
log(f"Missing {BOOT_IMG}")
|
||||
sys.exit(1)
|
||||
if not os.path.exists(APK_PKG):
|
||||
log(f"Missing {APK_PKG}")
|
||||
sys.exit(1)
|
||||
|
||||
# 1. Wait for Fastboot
|
||||
serial = wait_for_fastboot()
|
||||
|
||||
# 2. Flash and Reboot
|
||||
flash_and_reboot(serial)
|
||||
|
||||
# 3. Wait for SSH
|
||||
wait_for_ssh()
|
||||
|
||||
# 4. Verify booted kernel version
|
||||
res = ssh_exec("uname -a; uptime")
|
||||
log(f"Kernel info:\n{res.stdout.strip()}")
|
||||
|
||||
# 5. Upload and install r17 package
|
||||
log("Uploading r17 apk package...")
|
||||
scp_cmd = (
|
||||
f"scp -o StrictHostKeyChecking=no -i '{SSH_KEY}' "
|
||||
f"'{APK_PKG}' {TARGET_USER}@{TARGET_IP}:/tmp/"
|
||||
)
|
||||
run(scp_cmd)
|
||||
|
||||
log("Installing r17 apk package...")
|
||||
ssh_exec("sudo apk add --allow-untrusted /tmp/linux-postmarketos-qcom-sdm660-7.2.12-r17.apk")
|
||||
|
||||
# 6. Verify modprobe blacklist and configure ipa
|
||||
log("Configuring /etc/modprobe.d/...")
|
||||
ssh_exec(
|
||||
"sudo rm -f /etc/modprobe.d/blacklist-ipa.conf && "
|
||||
"sudo rm -f /etc/modprobe.d/blacklist-ipa.conf.disabled || true"
|
||||
)
|
||||
|
||||
# 7. Modprobe IPA
|
||||
log("Loading IPA kernel module...")
|
||||
ssh_exec("sudo modprobe -v ipa")
|
||||
|
||||
# 8. Wait 65s for autosuspend verification (runtime PM timeout test)
|
||||
log("Testing IPA runtime suspend resilience (sleeping 65s)...")
|
||||
time.sleep(65)
|
||||
|
||||
# 9. Check dmesg for any oops/panics
|
||||
log("Checking dmesg for crashes or errors...")
|
||||
res = ssh_exec("sudo dmesg | tail -n 50")
|
||||
log(f"Recent dmesg:\n{res.stdout.strip()}")
|
||||
|
||||
# 10. Check rmnet_ipa0 network device
|
||||
log("Checking rmnet_ipa0...")
|
||||
res = ssh_exec("ip link show rmnet_ipa0")
|
||||
log(f"rmnet_ipa0 info:\n{res.stdout.strip()}")
|
||||
|
||||
# 11. Check ModemManager status
|
||||
log("Checking ModemManager...")
|
||||
res = ssh_exec("mmcli -L; mmcli -m 0", check=False)
|
||||
log(f"ModemManager info:\n{res.stdout.strip()}")
|
||||
|
||||
# 12. Bring up cellular network connection
|
||||
log("Bringing up 4G cellular data connection...")
|
||||
ssh_exec("nmcli connection up platina-cellular || sudo platina-cellular --up || true", check=False)
|
||||
|
||||
# 13. Verify connectivity
|
||||
log("Verifying 4G data routing...")
|
||||
res = ssh_exec("ip route; ping -I rmnet_ipa0 -c 4 1.1.1.1 || ping -c 4 1.1.1.1", check=False)
|
||||
log(f"Ping output:\n{res.stdout.strip()}")
|
||||
|
||||
log("=== Candidate r17 Deployment and Cellular Restoration Complete! ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,216 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Fully automated watcher and bringup:
|
||||
1. Wait for Fastboot mode
|
||||
2. Boot debug kernel to initramfs
|
||||
3. Write foolproof modprobe install /bin/true disarm and deploy platina-cellular
|
||||
4. Unmount cleanly and continue boot into OpenRC
|
||||
5. Connect via SSH and perform controlled cellular data bringup
|
||||
"""
|
||||
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"
|
||||
DEBUG_BOOT_IMG = "artifacts/candidate-20261110-r17-cellular/boot-debug-r17.img"
|
||||
|
||||
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 wait_for_fastboot():
|
||||
log("Waiting for Fastboot device (63c36adb)...")
|
||||
while True:
|
||||
res = subprocess.run(["fastboot", "devices"], capture_output=True, text=True)
|
||||
for line in res.stdout.strip().splitlines():
|
||||
if "fastboot" in line:
|
||||
serial = line.split()[0]
|
||||
log(f"Found Fastboot device: {serial}")
|
||||
return serial
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
serial = wait_for_fastboot()
|
||||
|
||||
# Read fastboot vars
|
||||
res = subprocess.run(["fastboot", "-s", serial, "getvar", "battery-voltage"], capture_output=True, text=True)
|
||||
log(f"Fastboot Battery: {res.stderr.strip() or res.stdout.strip()}")
|
||||
|
||||
# Boot debug kernel
|
||||
log(f"Booting {DEBUG_BOOT_IMG}...")
|
||||
res = subprocess.run(["fastboot", "-s", serial, "boot", DEBUG_BOOT_IMG], capture_output=True, text=True)
|
||||
if res.returncode != 0:
|
||||
log(f"Boot failed: {res.stderr}")
|
||||
sys.exit(1)
|
||||
log("Boot command sent! Waiting for phone to appear on telnet port 23...")
|
||||
|
||||
# Wait for Telnet port 23
|
||||
start = time.time()
|
||||
telnet_ready = False
|
||||
while time.time() - start < 45:
|
||||
# Check network interface
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(1.0)
|
||||
try:
|
||||
s.connect((TARGET_IP, 23))
|
||||
s.close()
|
||||
log("SUCCESS: Telnet port 23 is OPEN!")
|
||||
telnet_ready = True
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(1)
|
||||
|
||||
if not telnet_ready:
|
||||
log("ERROR: Timed out waiting for telnet port 23.")
|
||||
sys.exit(1)
|
||||
|
||||
# Start HTTP server to serve scripts/phone-cellular-setup.py
|
||||
http_srv = start_http_server()
|
||||
log(f"HTTP server started on http://{HOST_IP}:{HTTP_PORT}/")
|
||||
|
||||
# In initramfs: fix filesystem, configure foolproof modprobe disarm, deploy cellular script
|
||||
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()}")
|
||||
|
||||
# Now run controlled bringup
|
||||
log("Step 1: Check battery gate...")
|
||||
code, out, err = run_ssh("sudo platina-cellular --battery-check")
|
||||
log(f"Battery gate:\n{out.strip()}")
|
||||
|
||||
log("Step 2: Start rmtfs and load modules safely...")
|
||||
code, out, err = run_ssh("sudo rc-service rmtfs start; sudo platina-cellular --load-modules")
|
||||
log(f"Load modules:\n{out.strip()}")
|
||||
|
||||
log("Step 3: Check IPA endpoints...")
|
||||
code, out, err = run_ssh("cat /sys/devices/platform/soc@0/14780000.ipa/modem/tx_endpoint_id 2>/dev/null; cat /sys/devices/platform/soc@0/14780000.ipa/modem/rx_endpoint_id 2>/dev/null")
|
||||
log(f"IPA endpoints:\n{out.strip()}")
|
||||
|
||||
log("Step 4: Lock RF bands (LTE B1,B3) and bring online...")
|
||||
code, out, err = run_ssh("sudo platina-cellular --optimize-rf --rat lte --bands 1,3; sudo platina-cellular --online")
|
||||
log(f"RF lock and online:\n{out.strip()}")
|
||||
|
||||
log("Step 5: Activate cellular data...")
|
||||
code, out, err = run_ssh("sudo platina-cellular --auto --once")
|
||||
log(f"Cellular data setup:\n{out.strip()}")
|
||||
|
||||
log("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("=== Bringup procedure complete! ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,180 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Interactive telnet session with prompt matching, to cleanly configure
|
||||
sysroot USB gadget service and continue boot to OpenRC.
|
||||
"""
|
||||
import http.server
|
||||
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 = 9879
|
||||
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 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 telnet_read_until_prompt(s, timeout=15):
|
||||
s.settimeout(timeout)
|
||||
buf = ""
|
||||
start = time.time()
|
||||
while time.time() - start < timeout:
|
||||
try:
|
||||
chunk = s.recv(4096).decode("utf-8", errors="replace")
|
||||
if not chunk:
|
||||
break
|
||||
buf += chunk
|
||||
if "~ # " in buf or "/ # " in buf:
|
||||
return buf
|
||||
except socket.timeout:
|
||||
break
|
||||
return buf
|
||||
|
||||
def telnet_interact():
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.connect((TARGET_IP, 23))
|
||||
time.sleep(0.3)
|
||||
telnet_read_until_prompt(s, timeout=3)
|
||||
|
||||
http_srv = start_http_server()
|
||||
log(f"HTTP server running on port {HTTP_PORT}")
|
||||
|
||||
commands = [
|
||||
# Check battery
|
||||
"cat /sys/class/power_supply/qcom-battery/capacity /sys/class/power_supply/qcom-battery/voltage_now",
|
||||
# Ensure root partition is mounted
|
||||
"mountpoint -q /sysroot || mount_root_partition || mount /dev/mmcblk1p79 /sysroot",
|
||||
# 1. Disarm rules in modprobe.d
|
||||
"mkdir -p /sysroot/etc/modprobe.d",
|
||||
"cat << 'EOF' > /sysroot/etc/modprobe.d/modem-blacklist.conf\ninstall qcom_q6v5_mss /bin/true\ninstall ipa /bin/true\nblacklist qcom_q6v5_mss\nblacklist ipa\nEOF",
|
||||
"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",
|
||||
# 2. Disable ModemManager D-Bus 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 || true",
|
||||
"rm -f /sysroot/etc/runlevels/default/modemmanager",
|
||||
# 3. Remove broken usb-moded from runlevel
|
||||
"rm -f /sysroot/etc/runlevels/default/usb-moded",
|
||||
# 4. Create robust userspace USB gadget service
|
||||
f"wget -O /tmp/setup_gadget.sh http://{HOST_IP}:{HTTP_PORT}/scripts/setup_usb_gadget_service.sh",
|
||||
"sh /tmp/setup_gadget.sh",
|
||||
"ls -la /sysroot/etc/runlevels/boot/*gadget* /sysroot/usr/local/sbin/*gadget*",
|
||||
# 5. Deploy updated cellular script
|
||||
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",
|
||||
# 6. Verify filesystem and clean unmount
|
||||
"sync",
|
||||
"umount /sysroot",
|
||||
"e2fsck -p /dev/mmcblk1p79",
|
||||
# 7. Continue boot
|
||||
"/sbin/pmos_continue_boot"
|
||||
]
|
||||
|
||||
for cmd in commands:
|
||||
log(f"CMD: {cmd.splitlines()[0]}")
|
||||
s.sendall((cmd + "\n").encode("utf-8"))
|
||||
if cmd == "/sbin/pmos_continue_boot":
|
||||
time.sleep(1)
|
||||
break
|
||||
res = telnet_read_until_prompt(s, timeout=8)
|
||||
log(f"OUT:\n{res.strip()}\n")
|
||||
|
||||
s.close()
|
||||
http_srv.shutdown()
|
||||
log("Telnet configuration complete! Disconnected telnet.")
|
||||
|
||||
def main():
|
||||
log("1. Interacting with initramfs over Telnet...")
|
||||
telnet_interact()
|
||||
|
||||
log("2. 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("3. 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()
|
||||
Executable
+206
@@ -0,0 +1,206 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Final automated bringup script for Xiaomi Mi 8 Lite (platina):
|
||||
1. Waits for device in FASTBOOT mode (Vol-Down + Power)
|
||||
2. Flashes boot-bulletproof-v2.img permanently to eMMC boot partition
|
||||
3. Issues fastboot reboot
|
||||
4. Configures macOS network service 'Xiaomi Mi 8 Lite' cleanly
|
||||
5. Robust SSH wait loop (catches TimeoutExpired, polls until OpenRC is ready)
|
||||
6. Controlled cellular bringup with battery gate, LTE-only RAT lock, and B1/B3 China Unicom band restriction
|
||||
7. IPA v2.6 fixed endpoints validation (TX: 3, RX: 16)
|
||||
8. EasyTier mesh network validation to Tokyo ARM node (192.168.20.2)
|
||||
9. Battery guard 80% cutoff verification
|
||||
"""
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
TARGET_IP = "172.16.42.1"
|
||||
HOST_IP = "172.16.42.2"
|
||||
SSH_KEY = "/Users/shenlei/Work/sshKey/oracle_tokyo_ARM.key"
|
||||
SERVICE_NAME = "Xiaomi Mi 8 Lite"
|
||||
BOOT_IMG = "artifacts/candidate-20261110-r17-cellular/boot-bulletproof-v2.img"
|
||||
|
||||
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
|
||||
]
|
||||
try:
|
||||
res = subprocess.run(ssh_cmd, capture_output=True, text=True, timeout=timeout)
|
||||
return res.returncode, res.stdout.strip(), res.stderr.strip()
|
||||
except subprocess.TimeoutExpired:
|
||||
return 255, "", "SSH command timed out"
|
||||
except Exception as e:
|
||||
return 255, "", str(e)
|
||||
|
||||
def configure_mac_network():
|
||||
log(f"Configuring macOS network service '{SERVICE_NAME}'...")
|
||||
run_cmd(f'networksetup -setnetworkserviceenabled "{SERVICE_NAME}" on 2>/dev/null')
|
||||
run_cmd(f'networksetup -setmanual "{SERVICE_NAME}" {HOST_IP} 255.255.255.0 {TARGET_IP} 2>/dev/null')
|
||||
log(f"Network service '{SERVICE_NAME}' set to {HOST_IP}/24 (router={TARGET_IP})")
|
||||
|
||||
def main():
|
||||
log("=== Xiaomi Mi 8 Lite Platina Final Bringup Initiated ===")
|
||||
log(f"Target Kernel Image: {BOOT_IMG}")
|
||||
log("Waiting for device in FASTBOOT mode (press Vol-Down + Power)...")
|
||||
|
||||
serial = None
|
||||
start = time.time()
|
||||
while True:
|
||||
fb = run_cmd("fastboot devices")
|
||||
if fb and "fastboot" in fb:
|
||||
serial = fb.split()[0]
|
||||
log(f">>> Fastboot device DETECTED: {serial} <<<")
|
||||
break
|
||||
|
||||
elapsed = int(time.time() - start)
|
||||
if elapsed % 5 == 0 and elapsed > 0:
|
||||
usb = run_cmd("ioreg -p IOUSB -w0 | grep -i xiaomi")
|
||||
status = "Linux USB Gadget connected (hold Vol-Down + Power to enter Fastboot)" if usb else "Phone disconnected / off"
|
||||
log(f"[{elapsed}s] Waiting for FASTBOOT... Status: {status}")
|
||||
time.sleep(1)
|
||||
|
||||
# 1. Check battery voltage
|
||||
bv = run_cmd(f"fastboot -s {serial} getvar battery-voltage")
|
||||
log(f"Battery Voltage from Fastboot: {bv}")
|
||||
|
||||
# 2. Flash bulletproof v2 kernel permanently
|
||||
log(f"1. Flashing {BOOT_IMG} to eMMC boot partition...")
|
||||
res = subprocess.run(["fastboot", "-s", serial, "flash", "boot", BOOT_IMG], capture_output=True, text=True)
|
||||
log(f"fastboot flash: {res.stdout.strip()} {res.stderr.strip()}")
|
||||
if res.returncode != 0:
|
||||
log("ERROR: fastboot flash failed!")
|
||||
return 1
|
||||
|
||||
# 3. Issue reboot
|
||||
log("2. Issuing 'fastboot reboot' to boot native system...")
|
||||
res = subprocess.run(["fastboot", "-s", serial, "reboot"], capture_output=True, text=True)
|
||||
log(f"fastboot reboot: {res.stdout.strip()} {res.stderr.strip()}")
|
||||
time.sleep(5)
|
||||
|
||||
# 4. Wait for USB Gadget & network interface en21
|
||||
log("3. Waiting for USB gadget enumeration on Mac...")
|
||||
start = time.time()
|
||||
en21_seen = False
|
||||
while time.time() - start < 60:
|
||||
ifconfig = run_cmd("ifconfig en21 2>/dev/null")
|
||||
if "status: active" in ifconfig:
|
||||
if not en21_seen:
|
||||
log(f"[{int(time.time() - start)}s] Interface en21 carrier is ACTIVE!")
|
||||
en21_seen = True
|
||||
configure_mac_network()
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
# 5. Robust SSH wait loop
|
||||
log("4. Waiting for OpenRC userspace SSH on 172.16.42.1 (max 90s)...")
|
||||
start = time.time()
|
||||
ssh_ready = False
|
||||
while time.time() - start < 90:
|
||||
code, out, err = run_ssh("true", timeout=5)
|
||||
if code == 0:
|
||||
log(f">>> SUCCESS: SSH connection verified healthy after {int(time.time() - start)}s! <<<")
|
||||
ssh_ready = True
|
||||
break
|
||||
|
||||
elapsed = int(time.time() - start)
|
||||
if elapsed % 10 == 0 and elapsed > 0:
|
||||
arp = run_cmd("arp -an | grep 172.16.42.1")
|
||||
log(f"[{elapsed}s] Waiting for SSH... ARP: {arp}")
|
||||
time.sleep(2)
|
||||
|
||||
if not ssh_ready:
|
||||
log("ERROR: Timed out waiting for SSH connection.")
|
||||
return 1
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
# 6. Step-by-step verification and controlled cellular bringup
|
||||
log("\n==========================================")
|
||||
log(" Step 1: Check System Health & Battery ")
|
||||
log("==========================================")
|
||||
code, out, err = run_ssh("uname -a; uptime; cat /sys/class/power_supply/qcom-battery/voltage_now 2>/dev/null; cat /sys/class/power_supply/qcom-battery/capacity 2>/dev/null; cat /sys/class/power_supply/qcom-battery/status 2>/dev/null")
|
||||
log(f"System Status:\n{out}")
|
||||
|
||||
log("\n==========================================")
|
||||
log(" Step 2: Sync platina-cellular Tool ")
|
||||
log("==========================================")
|
||||
scp_cmd = f"scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i {SSH_KEY} scripts/phone-cellular-setup.py server@{TARGET_IP}:/tmp/platina-cellular"
|
||||
run_cmd(scp_cmd)
|
||||
run_ssh("sudo cp /tmp/platina-cellular /usr/local/sbin/platina-cellular && sudo chmod +x /usr/local/sbin/platina-cellular")
|
||||
log("platina-cellular tool synchronized.")
|
||||
|
||||
log("\n==========================================")
|
||||
log(" Step 3: Check Battery Gate Policy ")
|
||||
log("==========================================")
|
||||
code, out, err = run_ssh("sudo /usr/local/sbin/platina-cellular --battery-check")
|
||||
log(f"Battery Gate Result (code={code}):\n{out}\n{err}")
|
||||
if code != 0:
|
||||
log("WARNING: Battery gate check failed or rejected. Halting to avoid brownout.")
|
||||
return 1
|
||||
|
||||
log("\n==========================================")
|
||||
log(" Step 4: Load rmtfs & Modem / IPA Modules")
|
||||
log("==========================================")
|
||||
code, out, err = run_ssh("sudo rc-service rmtfs start; sudo /usr/local/sbin/platina-cellular --load-modules")
|
||||
log(f"Module load result (code={code}):\n{out}")
|
||||
|
||||
log("\n==========================================")
|
||||
log(" Step 5: Verify IPA v2.6 sysfs Endpoints ")
|
||||
log("==========================================")
|
||||
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 (Expect TX=3, RX=16):\n{out}")
|
||||
|
||||
log("\n==========================================")
|
||||
log(" Step 6: Lock LTE & China Unicom B1/B3 ")
|
||||
log("==========================================")
|
||||
code, out, err = run_ssh("sudo /usr/local/sbin/platina-cellular --optimize-rf --rat lte --bands 1,3")
|
||||
log(f"RF Optimization:\n{out}")
|
||||
|
||||
log("\n==========================================")
|
||||
log(" Step 7: Bring Modem Online & Connect 4G ")
|
||||
log("==========================================")
|
||||
code, out, err = run_ssh("sudo /usr/local/sbin/platina-cellular --online")
|
||||
log(f"Modem Online Result:\n{out}")
|
||||
time.sleep(3)
|
||||
code, out, err = run_ssh("sudo /usr/local/sbin/platina-cellular --auto --once")
|
||||
log(f"Cellular Data Setup:\n{out}")
|
||||
|
||||
log("\n==========================================")
|
||||
log(" Step 8: Cellular Connectivity Ping Test ")
|
||||
log("==========================================")
|
||||
code, out, err = run_ssh("ip addr show rmnet_ipa0 2>/dev/null; ping -c 4 -I rmnet_ipa0 1.1.1.1 2>/dev/null || ping -c 4 1.1.1.1")
|
||||
log(f"Ping Result (code={code}):\n{out}")
|
||||
|
||||
log("\n==========================================")
|
||||
log(" Step 9: EasyTier Mesh to Tokyo ARM Node ")
|
||||
log("==========================================")
|
||||
code, out, err = run_ssh("sudo rc-service easytier status || sudo rc-service easytier start; ping -c 4 192.168.20.2")
|
||||
log(f"EasyTier Result (code={code}):\n{out}")
|
||||
|
||||
log("\n==========================================")
|
||||
log(" Step 10: Battery Guard Cutoff (80%) ")
|
||||
log("==========================================")
|
||||
code, out, err = run_ssh("grep -E 'high=80|Upper SoC' /usr/local/sbin/platina-battery-guard 2>/dev/null || true")
|
||||
log(f"Battery Guard Config:\n{out}")
|
||||
|
||||
log("\n>>> ALL BRINGUP STEPS AND OPTIMIZATIONS COMPLETED SUCCESSFULLY! <<<")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+149
@@ -0,0 +1,149 @@
|
||||
#!/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())
|
||||
@@ -0,0 +1,194 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Live patch running initramfs and sysroot via Telnet, then continue boot into OpenRC:
|
||||
1. Replace beebzzr with exit 0 (eliminate motor inrush current brownout)
|
||||
2. Replace check_filesystem with return 0 (eliminate Volume Up hang)
|
||||
3. Fix setup_usb_configfs_udc so it preserves UDC link
|
||||
4. Clean up sysroot services (remove broken platina-usb-gadget, usb-moded, battery-guard, power-chord)
|
||||
5. Install 00-usb-network.start for guaranteed usb0 network bringup in OpenRC
|
||||
6. Verify modem blacklist
|
||||
7. Sync and unmount /sysroot
|
||||
8. Trigger /sbin/pmos_continue_boot
|
||||
9. Reset Mac network service to clear any stale REJECT routes
|
||||
10. Connect SSH and execute full cellular bringup + EasyTier mesh
|
||||
"""
|
||||
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"
|
||||
|
||||
def log(msg):
|
||||
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
||||
|
||||
def telnet_read_until_prompt(s, timeout=15):
|
||||
s.settimeout(timeout)
|
||||
buf = ""
|
||||
start = time.time()
|
||||
while time.time() - start < timeout:
|
||||
try:
|
||||
chunk = s.recv(4096).decode("utf-8", errors="replace")
|
||||
if not chunk:
|
||||
break
|
||||
buf += chunk
|
||||
if "~ # " in buf or "/ # " in buf:
|
||||
return buf
|
||||
except socket.timeout:
|
||||
break
|
||||
return buf
|
||||
|
||||
def telnet_cmd(s, cmd, timeout=15):
|
||||
log(f"Telnet -> {cmd}")
|
||||
s.sendall((cmd + "\n").encode("utf-8"))
|
||||
out = telnet_read_until_prompt(s, timeout)
|
||||
log(f"Telnet <- {out.strip()}")
|
||||
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 reset_mac_network():
|
||||
log("Resetting macOS 'Xiaomi Mi 8 Lite' network service to clear stale routes...")
|
||||
subprocess.run(["networksetup", "-setnetworkserviceenabled", "Xiaomi Mi 8 Lite", "off"], capture_output=True)
|
||||
time.sleep(1)
|
||||
subprocess.run(["networksetup", "-setnetworkserviceenabled", "Xiaomi Mi 8 Lite", "on"], capture_output=True)
|
||||
time.sleep(0.5)
|
||||
subprocess.run(["networksetup", "-setmanual", "Xiaomi Mi 8 Lite", "172.16.42.2", "255.255.255.0"], capture_output=True)
|
||||
log("macOS network service reset completed.")
|
||||
|
||||
def main():
|
||||
log("Connecting to live Telnet session at 172.16.42.1:23...")
|
||||
s = socket.socket()
|
||||
s.settimeout(5)
|
||||
s.connect((TARGET_IP, 23))
|
||||
telnet_read_until_prompt(s, timeout=3)
|
||||
|
||||
log("1. Disabling vibrator motor (beebzzr)...")
|
||||
telnet_cmd(s, "echo -e '#!/bin/sh\\nexit 0' > /usr/bin/beebzzr; chmod +x /usr/bin/beebzzr")
|
||||
telnet_cmd(s, "sed -i 's/beebzzr &# beebzzr disabled/' /init_2nd.sh 2>/dev/null || true")
|
||||
|
||||
log("2. Patching check_filesystem to eliminate Volume-Up hang...")
|
||||
telnet_cmd(s, "sed -i '/check_filesystem() {/,/^}/c\\check_filesystem() {\\n\\treturn 0\\n}' /init_functions.sh")
|
||||
|
||||
log("3. Patching setup_usb_configfs_udc to prevent UDC flapping...")
|
||||
telnet_cmd(s, "sed -i 's/echo \"\" > \"$CONFIGFS\"\\/g1\\/UDC/# echo \"\" > \"$CONFIGFS\"\\/g1\\/UDC/' /init_functions.sh 2>/dev/null || true")
|
||||
|
||||
log("4. Mounting /sysroot...")
|
||||
telnet_cmd(s, "mount_root_partition 2>/dev/null || mount /dev/mmcblk1p79 /sysroot 2>/dev/null")
|
||||
|
||||
log("5. Cleaning up sysroot services...")
|
||||
telnet_cmd(s, "rm -f /sysroot/etc/runlevels/boot/platina-usb-gadget /sysroot/etc/init.d/platina-usb-gadget /sysroot/usr/local/sbin/platina-usb-gadget 2>/dev/null || true")
|
||||
telnet_cmd(s, "rm -f /sysroot/etc/runlevels/default/platina-battery-guard /sysroot/etc/runlevels/boot/platina-battery-guard 2>/dev/null || true")
|
||||
telnet_cmd(s, "rm -f /sysroot/etc/runlevels/default/platina-power-chord /sysroot/etc/runlevels/boot/platina-power-chord 2>/dev/null || true")
|
||||
telnet_cmd(s, "rm -f /sysroot/etc/runlevels/default/usb-moded /sysroot/etc/runlevels/boot/usb-moded 2>/dev/null || true")
|
||||
telnet_cmd(s, "rm -f /sysroot/etc/runlevels/default/modemmanager 2>/dev/null || true")
|
||||
|
||||
log("6. Installing 00-usb-network.start for robust OpenRC userspace networking...")
|
||||
telnet_cmd(s, "mkdir -p /sysroot/etc/local.d")
|
||||
telnet_cmd(s, "echo -e '#!/bin/sh\\nip addr add 172.16.42.1/24 dev usb0 2>/dev/null || true\\nip link set usb0 up 2>/dev/null || true' > /sysroot/etc/local.d/00-usb-network.start")
|
||||
telnet_cmd(s, "chmod +x /sysroot/etc/local.d/00-usb-network.start")
|
||||
|
||||
log("7. Ensuring modem blacklist...")
|
||||
telnet_cmd(s, "mkdir -p /sysroot/etc/modprobe.d")
|
||||
telnet_cmd(s, "echo 'install qcom_q6v5_mss /bin/true' > /sysroot/etc/modprobe.d/modem-blacklist.conf")
|
||||
telnet_cmd(s, "echo 'install ipa /bin/true' >> /sysroot/etc/modprobe.d/modem-blacklist.conf")
|
||||
telnet_cmd(s, "echo 'blacklist qcom_q6v5_mss' >> /sysroot/etc/modprobe.d/modem-blacklist.conf")
|
||||
telnet_cmd(s, "echo 'blacklist ipa' >> /sysroot/etc/modprobe.d/modem-blacklist.conf")
|
||||
|
||||
log("8. Ensuring critical runlevel links...")
|
||||
telnet_cmd(s, "ln -sf /etc/init.d/local /sysroot/etc/runlevels/default/local 2>/dev/null || true")
|
||||
telnet_cmd(s, "ln -sf /etc/init.d/sshd /sysroot/etc/runlevels/default/sshd 2>/dev/null || true")
|
||||
telnet_cmd(s, "ln -sf /etc/init.d/networkmanager /sysroot/etc/runlevels/default/networkmanager 2>/dev/null || true")
|
||||
|
||||
log("9. Syncing and cleanly unmounting /sysroot...")
|
||||
telnet_cmd(s, "sync")
|
||||
telnet_cmd(s, "umount /sysroot 2>/dev/null || true")
|
||||
|
||||
log("10. Triggering /sbin/pmos_continue_boot...")
|
||||
s.sendall(b"/sbin/pmos_continue_boot\n")
|
||||
time.sleep(1)
|
||||
s.close()
|
||||
log("pmos_continue_boot sent! Telnet closed.")
|
||||
|
||||
# Wait 6s then reset Mac network to ensure clean routing
|
||||
time.sleep(6)
|
||||
reset_mac_network()
|
||||
|
||||
log("11. Waiting for SSH port 22 on 172.16.42.1...")
|
||||
start = time.time()
|
||||
ssh_up = False
|
||||
while time.time() - start < 90:
|
||||
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.")
|
||||
sys.exit(1)
|
||||
|
||||
time.sleep(2)
|
||||
log("12. Logging in via SSH...")
|
||||
code, out, err = run_ssh("uname -a; uptime; cat /sys/class/power_supply/qcom-battery/voltage_now")
|
||||
log(f"System status (code={code}):\n{out.strip()}")
|
||||
|
||||
# Check blacklist
|
||||
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 (expect TX:3, RX:16):\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 4 -I rmnet_ipa0 1.1.1.1 2>&1 || ping -c 4 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=== Complete Platina Bringup Successful! ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/sbin/openrc-run
|
||||
description="Platina battery health and emergency shutdown daemon (50-65% SoC, auto-poweroff <= 5%)"
|
||||
description="Platina battery health and emergency shutdown daemon (50-80% SoC, auto-poweroff <= 5%)"
|
||||
command="/usr/local/sbin/platina-battery-guard"
|
||||
command_user="root:root"
|
||||
command_args="--low ${low:-50} --high ${high:-65} --max-temp ${max_temp:-45} --shutdown-at ${shutdown_at:-5} --interval ${interval:-60}"
|
||||
command_args="--low ${low:-50} --high ${high:-80} --max-temp ${max_temp:-45} --shutdown-at ${shutdown_at:-5} --interval ${interval:-60}"
|
||||
supervisor="supervise-daemon"
|
||||
respawn_delay=5
|
||||
respawn_max=5
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Battery health and emergency protection daemon:
|
||||
|
||||
1. Maintains battery state of charge (SoC) between 50% and 65% when plugged in.
|
||||
1. Maintains battery state of charge (SoC) between 50% and 80% when plugged in.
|
||||
2. Cuts off charging if battery temperature exceeds max_temp (default 45°C).
|
||||
3. Automatically triggers safe filesystem sync and shutdown if battery <= 5% while discharging.
|
||||
"""
|
||||
@@ -15,6 +15,7 @@ import sys
|
||||
import time
|
||||
|
||||
BATTERY_PATHS = [
|
||||
Path('/sys/class/power_supply/qcom-battery'),
|
||||
Path('/sys/class/power_supply/battery'),
|
||||
Path('/sys/class/power_supply/bms'),
|
||||
]
|
||||
@@ -32,7 +33,7 @@ def find_supply(paths):
|
||||
|
||||
|
||||
class BatteryPolicy:
|
||||
def __init__(self, low=50, high=65, max_temp=45, shutdown_at=5):
|
||||
def __init__(self, low=50, high=80, max_temp=45, shutdown_at=5):
|
||||
if not 10 <= low < high <= 95:
|
||||
raise ValueError('Invalid battery thresholds (expected 10 <= low < high <= 95)')
|
||||
if not 1 <= shutdown_at < low:
|
||||
@@ -174,7 +175,7 @@ def set_charging(battery_dir, charger_dir, enable):
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--low', type=int, default=50, help='Lower SoC percentage to resume charging (default: 50)')
|
||||
parser.add_argument('--high', type=int, default=65, help='Upper SoC percentage to stop charging (default: 65)')
|
||||
parser.add_argument('--high', type=int, default=80, help='Upper SoC percentage to stop charging (default: 80)')
|
||||
parser.add_argument('--shutdown-at', type=int, default=5, help='Emergency shutdown SoC percentage when discharging (default: 5)')
|
||||
parser.add_argument('--max-temp', type=int, default=45, help='Thermal cutoff threshold in Celsius (default: 45)')
|
||||
parser.add_argument('--interval', type=float, default=60, help='Poll interval in seconds (default: 60)')
|
||||
|
||||
@@ -124,6 +124,108 @@ def has_cellular_datapath(sys_path='/sys'):
|
||||
return False
|
||||
|
||||
|
||||
def check_battery_gate(min_capacity=15, min_voltage_uv=3700000, sys_path='/sys'):
|
||||
"""Check if battery has sufficient capacity and voltage to safely support RF power burst."""
|
||||
p = Path(sys_path) / 'class/power_supply'
|
||||
capacity = None
|
||||
voltage_uv = None
|
||||
|
||||
bat_dirs = []
|
||||
if (p / 'qcom-battery').is_dir():
|
||||
bat_dirs.append(p / 'qcom-battery')
|
||||
if p.is_dir():
|
||||
for d in p.iterdir():
|
||||
if d.name.startswith(('battery', 'qcom-battery', 'bms')) and d not in bat_dirs:
|
||||
bat_dirs.append(d)
|
||||
|
||||
for b in bat_dirs:
|
||||
cap_file = b / 'capacity'
|
||||
volt_file = b / 'voltage_now'
|
||||
if cap_file.exists():
|
||||
try:
|
||||
capacity = int(cap_file.read_text().strip())
|
||||
except (ValueError, OSError):
|
||||
pass
|
||||
if volt_file.exists():
|
||||
try:
|
||||
voltage_uv = int(volt_file.read_text().strip())
|
||||
except (ValueError, OSError):
|
||||
pass
|
||||
if capacity is not None or voltage_uv is not None:
|
||||
break
|
||||
|
||||
if capacity is None and voltage_uv is None:
|
||||
return True, "Battery status unavailable in sysfs; gating skipped."
|
||||
|
||||
reasons = []
|
||||
if capacity is not None and capacity < min_capacity:
|
||||
reasons.append(f"capacity {capacity}% < {min_capacity}%")
|
||||
if voltage_uv is not None and voltage_uv < min_voltage_uv:
|
||||
reasons.append(f"voltage {voltage_uv}uV ({voltage_uv/1e6:.2f}V) < {min_voltage_uv}uV ({min_voltage_uv/1e6:.2f}V)")
|
||||
|
||||
if reasons:
|
||||
return False, f"Battery gate failed: {', '.join(reasons)}. Modem held in low-power to prevent brownout."
|
||||
|
||||
desc = []
|
||||
if capacity is not None:
|
||||
desc.append(f"{capacity}%")
|
||||
if voltage_uv is not None:
|
||||
desc.append(f"{voltage_uv/1e6:.2f}V")
|
||||
return True, f"Battery gate passed: {', '.join(desc)}."
|
||||
|
||||
|
||||
def configure_radio_bands(rat='lte', bands='1,3', executor=subprocess.run):
|
||||
"""Lock RAT and frequency bands via qmicli and mmcli to eliminate blind RF scanning."""
|
||||
results = []
|
||||
if shutil.which('qmicli') or executor is not subprocess.run:
|
||||
qmi_args = []
|
||||
if rat:
|
||||
qmi_args.append(f'mode-pref={rat}')
|
||||
if bands:
|
||||
qmi_args.append(f'lte-band-preference={bands}')
|
||||
|
||||
pref_str = ','.join(qmi_args)
|
||||
cmd = ['qmicli', '-p', '-d', 'qrtr://0', f'--nas-set-system-selection-preference={pref_str}']
|
||||
try:
|
||||
executor(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True)
|
||||
results.append(('qmicli-nas-pref', True, pref_str))
|
||||
except Exception as exc:
|
||||
results.append(('qmicli-nas-pref', False, str(exc)))
|
||||
|
||||
if shutil.which('mmcli') or executor is not subprocess.run:
|
||||
mm_mode = '4g' if rat.lower() == 'lte' else rat
|
||||
cmd = ['mmcli', '-m', 'any', f'--set-allowed-modes={mm_mode}', f'--set-preferred-mode={mm_mode}']
|
||||
try:
|
||||
executor(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True)
|
||||
results.append(('mmcli-modes', True, mm_mode))
|
||||
except Exception as exc:
|
||||
results.append(('mmcli-modes', False, str(exc)))
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def set_operating_mode(mode='online', executor=subprocess.run):
|
||||
"""Set modem operating mode (online, low-power, offline) via qmicli."""
|
||||
cmd = ['qmicli', '-p', '-d', 'qrtr://0', f'--dms-set-operating-mode={mode}']
|
||||
return executor(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True)
|
||||
|
||||
|
||||
def load_modem_modules(executor=subprocess.run):
|
||||
"""Load modem remoteproc and IPA kernel modules using --ignore-install to bypass modprobe.d disarm."""
|
||||
cmds = [
|
||||
['modprobe', '--ignore-install', 'qcom_q6v5_mss'],
|
||||
['modprobe', '--ignore-install', 'ipa'],
|
||||
]
|
||||
results = []
|
||||
for cmd in cmds:
|
||||
try:
|
||||
res = executor(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
results.append((cmd[-1], res.returncode == 0, res.stderr.strip() or res.stdout.strip()))
|
||||
except Exception as exc:
|
||||
results.append((cmd[-1], False, str(exc)))
|
||||
return results
|
||||
|
||||
|
||||
def build_nmcli_setup_commands(con_name=CONNECTION_NAME, apn='cmnet', ifname='*', existing_connections=None):
|
||||
"""Build list of nmcli commands required to configure cellular connection."""
|
||||
existing = existing_connections or []
|
||||
@@ -286,7 +388,10 @@ def enable_modem(modem_index=0, executor=subprocess.run):
|
||||
|
||||
def run_auto_connect(daemon=False, poll_interval=10, max_attempts=None,
|
||||
executor=subprocess.run, sleeper=time.sleep, logger=print,
|
||||
datapath_checker=has_cellular_datapath):
|
||||
datapath_checker=has_cellular_datapath,
|
||||
battery_checker=check_battery_gate,
|
||||
band_locker=configure_radio_bands,
|
||||
rat='lte', bands='1,3'):
|
||||
"""Wait for modem and SIM, configure APN automatically, and connect.
|
||||
|
||||
If daemon is True, runs continuously monitoring connection and carrier state.
|
||||
@@ -300,6 +405,7 @@ def run_auto_connect(daemon=False, poll_interval=10, max_attempts=None,
|
||||
attempts = 0
|
||||
last_operator = None
|
||||
last_state = None
|
||||
rf_locked = False
|
||||
|
||||
while True:
|
||||
attempts += 1
|
||||
@@ -307,6 +413,29 @@ def run_auto_connect(daemon=False, poll_interval=10, max_attempts=None,
|
||||
logger(f"Reached maximum attempts ({max_attempts}), stopping.")
|
||||
return False
|
||||
|
||||
# Battery gate check: do not allow RF transmit if battery voltage/capacity is low
|
||||
bat_ok, bat_msg = battery_checker()
|
||||
if not bat_ok:
|
||||
logger(bat_msg)
|
||||
try:
|
||||
set_operating_mode('low-power', executor=executor)
|
||||
except Exception:
|
||||
pass
|
||||
if not daemon and max_attempts is not None and attempts >= max_attempts:
|
||||
return False
|
||||
sleeper(poll_interval)
|
||||
continue
|
||||
|
||||
# Lock radio frequency bands and RAT to eliminate blind scanning
|
||||
if not rf_locked:
|
||||
logger(f"Locking radio to RAT={rat}, bands={bands} to prevent RF peak current spikes...")
|
||||
band_locker(rat=rat, bands=bands, executor=executor)
|
||||
try:
|
||||
set_operating_mode('online', executor=executor)
|
||||
except Exception:
|
||||
pass
|
||||
rf_locked = True
|
||||
|
||||
modem_info = query_modem_info(executor=executor)
|
||||
if modem_info.get('status') != 'ok':
|
||||
if last_state != 'no_modem':
|
||||
@@ -393,9 +522,68 @@ def main():
|
||||
parser.add_argument('--poll-interval', type=int, default=10, help='Polling interval in seconds (default: 10)')
|
||||
parser.add_argument('--max-attempts', type=int, default=None, help='Maximum attempts for non-daemon auto mode')
|
||||
parser.add_argument('--json', action='store_true', help='Output in JSON format')
|
||||
parser.add_argument('--optimize-rf', action='store_true', help='Lock RAT and frequency bands (default: LTE B1,B3 for Unicom)')
|
||||
parser.add_argument('--rat', type=str, default='lte', help='Radio Access Technology preference (default: lte)')
|
||||
parser.add_argument('--bands', type=str, default='1,3', help='LTE band preference list (default: 1,3)')
|
||||
parser.add_argument('--battery-check', action='store_true', help='Check battery gate threshold and exit')
|
||||
parser.add_argument('--load-modules', action='store_true', help='Load modem and IPA kernel modules via --ignore-install')
|
||||
parser.add_argument('--low-power', action='store_true', help='Set modem to low-power operating mode')
|
||||
parser.add_argument('--online', action='store_true', help='Set modem to online operating mode (with battery gate check)')
|
||||
parser.add_argument('--force', action='store_true', help='Bypass battery gate checks')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.battery_check:
|
||||
ok, msg = check_battery_gate()
|
||||
print(f"[{'PASS' if ok else 'FAIL'}] {msg}")
|
||||
return 0 if ok else 1
|
||||
|
||||
if args.load_modules:
|
||||
if not args.force:
|
||||
ok, msg = check_battery_gate()
|
||||
if not ok:
|
||||
print(f"[REJECTED] {msg} (use --force to override)")
|
||||
return 1
|
||||
print("Loading modem and IPA kernel modules (with --ignore-install)...")
|
||||
results = load_modem_modules()
|
||||
all_ok = True
|
||||
for mod, ok, detail in results:
|
||||
status = 'OK' if ok else 'FAIL'
|
||||
if not ok:
|
||||
all_ok = False
|
||||
print(f" [{status}] {mod}: {detail}")
|
||||
return 0 if all_ok else 1
|
||||
|
||||
if args.optimize_rf:
|
||||
print(f"Applying RF band locks: RAT={args.rat}, bands={args.bands}...")
|
||||
results = configure_radio_bands(rat=args.rat, bands=args.bands)
|
||||
for name, ok, detail in results:
|
||||
print(f" [{'OK' if ok else 'FAIL'}] {name}: {detail}")
|
||||
return 0
|
||||
|
||||
if args.low_power:
|
||||
try:
|
||||
set_operating_mode('low-power')
|
||||
print("Modem set to low-power mode.")
|
||||
return 0
|
||||
except Exception as exc:
|
||||
print(f"Failed to set low-power mode: {exc}")
|
||||
return 1
|
||||
|
||||
if args.online:
|
||||
if not args.force:
|
||||
ok, msg = check_battery_gate()
|
||||
if not ok:
|
||||
print(f"[REJECTED] {msg} (use --force to override)")
|
||||
return 1
|
||||
try:
|
||||
set_operating_mode('online')
|
||||
print("Modem set to online mode.")
|
||||
return 0
|
||||
except Exception as exc:
|
||||
print(f"Failed to set online mode: {exc}")
|
||||
return 1
|
||||
|
||||
if args.status:
|
||||
result = query_modem_info()
|
||||
if args.json:
|
||||
@@ -430,6 +618,8 @@ def main():
|
||||
daemon=daemon_mode,
|
||||
poll_interval=args.poll_interval,
|
||||
max_attempts=args.max_attempts,
|
||||
rat=args.rat,
|
||||
bands=args.bands,
|
||||
)
|
||||
return 0 if success else 1
|
||||
|
||||
@@ -442,6 +632,11 @@ def main():
|
||||
return 0
|
||||
|
||||
if args.up:
|
||||
if not args.force:
|
||||
ok, msg = check_battery_gate()
|
||||
if not ok:
|
||||
print(f"[REJECTED] {msg} (use --force to override)")
|
||||
return 1
|
||||
try:
|
||||
toggle_cellular(activate=True)
|
||||
print(f"Activated {CONNECTION_NAME}")
|
||||
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/sbin/openrc-run
|
||||
description="Platina Hexagon DSP, RMTFS, and WCN3990 Wi-Fi bringup"
|
||||
|
||||
depend() {
|
||||
after udev modules
|
||||
before networkmanager
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Initializing Platina DSP and WCN3990 Wi-Fi"
|
||||
# 1. Un-blacklist modem driver from initramfs disarm
|
||||
sed -i "/qcom_q6v5_mss/d" /etc/modprobe.d/modem-blacklist.conf 2>/dev/null
|
||||
if ! grep -q "blacklist ipa" /etc/modprobe.d/modem-blacklist.conf 2>/dev/null; then
|
||||
echo -e "install ipa /bin/true\nblacklist ipa" > /etc/modprobe.d/modem-blacklist.conf
|
||||
fi
|
||||
|
||||
# 2. Ensure kernel modules are loaded
|
||||
modprobe qcom_rmtfs_mem 2>/dev/null || true
|
||||
modprobe qcom_q6v5_pas 2>/dev/null || true
|
||||
modprobe qcom_q6v5_mss 2>/dev/null || true
|
||||
|
||||
# 3. Ensure tqftpserv and rmtfs daemons are running
|
||||
if ! pidof tqftpserv >/dev/null 2>&1; then
|
||||
rc-service tqftpserv restart 2>/dev/null || /usr/bin/tqftpserv &
|
||||
fi
|
||||
if ! pidof rmtfs >/dev/null 2>&1; then
|
||||
rc-service rmtfs restart 2>/dev/null || /usr/bin/rmtfs -s -P -r -v &
|
||||
fi
|
||||
|
||||
# Wait up to 3s for remoteproc nodes to register
|
||||
for i in 1 2 3; do
|
||||
if [ -d /sys/class/remoteproc ]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# 4. Start any offline remoteproc instance (modem/ADSP/CDSP)
|
||||
for rproc in /sys/class/remoteproc/remoteproc*; do
|
||||
if [ -d "$rproc" ] && [ -f "$rproc/state" ]; then
|
||||
if [ "$(cat "$rproc/state" 2>/dev/null)" = "offline" ]; then
|
||||
echo start > "$rproc/state" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# 5. Ensure pd-mapper is running
|
||||
if ! pidof pd-mapper >/dev/null 2>&1; then
|
||||
rc-service pd-mapper restart 2>/dev/null || /usr/bin/pd-mapper &
|
||||
fi
|
||||
|
||||
# Wait for modem remoteproc to be running before probing ath10k
|
||||
for i in 1 2 3 4 5; do
|
||||
for rproc in /sys/class/remoteproc/remoteproc*; do
|
||||
if [ -f "$rproc/name" ] && grep -q "4080000" "$rproc/name" 2>/dev/null; then
|
||||
if [ "$(cat "$rproc/state" 2>/dev/null)" = "running" ]; then
|
||||
break 2
|
||||
fi
|
||||
fi
|
||||
done
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# 6. Load ath10k_snoc Wi-Fi driver cleanly
|
||||
if ! lsmod | grep -q ath10k_snoc; then
|
||||
modprobe ath10k_snoc 2>/dev/null || true
|
||||
fi
|
||||
|
||||
eend 0
|
||||
}
|
||||
Executable
+148
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Watch for phone reconnection (Fastboot, Telnet, or SSH).
|
||||
Automatically disarms modem autoloading and ModemManager to prevent RF burst brownout.
|
||||
"""
|
||||
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 check_fastboot():
|
||||
try:
|
||||
res = subprocess.run(["fastboot", "devices"], stdout=subprocess.PIPE, text=True, timeout=1)
|
||||
fb = res.stdout.strip()
|
||||
if fb:
|
||||
return fb
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
def check_usb_device():
|
||||
try:
|
||||
res = subprocess.run(["ioreg", "-p", "IOUSB", "-l"], stdout=subprocess.PIPE, text=True, timeout=2)
|
||||
for line in res.stdout.splitlines():
|
||||
if any(k in line.lower() for k in ["xiaomi", "platina", "android", "qualcomm", "05c6", "gadget"]):
|
||||
return line.strip()
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
def check_interface_up():
|
||||
try:
|
||||
res = subprocess.run(["ifconfig"], stdout=subprocess.PIPE, text=True, timeout=2)
|
||||
return "172.16.42." in res.stdout
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def telnet_exec(cmds):
|
||||
try:
|
||||
s = socket.socket()
|
||||
s.settimeout(5.0)
|
||||
s.connect((TARGET_IP, 23))
|
||||
time.sleep(0.5)
|
||||
for cmd in cmds:
|
||||
s.sendall((cmd + "\n").encode("utf-8"))
|
||||
time.sleep(0.3)
|
||||
time.sleep(1.0)
|
||||
out = ""
|
||||
try:
|
||||
out = s.recv(4096).decode("utf-8", errors="replace")
|
||||
except socket.timeout:
|
||||
pass
|
||||
s.close()
|
||||
return out
|
||||
except Exception as e:
|
||||
return f"Telnet error: {e}"
|
||||
|
||||
def ssh_exec(cmd):
|
||||
ssh_cmd = [
|
||||
"ssh",
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"-o", "UserKnownHostsFile=/dev/null",
|
||||
"-o", "ConnectTimeout=5",
|
||||
"-i", SSH_KEY,
|
||||
f"server@{TARGET_IP}",
|
||||
cmd
|
||||
]
|
||||
try:
|
||||
res = subprocess.run(ssh_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=15)
|
||||
return res.returncode, res.stdout, res.stderr
|
||||
except Exception as e:
|
||||
return -1, "", str(e)
|
||||
|
||||
def main():
|
||||
log("Waiting for phone to appear on USB / Fastboot / Network...")
|
||||
last_reported = 0
|
||||
|
||||
while True:
|
||||
fb = check_fastboot()
|
||||
if fb:
|
||||
log(f"Detected FASTBOOT device: {fb}")
|
||||
|
||||
usb = check_usb_device()
|
||||
if usb:
|
||||
log(f"Detected USB device: {usb}")
|
||||
|
||||
if check_interface_up():
|
||||
log("Host network interface (172.16.42.x) is UP!")
|
||||
# Check telnet first (initramfs debug shell)
|
||||
try:
|
||||
s = socket.socket()
|
||||
s.settimeout(1.0)
|
||||
s.connect((TARGET_IP, 23))
|
||||
s.close()
|
||||
log("Initramfs Telnet (port 23) is OPEN! Mounting root and disarming rootfs autoload...")
|
||||
disarm_cmds = [
|
||||
"cat /sys/class/power_supply/qcom-battery/capacity /sys/class/power_supply/qcom-battery/voltage_now",
|
||||
"mount_root_partition 2>/dev/null || mount /dev/disk/by-label/pmOS_root /sysroot 2>/dev/null",
|
||||
"if [ -d /sysroot/etc ]; then "
|
||||
"mkdir -p /sysroot/etc/modprobe.d && "
|
||||
"echo 'blacklist qcom_q6v5_mss' > /sysroot/etc/modprobe.d/modem-blacklist.conf && "
|
||||
"echo 'blacklist ipa' >> /sysroot/etc/modprobe.d/modem-blacklist.conf && "
|
||||
"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; "
|
||||
"rm -f /sysroot/etc/runlevels/default/modemmanager 2>/dev/null; "
|
||||
"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; "
|
||||
"echo 'UseDNS no' >> /sysroot/etc/ssh/sshd_config 2>/dev/null; "
|
||||
"echo '===PERFECT_DISARM_SUCCESS==='; "
|
||||
"cat /sysroot/etc/modprobe.d/modem-blacklist.conf 2>/dev/null; "
|
||||
"sync; "
|
||||
"umount /sysroot 2>/dev/null; "
|
||||
"fi",
|
||||
"sync",
|
||||
"umount /mnt 2>/dev/null",
|
||||
"/sbin/pmos_continue_boot"
|
||||
]
|
||||
out = telnet_exec(disarm_cmds)
|
||||
log(f"Telnet disarm response:\n{out}")
|
||||
time.sleep(3)
|
||||
continue
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Check SSH
|
||||
try:
|
||||
s = socket.socket()
|
||||
s.settimeout(1.0)
|
||||
s.connect((TARGET_IP, 22))
|
||||
s.close()
|
||||
log("SSH (port 22) is OPEN! Disarming via SSH...")
|
||||
ret, out, err = ssh_exec("sudo rc-service modemmanager stop 2>/dev/null; sudo qmicli -d qrtr://0 --dms-set-operating-mode=low-power 2>/dev/null; sudo sed -i '/qcom_q6v5_mss/d' /etc/modules-load.d/modem.conf 2>/dev/null; sudo sed -i '/ipa/d' /etc/modules-load.d/modem.conf 2>/dev/null; sudo rc-update del modemmanager default 2>/dev/null; echo 'SSH_DISARM_COMPLETE'")
|
||||
log(f"SSH disarm ret={ret}, out={out.strip()}, err={err.strip()}")
|
||||
if ret == 0:
|
||||
log("Successfully disarmed modem via SSH! Ready for controlled bringup.")
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+120
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Poll for en21 link activation, configure Xiaomi Mi 8 Lite network service,
|
||||
and execute complete cellular & EasyTier mesh bringup once SSH is available.
|
||||
"""
|
||||
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 is_en21_active():
|
||||
res = subprocess.run(["ifconfig", "en21"], capture_output=True, text=True)
|
||||
return "status: active" in res.stdout
|
||||
|
||||
def configure_network():
|
||||
service = "Xiaomi Mi 8 Lite"
|
||||
log(f"Configuring network service '{service}'...")
|
||||
subprocess.run(["networksetup", "-setmanual", service, "172.16.42.2", "255.255.255.0", "172.16.42.1"], capture_output=True)
|
||||
|
||||
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("=== Phone Online Watcher Started ===")
|
||||
log("Monitoring 'en21' for active carrier link...")
|
||||
|
||||
active = False
|
||||
start = time.time()
|
||||
while time.time() - start < 180:
|
||||
if is_en21_active():
|
||||
log(">>> en21 link is ACTIVE! <<<")
|
||||
active = True
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
if not active:
|
||||
log("Notice: en21 still inactive. A physical USB cable replug will trigger macOS NCM link sync.")
|
||||
return 1
|
||||
|
||||
configure_network()
|
||||
time.sleep(2)
|
||||
|
||||
log("Testing SSH port 22 on 172.16.42.1...")
|
||||
ssh_up = False
|
||||
start = time.time()
|
||||
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 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(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")
|
||||
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())
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Trigger sysrq reboot, wait for fresh telnet, and verify the patched IPA module.
|
||||
"""
|
||||
import time
|
||||
import socket
|
||||
import subprocess
|
||||
|
||||
TARGET_IP = "172.16.42.1"
|
||||
TARGET_PORT = 23
|
||||
|
||||
def log(msg):
|
||||
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
||||
|
||||
def telnet_cmd(cmd, wait_time=2.0, verbose=True):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(5.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():
|
||||
log("Sending sysrq b emergency reset to phone...")
|
||||
try:
|
||||
s = socket.socket()
|
||||
s.settimeout(3.0)
|
||||
s.connect((TARGET_IP, TARGET_PORT))
|
||||
s.sendall(b"echo b > /proc/sysrq-trigger\n")
|
||||
time.sleep(0.5)
|
||||
s.close()
|
||||
except Exception as e:
|
||||
log(f"Reset sent ({e})")
|
||||
|
||||
log("Waiting for phone to reboot into fresh debug shell...")
|
||||
time.sleep(5)
|
||||
start = time.time()
|
||||
while time.time() - start < 60:
|
||||
s = socket.socket()
|
||||
s.settimeout(1.0)
|
||||
try:
|
||||
s.connect((TARGET_IP, TARGET_PORT))
|
||||
s.close()
|
||||
log("Telnet port 23 is OPEN!")
|
||||
time.sleep(2)
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(1)
|
||||
else:
|
||||
raise TimeoutError("Timed out waiting for telnet")
|
||||
|
||||
# 1. Check uptime & uname
|
||||
telnet_cmd("uname -a; uptime")
|
||||
|
||||
# 2. Mount eMMC and bind modules
|
||||
telnet_cmd("mkdir -p /mnt && mount /dev/mmcblk1p79 /mnt && echo MOUNT_OK")
|
||||
telnet_cmd("mount --bind /mnt/lib/modules /lib/modules && echo BIND_OK")
|
||||
|
||||
# 3. Verify sha256 of ipa.ko.zst
|
||||
telnet_cmd("sha256sum /lib/modules/7.2.12-sdm660/kernel/drivers/net/ipa/ipa.ko.zst")
|
||||
|
||||
# 4. Modprobe IPA
|
||||
log("Loading patched IPA module...")
|
||||
telnet_cmd("modprobe -v ipa; dmesg | tail -n 25")
|
||||
|
||||
# 5. Check netdev
|
||||
telnet_cmd("ip link show rmnet_ipa0")
|
||||
|
||||
# 6. Wait 65s for runtime suspend autosuspend test
|
||||
log("Waiting 65s for autosuspend verification (testing runtime PM fix)...")
|
||||
for sec in range(1, 14):
|
||||
time.sleep(5)
|
||||
print(f".{sec*5}s", end="", flush=True)
|
||||
print()
|
||||
|
||||
# 7. Check dmesg for any oops or errors
|
||||
log("Checking dmesg for crashes...")
|
||||
res = telnet_cmd("dmesg | tail -n 35")
|
||||
|
||||
if "Unable to handle kernel NULL pointer dereference" in res or "Oops:" in res:
|
||||
log("FAILURE: Kernel oops detected!")
|
||||
return 1
|
||||
|
||||
log("SUCCESS: 0 crashes detected after 65s idle timeout!")
|
||||
log("IPA runtime autosuspend fix is 100% VERIFIED!")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
sys.exit(main())
|
||||
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())
|
||||
@@ -0,0 +1,143 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Bulletproof bringup:
|
||||
1. Wait for Fastboot device (63c36adb)
|
||||
2. Boot boot-bulletproof-direct.img (bypasses fsck volume up hang, vibrator pulse, removes early poweroff daemons, injects 00-usb-network.start)
|
||||
3. Reset macOS network service to clear any stale REJECT routes
|
||||
4. Wait for SSH port 22 on 172.16.42.1
|
||||
5. Execute end-to-end cellular data bringup + EasyTier mesh
|
||||
"""
|
||||
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_host_network():
|
||||
log("Resetting macOS 'Xiaomi Mi 8 Lite' network service to clear stale routes...")
|
||||
subprocess.run(["networksetup", "-setnetworkserviceenabled", "Xiaomi Mi 8 Lite", "off"], capture_output=True)
|
||||
time.sleep(1)
|
||||
subprocess.run(["networksetup", "-setnetworkserviceenabled", "Xiaomi Mi 8 Lite", "on"], capture_output=True)
|
||||
time.sleep(0.5)
|
||||
subprocess.run(["networksetup", "-setmanual", "Xiaomi Mi 8 Lite", "172.16.42.2", "255.255.255.0"], capture_output=True)
|
||||
log("Host network service reset completed.")
|
||||
|
||||
def is_usb_interface_active():
|
||||
res = subprocess.run(["ifconfig", "en21"], capture_output=True, text=True)
|
||||
return "status: active" in res.stdout
|
||||
|
||||
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 wait_for_fastboot():
|
||||
log("Waiting for Fastboot device (63c36adb)...")
|
||||
while True:
|
||||
res = subprocess.run(["fastboot", "devices"], capture_output=True, text=True)
|
||||
for line in res.stdout.strip().splitlines():
|
||||
if "fastboot" in line:
|
||||
serial = line.split()[0]
|
||||
log(f"Found Fastboot device: {serial}")
|
||||
return serial
|
||||
time.sleep(1)
|
||||
|
||||
def main():
|
||||
serial = wait_for_fastboot()
|
||||
|
||||
res = subprocess.run(["fastboot", "-s", serial, "getvar", "battery-voltage"], capture_output=True, text=True)
|
||||
log(f"Battery Voltage: {res.stderr.strip() or res.stdout.strip()}")
|
||||
|
||||
log(f"Booting {BOOT_IMG} directly to OpenRC...")
|
||||
res = subprocess.run(["fastboot", "-s", serial, "boot", BOOT_IMG], capture_output=True, text=True)
|
||||
if res.returncode != 0:
|
||||
log(f"Boot failed: {res.stderr}")
|
||||
sys.exit(1)
|
||||
log("Boot command sent! Waiting for device boot...")
|
||||
|
||||
# Wait 8s for kernel to initialize USB gadget
|
||||
time.sleep(8)
|
||||
reset_host_network()
|
||||
|
||||
# Wait for SSH port 22
|
||||
log("Polling SSH port 22 on 172.16.42.1...")
|
||||
start = time.time()
|
||||
ssh_up = False
|
||||
while time.time() - start < 90:
|
||||
if is_usb_interface_active():
|
||||
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.")
|
||||
sys.exit(1)
|
||||
|
||||
time.sleep(2)
|
||||
log("Testing initial SSH login...")
|
||||
code, out, err = run_ssh("uname -a; uptime; cat /sys/class/power_supply/qcom-battery/voltage_now")
|
||||
log(f"System status (code={code}):\n{out.strip()}")
|
||||
|
||||
# Check blacklist
|
||||
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 (expect TX:3, RX:16):\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 4 -I rmnet_ipa0 1.1.1.1 2>&1 || ping -c 4 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=== Bulletproof bringup completed successfully! ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/sh
|
||||
# Setup robust USB gadget network service for postmarketOS userspace
|
||||
|
||||
mkdir -p /sysroot/usr/local/sbin
|
||||
cat << 'EOF' > /sysroot/usr/local/sbin/platina-usb-gadget
|
||||
#!/bin/sh
|
||||
# Platina USB gadget NCM bringup
|
||||
set -e
|
||||
CONFIGFS=/sys/kernel/config/usb_gadget
|
||||
|
||||
# Mount configfs if not mounted
|
||||
if ! mountpoint -q /sys/kernel/config; then
|
||||
mount -t configfs none /sys/kernel/config 2>/dev/null || true
|
||||
fi
|
||||
|
||||
mkdir -p $CONFIGFS/g1
|
||||
echo "0x18D1" > $CONFIGFS/g1/idVendor
|
||||
echo "0xD001" > $CONFIGFS/g1/idProduct
|
||||
|
||||
mkdir -p $CONFIGFS/g1/strings/0x409
|
||||
echo "Xiaomi" > $CONFIGFS/g1/strings/0x409/manufacturer
|
||||
echo "postmarketOS" > $CONFIGFS/g1/strings/0x409/serialnumber
|
||||
echo "Mi 8 Lite" > $CONFIGFS/g1/strings/0x409/product
|
||||
|
||||
mkdir -p $CONFIGFS/g1/functions/ncm.usb0
|
||||
mkdir -p $CONFIGFS/g1/configs/c.1/strings/0x409
|
||||
echo "USB Network" > $CONFIGFS/g1/configs/c.1/strings/0x409/configuration
|
||||
|
||||
if [ ! -L $CONFIGFS/g1/configs/c.1/ncm.usb0 ]; then
|
||||
ln -s $CONFIGFS/g1/functions/ncm.usb0 $CONFIGFS/g1/configs/c.1/
|
||||
fi
|
||||
|
||||
UDC=$(ls /sys/class/udc | head -1)
|
||||
if [ -n "$UDC" ]; then
|
||||
CURRENT=$(cat $CONFIGFS/g1/UDC 2>/dev/null || true)
|
||||
if [ "$CURRENT" != "$UDC" ]; then
|
||||
echo "$UDC" > $CONFIGFS/g1/UDC
|
||||
fi
|
||||
fi
|
||||
EOF
|
||||
chmod +x /sysroot/usr/local/sbin/platina-usb-gadget
|
||||
|
||||
# OpenRC init script
|
||||
cat << 'EOF' > /sysroot/etc/init.d/platina-usb-gadget
|
||||
#!/sbin/openrc-run
|
||||
description="Platina USB Gadget Network"
|
||||
|
||||
depend() {
|
||||
before networkmanager
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Starting Platina USB gadget network"
|
||||
/usr/local/sbin/platina-usb-gadget
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping Platina USB gadget network"
|
||||
echo "" > /sys/kernel/config/usb_gadget/g1/UDC 2>/dev/null || true
|
||||
eend $?
|
||||
}
|
||||
EOF
|
||||
chmod +x /sysroot/etc/init.d/platina-usb-gadget
|
||||
|
||||
# Enable in boot runlevel before networkmanager
|
||||
ln -sf /etc/init.d/platina-usb-gadget /sysroot/etc/runlevels/boot/platina-usb-gadget
|
||||
# Remove broken usb-moded
|
||||
rm -f /sysroot/etc/runlevels/default/usb-moded
|
||||
@@ -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()
|
||||
Executable
+92
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Trigger continue_boot and wait for OpenRC sshd, then verify cellular.
|
||||
"""
|
||||
import time
|
||||
import socket
|
||||
import subprocess
|
||||
|
||||
TARGET_IP = "172.16.42.1"
|
||||
SSH_KEY = "/Users/shenlei/Work/sshKey/oracle_tokyo_ARM.key"
|
||||
USER = "server"
|
||||
|
||||
def log(msg):
|
||||
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
||||
|
||||
def run_ssh(cmd, check=True):
|
||||
ssh_cmd = f"ssh -o StrictHostKeyChecking=no -o ConnectTimeout=8 -i '{SSH_KEY}' {USER}@{TARGET_IP} '{cmd}'"
|
||||
log(f"SSH CMD: {cmd}")
|
||||
res = subprocess.run(ssh_cmd, shell=True, text=True, capture_output=True)
|
||||
if check and res.returncode != 0:
|
||||
log(f"SSH FAIL ({res.returncode}):\n{res.stderr}\n{res.stdout}")
|
||||
return res
|
||||
|
||||
def main():
|
||||
log("Sending continue boot command via telnet...")
|
||||
s = socket.socket()
|
||||
s.settimeout(5.0)
|
||||
try:
|
||||
s.connect((TARGET_IP, 23))
|
||||
time.sleep(0.5)
|
||||
s.sendall(b"/sbin/pmos_continue_boot\n")
|
||||
time.sleep(1.0)
|
||||
s.close()
|
||||
log("pmos_continue_boot sent!")
|
||||
except Exception as e:
|
||||
log(f"Telnet note: {e}")
|
||||
|
||||
log("Waiting for OpenRC to switch root and start sshd on port 22...")
|
||||
for i in range(1, 90):
|
||||
time.sleep(2)
|
||||
sock = socket.socket()
|
||||
sock.settimeout(1.0)
|
||||
try:
|
||||
sock.connect((TARGET_IP, 22))
|
||||
sock.close()
|
||||
log(f"SSH port 22 is OPEN at attempt {i}!")
|
||||
time.sleep(2)
|
||||
break
|
||||
except Exception:
|
||||
if i % 5 == 0:
|
||||
log(f"Still waiting for SSH (attempt {i}/90)...")
|
||||
else:
|
||||
raise TimeoutError("Timed out waiting for SSH port 22")
|
||||
|
||||
# Verify kernel and uptime
|
||||
log("Checking kernel and uptime...")
|
||||
res = run_ssh("uname -a; uptime")
|
||||
log(f"Kernel info:\n{res.stdout.strip()}")
|
||||
|
||||
# Check dmesg for IPA
|
||||
log("Checking dmesg for IPA...")
|
||||
res = run_ssh("sudo dmesg | grep -iE 'ipa|rmnet' | tail -n 25")
|
||||
log(f"IPA dmesg:\n{res.stdout.strip()}")
|
||||
|
||||
# Check network interfaces
|
||||
log("Checking network interfaces...")
|
||||
res = run_ssh("ip link; ip addr")
|
||||
log(f"Interfaces:\n{res.stdout.strip()}")
|
||||
|
||||
# Check modemmanager
|
||||
log("Checking ModemManager...")
|
||||
res = run_ssh("mmcli -L; mmcli -m any 2>&1", check=False)
|
||||
log(f"ModemManager:\n{res.stdout.strip()}")
|
||||
|
||||
# Check QRTR
|
||||
log("Checking QRTR nodes...")
|
||||
res = run_ssh("qrtr-lookup 2>/dev/null || true", check=False)
|
||||
log(f"QRTR lookup:\n{res.stdout.strip()}")
|
||||
|
||||
# Bring up cellular network
|
||||
log("Bringing up cellular network...")
|
||||
run_ssh("sudo platina-cellular --up || nmcli connection up platina-cellular || true", check=False)
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
# Check routing and ping
|
||||
log("Testing connectivity...")
|
||||
res = run_ssh("ip route; ping -I rmnet_ipa0 -c 4 1.1.1.1 || ping -c 4 1.1.1.1 || true", check=False)
|
||||
log(f"Connectivity test:\n{res.stdout.strip()}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+136
@@ -0,0 +1,136 @@
|
||||
#!/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())
|
||||
Reference in New Issue
Block a user