From 14cd3277de1ec1ce902c5a1495fe02c56aedbaa2 Mon Sep 17 00:00:00 2001 From: agent Date: Wed, 29 Jul 2026 05:34:52 +0000 Subject: [PATCH] =?UTF-8?q?feat(tools):=20flash=5Frun=20=E5=86=85=E7=BD=AE?= =?UTF-8?q?=E5=AE=88=E5=80=99=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/suota-flash-log.jsonl | 1 + tools/flash_run.py | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 docs/suota-flash-log.jsonl 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)