feat(tools): flash_run 内置守候循环

This commit is contained in:
agent committed 2026-07-29 05:34:52 +00:00
1 parent 31571b54ef
commit 14cd3277de
2 files changed
+15 -4

No files matched your search

+1
View File
@@ -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"}
+14 -4
View File
@@ -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,
# 守候清醒窗口(设备无唤醒按钮、自动周期醒)
for attempt in range(20):
try:
async with BridgeTransport(address=DEVICE, timeout=30, subscribe=False,
host=HOST, port=PORT) as t:
print("已连接(净连接),开始全量烧录...", flush=True)
log({"kind": "connected", "device": DEVICE})
# BridgeTransport.run_ota 不支持 gpio_map 参数,直接发 RPC
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)