diff --git a/docs/suota-flash-log.jsonl b/docs/suota-flash-log.jsonl new file mode 100644 index 0000000..21e2712 --- /dev/null +++ b/docs/suota-flash-log.jsonl @@ -0,0 +1 @@ +{"kind": "run_start", "image": "analysis/firmware/fw_tst.img", "gpio": "05060040", "authorization": "用户授权 2026-07-29(DECISIONS.md)", "ts": "2026-07-29T05:27:57.656"} diff --git a/tools/flash_run.py b/tools/flash_run.py index f462987..504e580 100644 --- a/tools/flash_run.py +++ b/tools/flash_run.py @@ -82,14 +82,24 @@ async def main(): if msg["block"] % 20 == 0 or msg["block"] == msg["total"]: print(f"[{el:6.1f}s] 块确认(2) {msg['block']}/{msg['total']}", flush=True) - async with BridgeTransport(address=DEVICE, timeout=45, subscribe=False, - host=HOST, port=PORT) as t: - print("已连接(净连接),开始全量烧录...", flush=True) - log({"kind": "connected", "device": DEVICE}) - # BridgeTransport.run_ota 不支持 gpio_map 参数,直接发 RPC - result = await ota_with_gpio(HOST, PORT, image, GPIO, prog) - print(f"[{time.time() - t0:6.1f}s] 最终结果: {result}", flush=True) - log({"kind": "run_end", "result": result, "stats": stats}) + # 守候清醒窗口(设备无唤醒按钮、自动周期醒) + for attempt in range(20): + try: + async with BridgeTransport(address=DEVICE, timeout=30, subscribe=False, + host=HOST, port=PORT) as t: + print(f"已连接(第 {attempt + 1} 次尝试),开始全量烧录...", flush=True) + log({"kind": "connected", "device": DEVICE, "attempt": attempt + 1}) + result = await ota_with_gpio(HOST, PORT, image, GPIO, prog) + print(f"[{time.time() - t0:6.1f}s] 最终结果: {result}", flush=True) + log({"kind": "run_end", "result": result, "stats": stats}) + break + except Exception as e: + print(f" 等待设备唤醒...({attempt + 1}/20) {type(e).__name__}", flush=True) + await asyncio.sleep(15) + else: + print("设备持续未醒,放弃", flush=True) + log({"kind": "run_abort", "reason": "device_never_awake"}) + return print(f"=== 状态统计: {stats} ===", flush=True)