firmwareloop 0.7.1__tar.gz → 0.7.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/PKG-INFO +13 -5
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/README.md +11 -3
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/firmwareloop.egg-info/PKG-INFO +13 -5
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/firmwareloop.egg-info/requires.txt +1 -1
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/pyproject.toml +2 -2
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/__init__.py +1 -1
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/fw_mcp_server.py +40 -12
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/lib/ndtdbg.py +313 -6
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/lib/serial_assistant.py +116 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/ndtdbg_cli.py +54 -9
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/serial_cli.py +35 -5
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/setup-agent-mcp.ps1 +2 -2
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/LICENSE +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/firmwareloop.egg-info/SOURCES.txt +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/firmwareloop.egg-info/dependency_links.txt +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/firmwareloop.egg-info/entry_points.txt +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/firmwareloop.egg-info/top_level.txt +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/setup.cfg +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/acceptance-scenario.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/build.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/can.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/check-qoder-mcp.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/common/build-backends.psm1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/common/fw.psm1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/common/uart_probe.py +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/doctor.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/flash.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/instrument_cli.py +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/lib/__init__.py +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/lib/instruments.py +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/logic_capture.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/logic_decode.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/ndtdbg_bridge.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/reset.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/sigrok_csv_to_fwloop.py +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/test-backends.ps1 +0 -0
- {firmwareloop-0.7.1 → firmwareloop-0.7.3}/tools/test.ps1 +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: firmwareloop
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
4
4
|
Summary: AI Agent Firmware Development and Lab Automation Platform (Dual-Tier MCP Server)
|
|
5
5
|
Author-email: WeilinZhang <19523330249@163.com>
|
|
6
6
|
License: MIT
|
|
@@ -18,7 +18,7 @@ Requires-Python: >=3.10
|
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
20
|
Requires-Dist: pyvisa>=1.14.0
|
|
21
|
-
Requires-Dist: pyvisa-py>=0.7.
|
|
21
|
+
Requires-Dist: pyvisa-py>=0.7.3
|
|
22
22
|
Requires-Dist: pyserial>=3.5
|
|
23
23
|
Requires-Dist: pytest>=8.0.0
|
|
24
24
|
Requires-Dist: pyocd>=0.36.0
|
|
@@ -383,7 +383,7 @@ claude mcp remove --scope user agentic-hil
|
|
|
383
383
|
├── demo-firmware/ 示例固件(CMake;宿主编译模拟 MCU,闭环验证载体)
|
|
384
384
|
├── demo-make/ 示例固件(Make;构建测试载体)
|
|
385
385
|
├── docs/ DEPENDENCY_MATRIX / REUSE_PLAN / V0.0.2_GAP_VERIFICATION
|
|
386
|
-
├── pyproject.toml 标准 Python 包配置与 CLI 入口声明 (v0.7.
|
|
386
|
+
├── pyproject.toml 标准 Python 包配置与 CLI 入口声明 (v0.7.3)
|
|
387
387
|
├── .mcp.example.json 双层 MCP 配置模板(firmwareloop + agentic-hil)
|
|
388
388
|
├── AGENTS.md 通用智能体规范(Antigravity / Qoder / Cursor 等)
|
|
389
389
|
├── CLAUDE.md Claude Code CLI 指南
|
|
@@ -393,7 +393,7 @@ claude mcp remove --scope user agentic-hil
|
|
|
393
393
|
|
|
394
394
|
---
|
|
395
395
|
|
|
396
|
-
## 能力验证状态(v0.7.
|
|
396
|
+
## 能力验证状态(v0.7.3)
|
|
397
397
|
|
|
398
398
|
> 状态定义:`Implemented`(已实现)/ `Simulator Validated`(模拟验证)/
|
|
399
399
|
> `Real Hardware Validated`(真机验证)/ `Experimental` / `Not Implemented`
|
|
@@ -416,7 +416,9 @@ claude mcp remove --scope user agentic-hil
|
|
|
416
416
|
| 自动修复闭环(M6 载体) | Simulator Validated -> Real Hardware Validated 待 DUT |
|
|
417
417
|
| NdtBox 数据采集/调试(fw_ndtdbg_status / fw_ndtdbg_measure, ChipSea Fxx IIC) | Implemented(无硬件 Fail-Closed 已验证)-> Real Hardware Validated 待 NdtBox |
|
|
418
418
|
| NdtBox 目标断电复位(fw_ndtdbg_power_cycle, 仅 io10 断电复位, 无写闸门) | Implemented(单测覆盖时序/探针缺失指引)-> Real Hardware Validated 待 NdtBox |
|
|
419
|
-
| NdtBox IIC 固件烧录(fw_ndtdbg_flash, .bin/.nfw 整片擦写, 芯海 Fxx) | Real Hardware Validated(84.87.1.1 / 84.87.1.2 真机整片擦写 verify pass;双闸门 Fail-Closed
|
|
419
|
+
| NdtBox IIC 固件烧录(fw_ndtdbg_flash, .bin/.nfw 整片擦写, 芯海 Fxx) | Real Hardware Validated(84.87.1.1 / 84.87.1.2 真机整片擦写 verify pass; 2026-09-11 同批文件桥内单体 flash 6/6 pass;双闸门 Fail-Closed)。**v0.7.2 起默认引擎 = 桥内单体 flash**(逐笔 serve 路径现场实测"擦除生效但页写不落地",保留 `flash_engine: serve` 供 A/B);差分 boot 判据 + `boot_judge: off` 逃生开关见 0.7.1;**待验收声明:默认引擎路径(Python 组 plan → Popen 桥 → 解析信封)尚待真机验收** |
|
|
420
|
+
| 烧后冷启动冒烟(fw_ndtdbg_flash 默认开, `cold_boot_check`) | Implemented(单测覆盖通过/全 FF/期望不符/关闭;`COLD_BOOT_VERIFY_FAILED` 错误类)-> Real Hardware Validated 待真机 |
|
|
421
|
+
| 串口占用取证(`port_probe` 试开硬结论 + `holder_candidates` 候选名单) | Implemented(试开结论可复现;候选按 cmdline/name 标注置信度) |
|
|
420
422
|
| 抓开机日志(fw_serial_capture + power_cycle_off_ms, 窗口内断电复位) | Implemented(simulator 验证窗口与复位串联)-> Real Hardware Validated 待 NdtBox + DUT |
|
|
421
423
|
|
|
422
424
|
---
|
|
@@ -434,6 +436,12 @@ claude mcp remove --scope user agentic-hil
|
|
|
434
436
|
| `fw_ndtdbg_flash` 报 `TARGET_MISMATCH: 烧录校验失败 @0x....` | 校验是**权威判据**(不是探测启发式)。信封带 `stage_timings`/`probe_before_hex`/`probe_hex`/`boot_evidence`/`first_mismatch_*`:`boot_evidence=erase_effective` 说明擦除生效 → 看失配偏移是否恒定(恒定=页写未落地);`inconclusive` 说明探测无区分度(擦除后读回全 00/全 FF)→ 需人工确认是否真进了 boot;整片重写次数由 `rewrite_times` 控制(默认 3) |
|
|
435
437
|
| 串口 `SERIAL_PORT_ERROR: ... PermissionError(13)` | 端口被 GUI 上位机独占(NDT Debug Tool / STDataCollection.exe、串口助手)→ 关闭占用方后 `fw_serial_open`;残留会话用 `fw_serial_close`(已自动等待/强杀进程,端口释放可验证) |
|
|
436
438
|
| `fw_serial_status` 的 `error_class` 为 `UART_BUSY` | 会话未打开或已被占用 → 先 `fw_serial_open`;残留会话 `fw_serial_close` 清理 |
|
|
439
|
+
| `fw_serial_*` 报 `PermissionError(13)` / `rx_bytes: 0` | 串口被独占:**退出 NDT Debug Tool GUI(STDataCollection.exe)**——它打开时会同时占住 Box 串口与 USB-IIC 通道;失败信封/`fw_serial_status` 的 `suspected_holders` 会直接列出嫌疑进程(注意别杀 MCP server 的 python) |
|
|
440
|
+
| 烧录"擦除生效(probe 从非 00 变 00)但校验读回全 FF"、`pages_written` 已发出 | v0.7.1 及更早的逐笔 serve 路径问题 → v0.7.3 起默认走 `flash_engine: bridge`(桥内单体,与 GUI 同进程模型);要复现/排查旧行为用 `flash_engine: "serve"` |
|
|
441
|
+
| 长调用(capture/measure)客户端超时 | MCP stdio 循环是**单线程**的:长调用会让同会话其它调用排队(含 3s 的小调用)→ 缩短窗口,或用 `fw_ndtdbg_stream_start` job 模式 |
|
|
442
|
+
| 烧录报 `INCOMPLETE_FLASH` | 桥内 flash 连续 30s 无进度(疑似卡在写入中途)→ **芯片处于半擦写态,勿直接使用,必须重新完整烧录**;信封带 `chip_state: partially_erased` 与 `post_kill_power_cycle`(已尝试复位) |
|
|
443
|
+
| 烧录报 `COLD_BOOT_VERIFY_FAILED` | **Flash 字节已通过逐窗校验,但断电重上电后目标没有有效应答/与期望不符**(现场 `.18` 类问题:GUI 报成功、当场可读,冷启动 `Fw_ver = -1`)→ 按固件冷启动路径排查(看门狗/时钟/外设初始化);或用 `cold_boot_expect` 指定期望值、`cold_boot_check: false` 关闭 |
|
|
444
|
+
| `fw_serial_status` 的 `port_probe.openable = false` | 端口当前**无法独占打开**(硬结论)→ 看 `holder_candidates`(`source: cmdline` 比 `name` 准,候选≠持有者)确认占用方 |
|
|
437
445
|
|
|
438
446
|
完整速查表与手工部署细节见 [`Fwloop_setup_pack/README.md`](Fwloop_setup_pack/README.md)。
|
|
439
447
|
|
|
@@ -355,7 +355,7 @@ claude mcp remove --scope user agentic-hil
|
|
|
355
355
|
├── demo-firmware/ 示例固件(CMake;宿主编译模拟 MCU,闭环验证载体)
|
|
356
356
|
├── demo-make/ 示例固件(Make;构建测试载体)
|
|
357
357
|
├── docs/ DEPENDENCY_MATRIX / REUSE_PLAN / V0.0.2_GAP_VERIFICATION
|
|
358
|
-
├── pyproject.toml 标准 Python 包配置与 CLI 入口声明 (v0.7.
|
|
358
|
+
├── pyproject.toml 标准 Python 包配置与 CLI 入口声明 (v0.7.3)
|
|
359
359
|
├── .mcp.example.json 双层 MCP 配置模板(firmwareloop + agentic-hil)
|
|
360
360
|
├── AGENTS.md 通用智能体规范(Antigravity / Qoder / Cursor 等)
|
|
361
361
|
├── CLAUDE.md Claude Code CLI 指南
|
|
@@ -365,7 +365,7 @@ claude mcp remove --scope user agentic-hil
|
|
|
365
365
|
|
|
366
366
|
---
|
|
367
367
|
|
|
368
|
-
## 能力验证状态(v0.7.
|
|
368
|
+
## 能力验证状态(v0.7.3)
|
|
369
369
|
|
|
370
370
|
> 状态定义:`Implemented`(已实现)/ `Simulator Validated`(模拟验证)/
|
|
371
371
|
> `Real Hardware Validated`(真机验证)/ `Experimental` / `Not Implemented`
|
|
@@ -388,7 +388,9 @@ claude mcp remove --scope user agentic-hil
|
|
|
388
388
|
| 自动修复闭环(M6 载体) | Simulator Validated -> Real Hardware Validated 待 DUT |
|
|
389
389
|
| NdtBox 数据采集/调试(fw_ndtdbg_status / fw_ndtdbg_measure, ChipSea Fxx IIC) | Implemented(无硬件 Fail-Closed 已验证)-> Real Hardware Validated 待 NdtBox |
|
|
390
390
|
| NdtBox 目标断电复位(fw_ndtdbg_power_cycle, 仅 io10 断电复位, 无写闸门) | Implemented(单测覆盖时序/探针缺失指引)-> Real Hardware Validated 待 NdtBox |
|
|
391
|
-
| NdtBox IIC 固件烧录(fw_ndtdbg_flash, .bin/.nfw 整片擦写, 芯海 Fxx) | Real Hardware Validated(84.87.1.1 / 84.87.1.2 真机整片擦写 verify pass;双闸门 Fail-Closed
|
|
391
|
+
| NdtBox IIC 固件烧录(fw_ndtdbg_flash, .bin/.nfw 整片擦写, 芯海 Fxx) | Real Hardware Validated(84.87.1.1 / 84.87.1.2 真机整片擦写 verify pass; 2026-09-11 同批文件桥内单体 flash 6/6 pass;双闸门 Fail-Closed)。**v0.7.2 起默认引擎 = 桥内单体 flash**(逐笔 serve 路径现场实测"擦除生效但页写不落地",保留 `flash_engine: serve` 供 A/B);差分 boot 判据 + `boot_judge: off` 逃生开关见 0.7.1;**待验收声明:默认引擎路径(Python 组 plan → Popen 桥 → 解析信封)尚待真机验收** |
|
|
392
|
+
| 烧后冷启动冒烟(fw_ndtdbg_flash 默认开, `cold_boot_check`) | Implemented(单测覆盖通过/全 FF/期望不符/关闭;`COLD_BOOT_VERIFY_FAILED` 错误类)-> Real Hardware Validated 待真机 |
|
|
393
|
+
| 串口占用取证(`port_probe` 试开硬结论 + `holder_candidates` 候选名单) | Implemented(试开结论可复现;候选按 cmdline/name 标注置信度) |
|
|
392
394
|
| 抓开机日志(fw_serial_capture + power_cycle_off_ms, 窗口内断电复位) | Implemented(simulator 验证窗口与复位串联)-> Real Hardware Validated 待 NdtBox + DUT |
|
|
393
395
|
|
|
394
396
|
---
|
|
@@ -406,6 +408,12 @@ claude mcp remove --scope user agentic-hil
|
|
|
406
408
|
| `fw_ndtdbg_flash` 报 `TARGET_MISMATCH: 烧录校验失败 @0x....` | 校验是**权威判据**(不是探测启发式)。信封带 `stage_timings`/`probe_before_hex`/`probe_hex`/`boot_evidence`/`first_mismatch_*`:`boot_evidence=erase_effective` 说明擦除生效 → 看失配偏移是否恒定(恒定=页写未落地);`inconclusive` 说明探测无区分度(擦除后读回全 00/全 FF)→ 需人工确认是否真进了 boot;整片重写次数由 `rewrite_times` 控制(默认 3) |
|
|
407
409
|
| 串口 `SERIAL_PORT_ERROR: ... PermissionError(13)` | 端口被 GUI 上位机独占(NDT Debug Tool / STDataCollection.exe、串口助手)→ 关闭占用方后 `fw_serial_open`;残留会话用 `fw_serial_close`(已自动等待/强杀进程,端口释放可验证) |
|
|
408
410
|
| `fw_serial_status` 的 `error_class` 为 `UART_BUSY` | 会话未打开或已被占用 → 先 `fw_serial_open`;残留会话 `fw_serial_close` 清理 |
|
|
411
|
+
| `fw_serial_*` 报 `PermissionError(13)` / `rx_bytes: 0` | 串口被独占:**退出 NDT Debug Tool GUI(STDataCollection.exe)**——它打开时会同时占住 Box 串口与 USB-IIC 通道;失败信封/`fw_serial_status` 的 `suspected_holders` 会直接列出嫌疑进程(注意别杀 MCP server 的 python) |
|
|
412
|
+
| 烧录"擦除生效(probe 从非 00 变 00)但校验读回全 FF"、`pages_written` 已发出 | v0.7.1 及更早的逐笔 serve 路径问题 → v0.7.3 起默认走 `flash_engine: bridge`(桥内单体,与 GUI 同进程模型);要复现/排查旧行为用 `flash_engine: "serve"` |
|
|
413
|
+
| 长调用(capture/measure)客户端超时 | MCP stdio 循环是**单线程**的:长调用会让同会话其它调用排队(含 3s 的小调用)→ 缩短窗口,或用 `fw_ndtdbg_stream_start` job 模式 |
|
|
414
|
+
| 烧录报 `INCOMPLETE_FLASH` | 桥内 flash 连续 30s 无进度(疑似卡在写入中途)→ **芯片处于半擦写态,勿直接使用,必须重新完整烧录**;信封带 `chip_state: partially_erased` 与 `post_kill_power_cycle`(已尝试复位) |
|
|
415
|
+
| 烧录报 `COLD_BOOT_VERIFY_FAILED` | **Flash 字节已通过逐窗校验,但断电重上电后目标没有有效应答/与期望不符**(现场 `.18` 类问题:GUI 报成功、当场可读,冷启动 `Fw_ver = -1`)→ 按固件冷启动路径排查(看门狗/时钟/外设初始化);或用 `cold_boot_expect` 指定期望值、`cold_boot_check: false` 关闭 |
|
|
416
|
+
| `fw_serial_status` 的 `port_probe.openable = false` | 端口当前**无法独占打开**(硬结论)→ 看 `holder_candidates`(`source: cmdline` 比 `name` 准,候选≠持有者)确认占用方 |
|
|
409
417
|
|
|
410
418
|
完整速查表与手工部署细节见 [`Fwloop_setup_pack/README.md`](Fwloop_setup_pack/README.md)。
|
|
411
419
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: firmwareloop
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
4
4
|
Summary: AI Agent Firmware Development and Lab Automation Platform (Dual-Tier MCP Server)
|
|
5
5
|
Author-email: WeilinZhang <19523330249@163.com>
|
|
6
6
|
License: MIT
|
|
@@ -18,7 +18,7 @@ Requires-Python: >=3.10
|
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
20
|
Requires-Dist: pyvisa>=1.14.0
|
|
21
|
-
Requires-Dist: pyvisa-py>=0.7.
|
|
21
|
+
Requires-Dist: pyvisa-py>=0.7.3
|
|
22
22
|
Requires-Dist: pyserial>=3.5
|
|
23
23
|
Requires-Dist: pytest>=8.0.0
|
|
24
24
|
Requires-Dist: pyocd>=0.36.0
|
|
@@ -383,7 +383,7 @@ claude mcp remove --scope user agentic-hil
|
|
|
383
383
|
├── demo-firmware/ 示例固件(CMake;宿主编译模拟 MCU,闭环验证载体)
|
|
384
384
|
├── demo-make/ 示例固件(Make;构建测试载体)
|
|
385
385
|
├── docs/ DEPENDENCY_MATRIX / REUSE_PLAN / V0.0.2_GAP_VERIFICATION
|
|
386
|
-
├── pyproject.toml 标准 Python 包配置与 CLI 入口声明 (v0.7.
|
|
386
|
+
├── pyproject.toml 标准 Python 包配置与 CLI 入口声明 (v0.7.3)
|
|
387
387
|
├── .mcp.example.json 双层 MCP 配置模板(firmwareloop + agentic-hil)
|
|
388
388
|
├── AGENTS.md 通用智能体规范(Antigravity / Qoder / Cursor 等)
|
|
389
389
|
├── CLAUDE.md Claude Code CLI 指南
|
|
@@ -393,7 +393,7 @@ claude mcp remove --scope user agentic-hil
|
|
|
393
393
|
|
|
394
394
|
---
|
|
395
395
|
|
|
396
|
-
## 能力验证状态(v0.7.
|
|
396
|
+
## 能力验证状态(v0.7.3)
|
|
397
397
|
|
|
398
398
|
> 状态定义:`Implemented`(已实现)/ `Simulator Validated`(模拟验证)/
|
|
399
399
|
> `Real Hardware Validated`(真机验证)/ `Experimental` / `Not Implemented`
|
|
@@ -416,7 +416,9 @@ claude mcp remove --scope user agentic-hil
|
|
|
416
416
|
| 自动修复闭环(M6 载体) | Simulator Validated -> Real Hardware Validated 待 DUT |
|
|
417
417
|
| NdtBox 数据采集/调试(fw_ndtdbg_status / fw_ndtdbg_measure, ChipSea Fxx IIC) | Implemented(无硬件 Fail-Closed 已验证)-> Real Hardware Validated 待 NdtBox |
|
|
418
418
|
| NdtBox 目标断电复位(fw_ndtdbg_power_cycle, 仅 io10 断电复位, 无写闸门) | Implemented(单测覆盖时序/探针缺失指引)-> Real Hardware Validated 待 NdtBox |
|
|
419
|
-
| NdtBox IIC 固件烧录(fw_ndtdbg_flash, .bin/.nfw 整片擦写, 芯海 Fxx) | Real Hardware Validated(84.87.1.1 / 84.87.1.2 真机整片擦写 verify pass;双闸门 Fail-Closed
|
|
419
|
+
| NdtBox IIC 固件烧录(fw_ndtdbg_flash, .bin/.nfw 整片擦写, 芯海 Fxx) | Real Hardware Validated(84.87.1.1 / 84.87.1.2 真机整片擦写 verify pass; 2026-09-11 同批文件桥内单体 flash 6/6 pass;双闸门 Fail-Closed)。**v0.7.2 起默认引擎 = 桥内单体 flash**(逐笔 serve 路径现场实测"擦除生效但页写不落地",保留 `flash_engine: serve` 供 A/B);差分 boot 判据 + `boot_judge: off` 逃生开关见 0.7.1;**待验收声明:默认引擎路径(Python 组 plan → Popen 桥 → 解析信封)尚待真机验收** |
|
|
420
|
+
| 烧后冷启动冒烟(fw_ndtdbg_flash 默认开, `cold_boot_check`) | Implemented(单测覆盖通过/全 FF/期望不符/关闭;`COLD_BOOT_VERIFY_FAILED` 错误类)-> Real Hardware Validated 待真机 |
|
|
421
|
+
| 串口占用取证(`port_probe` 试开硬结论 + `holder_candidates` 候选名单) | Implemented(试开结论可复现;候选按 cmdline/name 标注置信度) |
|
|
420
422
|
| 抓开机日志(fw_serial_capture + power_cycle_off_ms, 窗口内断电复位) | Implemented(simulator 验证窗口与复位串联)-> Real Hardware Validated 待 NdtBox + DUT |
|
|
421
423
|
|
|
422
424
|
---
|
|
@@ -434,6 +436,12 @@ claude mcp remove --scope user agentic-hil
|
|
|
434
436
|
| `fw_ndtdbg_flash` 报 `TARGET_MISMATCH: 烧录校验失败 @0x....` | 校验是**权威判据**(不是探测启发式)。信封带 `stage_timings`/`probe_before_hex`/`probe_hex`/`boot_evidence`/`first_mismatch_*`:`boot_evidence=erase_effective` 说明擦除生效 → 看失配偏移是否恒定(恒定=页写未落地);`inconclusive` 说明探测无区分度(擦除后读回全 00/全 FF)→ 需人工确认是否真进了 boot;整片重写次数由 `rewrite_times` 控制(默认 3) |
|
|
435
437
|
| 串口 `SERIAL_PORT_ERROR: ... PermissionError(13)` | 端口被 GUI 上位机独占(NDT Debug Tool / STDataCollection.exe、串口助手)→ 关闭占用方后 `fw_serial_open`;残留会话用 `fw_serial_close`(已自动等待/强杀进程,端口释放可验证) |
|
|
436
438
|
| `fw_serial_status` 的 `error_class` 为 `UART_BUSY` | 会话未打开或已被占用 → 先 `fw_serial_open`;残留会话 `fw_serial_close` 清理 |
|
|
439
|
+
| `fw_serial_*` 报 `PermissionError(13)` / `rx_bytes: 0` | 串口被独占:**退出 NDT Debug Tool GUI(STDataCollection.exe)**——它打开时会同时占住 Box 串口与 USB-IIC 通道;失败信封/`fw_serial_status` 的 `suspected_holders` 会直接列出嫌疑进程(注意别杀 MCP server 的 python) |
|
|
440
|
+
| 烧录"擦除生效(probe 从非 00 变 00)但校验读回全 FF"、`pages_written` 已发出 | v0.7.1 及更早的逐笔 serve 路径问题 → v0.7.3 起默认走 `flash_engine: bridge`(桥内单体,与 GUI 同进程模型);要复现/排查旧行为用 `flash_engine: "serve"` |
|
|
441
|
+
| 长调用(capture/measure)客户端超时 | MCP stdio 循环是**单线程**的:长调用会让同会话其它调用排队(含 3s 的小调用)→ 缩短窗口,或用 `fw_ndtdbg_stream_start` job 模式 |
|
|
442
|
+
| 烧录报 `INCOMPLETE_FLASH` | 桥内 flash 连续 30s 无进度(疑似卡在写入中途)→ **芯片处于半擦写态,勿直接使用,必须重新完整烧录**;信封带 `chip_state: partially_erased` 与 `post_kill_power_cycle`(已尝试复位) |
|
|
443
|
+
| 烧录报 `COLD_BOOT_VERIFY_FAILED` | **Flash 字节已通过逐窗校验,但断电重上电后目标没有有效应答/与期望不符**(现场 `.18` 类问题:GUI 报成功、当场可读,冷启动 `Fw_ver = -1`)→ 按固件冷启动路径排查(看门狗/时钟/外设初始化);或用 `cold_boot_expect` 指定期望值、`cold_boot_check: false` 关闭 |
|
|
444
|
+
| `fw_serial_status` 的 `port_probe.openable = false` | 端口当前**无法独占打开**(硬结论)→ 看 `holder_candidates`(`source: cmdline` 比 `name` 准,候选≠持有者)确认占用方 |
|
|
437
445
|
|
|
438
446
|
完整速查表与手工部署细节见 [`Fwloop_setup_pack/README.md`](Fwloop_setup_pack/README.md)。
|
|
439
447
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "firmwareloop"
|
|
7
|
-
version = "0.7.
|
|
7
|
+
version = "0.7.3"
|
|
8
8
|
description = "AI Agent Firmware Development and Lab Automation Platform (Dual-Tier MCP Server)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -14,7 +14,7 @@ license = { text = "MIT" }
|
|
|
14
14
|
requires-python = ">=3.10"
|
|
15
15
|
dependencies = [
|
|
16
16
|
"pyvisa>=1.14.0",
|
|
17
|
-
"pyvisa-py>=0.7.
|
|
17
|
+
"pyvisa-py>=0.7.3",
|
|
18
18
|
"pyserial>=3.5",
|
|
19
19
|
"pytest>=8.0.0",
|
|
20
20
|
"pyocd>=0.36.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
fw_mcp_server.py - FirmwareLoop High-Level Workflow & Device MCP Server (v0.7.
|
|
3
|
+
fw_mcp_server.py - FirmwareLoop High-Level Workflow & Device MCP Server (v0.7.3).
|
|
4
4
|
|
|
5
5
|
Exposes high-level firmware engineering and hardware management tools to AI Coding
|
|
6
6
|
Agents (Antigravity CLI, Claude Code CLI, Qoder IDE, CodeBuddy IDE, Cursor) via the Model Context
|
|
@@ -332,7 +332,7 @@ def handle_fw_ndtdbg_write_reg(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
332
332
|
def handle_fw_ndtdbg_flash(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
333
333
|
"""Erase + flash a .bin/.nfw image onto the NdtBox target chip (ChipSea Fxx) over IIC.
|
|
334
334
|
|
|
335
|
-
P1-3 (0.7.
|
|
335
|
+
P1-3 (0.7.3): 去掉按签名重试 —— "TARGET_MISMATCH @0x0000" 正是"根本没进 boot"的
|
|
336
336
|
特征签名 (旧 boot 判据假阳的同一条错误路径), 盲目重试只会重复同一失败路径。
|
|
337
337
|
整片重写 (<= rewrite_times) 现由 flash_exec 内部完成, 结果带 rewrite_count;
|
|
338
338
|
BOOT_NOT_ENTERED 直接返回指引 (需断电重启, 重试无意义)。
|
|
@@ -346,6 +346,15 @@ def handle_fw_ndtdbg_flash(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
346
346
|
cmd.extend(["--rewrite-times", str(max(0, int(args["rewrite_times"])))])
|
|
347
347
|
if args.get("boot_judge"):
|
|
348
348
|
cmd.extend(["--boot-judge", str(args["boot_judge"])])
|
|
349
|
+
if args.get("flash_engine"):
|
|
350
|
+
cmd.extend(["--flash-engine", str(args["flash_engine"])])
|
|
351
|
+
# 冷启动冒烟 (评审 §4): 默认开 -> CLI 默认即开, 仅显式 false 时加关闭旗标
|
|
352
|
+
if args.get("cold_boot_check") is False:
|
|
353
|
+
cmd.append("--no-cold-boot-check")
|
|
354
|
+
if args.get("cold_boot_reg") is not None:
|
|
355
|
+
cmd.extend(["--cold-boot-reg", str(int(args["cold_boot_reg"]))])
|
|
356
|
+
if args.get("cold_boot_expect"):
|
|
357
|
+
cmd.extend(["--cold-boot-expect", str(args["cold_boot_expect"])])
|
|
349
358
|
if args.get("confirm"):
|
|
350
359
|
cmd.append("--confirm")
|
|
351
360
|
_ndtdbg_reg_args(args, cmd)
|
|
@@ -1679,7 +1688,7 @@ TOOLS_REGISTRY = {
|
|
|
1679
1688
|
"handler": handle_fw_ndtdbg_status,
|
|
1680
1689
|
},
|
|
1681
1690
|
"fw_ndtdbg_measure": {
|
|
1682
|
-
"description": "Poll NdtBox IIC debug data stream (ChipSea Fxx) for N seconds: frame count, checksum errors, channel samples. Read-only
|
|
1691
|
+
"description": "Poll NdtBox IIC debug data stream (ChipSea Fxx) for N seconds: frame count, checksum errors, channel samples. Read-only. NOTE: the MCP stdio loop is single-threaded, so a long call blocks every other call in the same session (a concurrent short call just waits and may time out client-side) - keep duration_seconds small; use fw_ndtdbg_stream_start for long captures.",
|
|
1683
1692
|
"inputSchema": {
|
|
1684
1693
|
"type": "object",
|
|
1685
1694
|
"properties": {
|
|
@@ -1772,7 +1781,7 @@ TOOLS_REGISTRY = {
|
|
|
1772
1781
|
"handler": handle_fw_ndtdbg_write_reg,
|
|
1773
1782
|
},
|
|
1774
1783
|
"fw_ndtdbg_flash": {
|
|
1775
|
-
"description": "Erase and flash a .bin/.nfw firmware image onto the NdtBox target chip (ChipSea Fxx) over IIC via NdtDebugTool
|
|
1784
|
+
"description": "Erase and flash a .bin/.nfw firmware image onto the NdtBox target chip (ChipSea Fxx) over IIC via NdtDebugTool. Default engine 'bridge' runs the whole UpdateFW sequence in ONE 32-bit process holding both the IIC and power-rail handles (power-cycle into boot -> erase magic AA 55 A5 5A -> 128B page writes -> 256B read-back verify per window = the authoritative criterion -> finish 'PASs'), which is the path validated 6/6 on real hardware; engine 'serve' drives one raw transaction per page from Python (kept for A/B reproduction - field evidence showed it can report erase-effective but write nothing on the same frames). DESTRUCTIVE full-chip erase: requires lab.yaml ndtdbg.write_allowed: true AND confirm: true, otherwise PERMISSION_DENIED.",
|
|
1776
1785
|
"inputSchema": {
|
|
1777
1786
|
"type": "object",
|
|
1778
1787
|
"properties": {
|
|
@@ -1806,7 +1815,26 @@ TOOLS_REGISTRY = {
|
|
|
1806
1815
|
"boot_judge": {
|
|
1807
1816
|
"type": "string",
|
|
1808
1817
|
"enum": ["diff", "off"],
|
|
1809
|
-
"description": "Boot-probe criterion. 'diff' (default): compare 0x0000 before the power cycle vs after the erase, and raise BOOT_NOT_ENTERED only when both reads are identical NON-TRIVIAL data (proof the same running App answered the erase magic). 'off': only record probe evidence (probe_before_hex/probe_hex/boot_evidence) and never block - the 256B read-back verify stays the sole criterion, i.e. exactly the bridge/GUI behaviour. Use 'off' if a target ROM reports an unexpected 0x0000 signature",
|
|
1818
|
+
"description": "Boot-probe criterion (serve engine only). 'diff' (default): compare 0x0000 before the power cycle vs after the erase, and raise BOOT_NOT_ENTERED only when both reads are identical NON-TRIVIAL data (proof the same running App answered the erase magic). 'off': only record probe evidence (probe_before_hex/probe_hex/boot_evidence) and never block - the 256B read-back verify stays the sole criterion, i.e. exactly the bridge/GUI behaviour. Use 'off' if a target ROM reports an unexpected 0x0000 signature",
|
|
1819
|
+
},
|
|
1820
|
+
"flash_engine": {
|
|
1821
|
+
"type": "string",
|
|
1822
|
+
"enum": ["bridge", "serve"],
|
|
1823
|
+
"description": "Flash transport. 'bridge' (default): whole sequence inside one 32-bit process, frames passed once via stdin, both device handles held - real-hardware validated (6/6). 'serve': one raw I2C transaction per page driven from Python (kept for A/B; field evidence: same frames reported 'erase effective' yet wrote nothing). Use 'serve' only to reproduce/diagnose that case",
|
|
1824
|
+
},
|
|
1825
|
+
"cold_boot_check": {
|
|
1826
|
+
"type": "boolean",
|
|
1827
|
+
"description": "Post-flash cold-boot smoke test (default true, recommended): power-cycle the target, then read cold_boot_reg and decide whether the firmware actually runs. Byte-level read-back verification cannot catch 'image flashed OK but the device is dead after power-up' (field case: GUI said Success and read back fine, but Fw_ver = -1 after a real power cycle). Returns COLD_BOOT_VERIFY_FAILED with the raw bytes read vs expected - the flash itself is already verified, so decide whether the failure is expected (e.g. a bootloader-only image or a register that legitimately has no content). Set false to skip",
|
|
1828
|
+
"default": True,
|
|
1829
|
+
},
|
|
1830
|
+
"cold_boot_reg": {
|
|
1831
|
+
"type": "integer",
|
|
1832
|
+
"description": "Register read for the cold-boot check (default 0x10 = firmware version)",
|
|
1833
|
+
"default": 16,
|
|
1834
|
+
},
|
|
1835
|
+
"cold_boot_expect": {
|
|
1836
|
+
"type": "string",
|
|
1837
|
+
"description": "Optional expected hex for cold-boot verification (e.g. '51 17 64 11'); when omitted the check only requires a meaningful (non-all-00/FF) answer",
|
|
1810
1838
|
},
|
|
1811
1839
|
"dll_dir": {
|
|
1812
1840
|
"type": "string",
|
|
@@ -2242,7 +2270,7 @@ TOOLS_REGISTRY = {
|
|
|
2242
2270
|
"handler": handle_fw_serial_parse,
|
|
2243
2271
|
},
|
|
2244
2272
|
"fw_serial_capture": {
|
|
2245
|
-
"description": "Serial assistant: synchronous window capture - record the RX stream for duration_ms into a timestamped CSV (t_rel_ms, dir, hex, printable) for offline analysis/plotting (real-time-curve equivalent; plotting happens in your tools/Agent from the CSV). Pass power_cycle_off_ms to fire an NdtBox power-cycle inside the window and capture boot-time prints (port is opened first). duration_ms <= 90000; long background captures (job mode) are a planned follow-up.",
|
|
2273
|
+
"description": "Serial assistant: synchronous window capture - record the RX stream for duration_ms into a timestamped CSV (t_rel_ms, dir, hex, printable) for offline analysis/plotting (real-time-curve equivalent; plotting happens in your tools/Agent from the CSV). Pass power_cycle_off_ms to fire an NdtBox power-cycle inside the window and capture boot-time prints (port is opened first). duration_ms <= 90000; long background captures (job mode) are a planned follow-up. NOTE: the MCP stdio loop is single-threaded, so this call blocks every other call in the same session for the whole window (your client may time out first) - prefer windows of a few seconds and call it when nothing else needs the box.",
|
|
2246
2274
|
"inputSchema": {
|
|
2247
2275
|
"type": "object",
|
|
2248
2276
|
"properties": {
|
|
@@ -2307,7 +2335,7 @@ def process_request(req: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
|
|
2307
2335
|
},
|
|
2308
2336
|
"serverInfo": {
|
|
2309
2337
|
"name": "firmwareloop",
|
|
2310
|
-
"version": "0.7.
|
|
2338
|
+
"version": "0.7.3"
|
|
2311
2339
|
}
|
|
2312
2340
|
}
|
|
2313
2341
|
}
|
|
@@ -2442,7 +2470,7 @@ def _settle_stashed_entrypoints(stashed) -> None:
|
|
|
2442
2470
|
def handle_cli_update() -> int:
|
|
2443
2471
|
"""Handle `firmwareloop update` command."""
|
|
2444
2472
|
print("============================================================")
|
|
2445
|
-
print(" FirmwareLoop Auto-Updater (v0.7.
|
|
2473
|
+
print(" FirmwareLoop Auto-Updater (v0.7.3)")
|
|
2446
2474
|
print("============================================================")
|
|
2447
2475
|
|
|
2448
2476
|
is_git_repo = os.path.exists(os.path.join(REPO_ROOT, ".git"))
|
|
@@ -2873,7 +2901,7 @@ def set_ndtdbg_dlldir(dll_path: str) -> str:
|
|
|
2873
2901
|
def handle_cli_setup() -> int:
|
|
2874
2902
|
"""Handle `firmwareloop setup` command: simultaneously configure Antigravity CLI, Claude Code CLI, Qoder IDE, and CodeBuddy IDE."""
|
|
2875
2903
|
print("============================================================")
|
|
2876
|
-
print(" FirmwareLoop Multi-Agent Global Setup Helper (v0.7.
|
|
2904
|
+
print(" FirmwareLoop Multi-Agent Global Setup Helper (v0.7.3)")
|
|
2877
2905
|
print("============================================================")
|
|
2878
2906
|
print("")
|
|
2879
2907
|
|
|
@@ -2998,7 +3026,7 @@ def handle_cli_setup() -> int:
|
|
|
2998
3026
|
def handle_cli_init(chip: Optional[str] = None, upgrade: bool = False) -> int:
|
|
2999
3027
|
"""Handle `firmwareloop init [target_chip]` command."""
|
|
3000
3028
|
print("============================================================")
|
|
3001
|
-
print(" FirmwareLoop Multi-Agent Project Initializer (v0.7.
|
|
3029
|
+
print(" FirmwareLoop Multi-Agent Project Initializer (v0.7.3)")
|
|
3002
3030
|
print("============================================================")
|
|
3003
3031
|
cwd = os.getcwd()
|
|
3004
3032
|
print(f"[*] Initializing multi-agent guidelines & bench config in:\n {cwd}\n")
|
|
@@ -3031,7 +3059,7 @@ def handle_cli_init(chip: Optional[str] = None, upgrade: bool = False) -> int:
|
|
|
3031
3059
|
|
|
3032
3060
|
|
|
3033
3061
|
def print_cli_help() -> None:
|
|
3034
|
-
print("""FirmwareLoop (fwloop) — AI Agent Firmware Engineering & Lab Automation Platform (v0.7.
|
|
3062
|
+
print("""FirmwareLoop (fwloop) — AI Agent Firmware Engineering & Lab Automation Platform (v0.7.3)
|
|
3035
3063
|
|
|
3036
3064
|
Usage:
|
|
3037
3065
|
fwloop [command] (or: firmwareloop [command])
|
|
@@ -3077,7 +3105,7 @@ def main() -> None:
|
|
|
3077
3105
|
sys.exit(2)
|
|
3078
3106
|
sys.exit(handle_cli_ndtdebugtool(args[1]))
|
|
3079
3107
|
elif cmd in ["version", "-v", "--version"]:
|
|
3080
|
-
print("FirmwareLoop v0.7.
|
|
3108
|
+
print("FirmwareLoop v0.7.3")
|
|
3081
3109
|
sys.exit(0)
|
|
3082
3110
|
elif cmd in ["help", "-h", "--help"]:
|
|
3083
3111
|
print_cli_help()
|
|
@@ -11,6 +11,7 @@ import contextlib
|
|
|
11
11
|
import json
|
|
12
12
|
import os
|
|
13
13
|
import queue
|
|
14
|
+
import re
|
|
14
15
|
import subprocess
|
|
15
16
|
import sys
|
|
16
17
|
import threading
|
|
@@ -402,13 +403,19 @@ class NdtBoxIo:
|
|
|
402
403
|
return self._persistent
|
|
403
404
|
|
|
404
405
|
def _with_sess(self, fn):
|
|
406
|
+
"""在活跃会话上执行单事务。
|
|
407
|
+
|
|
408
|
+
`with io.session():` 块内 self._persistent 已置位 ⇒ 复用同一个 32 位桥进程与
|
|
409
|
+
USB 会话 (事务延迟 = 一次管道往返); 块外为即用即关 (spawn+open+事务+close)。
|
|
410
|
+
(现场曾怀疑此处未复用导致 77ms/页——每笔新 spawn 是 ~1.5s 量级, 与 77ms 不符,
|
|
411
|
+
故复用确实生效; 该现象的真因见 flash_exec 的引擎说明。)
|
|
412
|
+
"""
|
|
405
413
|
sess = self._get_live_sess()
|
|
406
|
-
if self._persistent is sess:
|
|
407
|
-
return fn(sess)
|
|
408
414
|
try:
|
|
409
415
|
return fn(sess)
|
|
410
416
|
finally:
|
|
411
|
-
sess.
|
|
417
|
+
if sess is not self._persistent:
|
|
418
|
+
sess.close()
|
|
412
419
|
|
|
413
420
|
# -- 芯片无关原语 (对齐 IIC.cs / I2CProxy.cs) --
|
|
414
421
|
|
|
@@ -424,7 +431,18 @@ class NdtBoxIo:
|
|
|
424
431
|
return self._with_sess(lambda s: s.read_reg(reg, length))
|
|
425
432
|
|
|
426
433
|
def write_reg(self, reg: int, data: bytes) -> None:
|
|
427
|
-
|
|
434
|
+
try:
|
|
435
|
+
self._with_sess(lambda s: s.write_reg(reg, data))
|
|
436
|
+
except NdtBoxError as exc:
|
|
437
|
+
if exc.error_class != "TARGET_MISMATCH":
|
|
438
|
+
raise
|
|
439
|
+
# P2-1: 写 NACK ≠ 从机死了 —— 现场实证"读正常但写稳定失败"
|
|
440
|
+
raise NdtBoxError(
|
|
441
|
+
exc.error_class, exc.message, exc.detail,
|
|
442
|
+
{"hint": "写事务无应答与'从机整体不应答'不同: 若紧随其后的读事务正常, 更可能是"
|
|
443
|
+
"该寄存器不可写/写保护, 或目标固件未实现该写寄存器 (也可能是写事务"
|
|
444
|
+
"超长/格式不符)。先用 fw_ndtdbg_read_reg 回读邻居寄存器确认链路仍活, "
|
|
445
|
+
"再核对寄存器语义"}) from exc
|
|
428
446
|
|
|
429
447
|
def raw_write_read(self, write: bytes, read_len: int = 0) -> bytes | None:
|
|
430
448
|
"""原始 IIC 事务 (对齐 IIC.WriteRead): 写 write 字节(不含从机地址) 再读 read_len 字节。
|
|
@@ -660,7 +678,223 @@ class NdtBoxIo:
|
|
|
660
678
|
return None
|
|
661
679
|
raise
|
|
662
680
|
|
|
681
|
+
def _post_kill_recover(self) -> dict:
|
|
682
|
+
"""kill 之后的兜底恢复 (best-effort): 断电复位一次, 让目标离开半擦写/写中途态。
|
|
683
|
+
|
|
684
|
+
失败不上抛 (本身已在错误路径上), 结果并入错误信封的 post_kill_power_cycle 字段。
|
|
685
|
+
"""
|
|
686
|
+
try:
|
|
687
|
+
self.vbrt_reset(DEFAULT_OFF_MS)
|
|
688
|
+
return {"post_kill_power_cycle": "ok"}
|
|
689
|
+
except Exception as exc: # noqa: BLE001
|
|
690
|
+
return {"post_kill_power_cycle": f"failed: {type(exc).__name__}: {exc}"}
|
|
691
|
+
|
|
692
|
+
def _bridge_plan_json(self, plan: dict) -> str:
|
|
693
|
+
"""桥 flash action 的 stdin plan (只含桥认识的键)。"""
|
|
694
|
+
return json.dumps({
|
|
695
|
+
"off_ms": int(plan.get("off_ms", DEFAULT_OFF_MS)),
|
|
696
|
+
"erase_ms": int(plan.get("erase_ms", 2000)),
|
|
697
|
+
"page_gap_ms": int(plan.get("page_gap_ms", PAGE_WRITE_GAP_MS)),
|
|
698
|
+
"read_gap_ms": int(plan.get("read_gap_ms", PAGE_READ_GAP_MS)),
|
|
699
|
+
"writes": list(plan.get("writes", []) or []),
|
|
700
|
+
"windows": list(plan.get("windows", []) or []),
|
|
701
|
+
}, ensure_ascii=False)
|
|
702
|
+
|
|
703
|
+
def _bridge_flash_once(self, plan: dict) -> dict:
|
|
704
|
+
"""单次桥内单体烧录 (ndtdbg_bridge.ps1 -Action flash): 返回 data dict, 失败抛 NdtBoxError。
|
|
705
|
+
|
|
706
|
+
桥侧 #progress 行转发到 stderr (agent 可见进度), 末行 JSON 为结果 / 错误信封。
|
|
707
|
+
桥自身无超时 ⇒ 本层按 plan 推预算守护, 超时 kill 并报 BUS_TIMEOUT (不留孤儿进程)。
|
|
708
|
+
"""
|
|
709
|
+
import time
|
|
710
|
+
if not os.path.exists(PS32):
|
|
711
|
+
raise NdtBoxError("CONFIG_ERROR", f"32 位 PowerShell 不存在: {PS32}")
|
|
712
|
+
if not os.path.isfile(os.path.join(self.dll_dir, "USBIOX.DLL")):
|
|
713
|
+
raise NdtBoxError("CONFIG_ERROR", f"USBIOX.DLL 不存在: {self.dll_dir}",
|
|
714
|
+
"lab.yaml 的 ndtdbg.dll_dir 指向 NdtDebugTool 的 lib 目录")
|
|
715
|
+
args = [PS32, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass",
|
|
716
|
+
"-File", self.bridge_ps1, "-Action", "flash",
|
|
717
|
+
"-DllDir", self.dll_dir, "-SlaveAddr", str(self.slave_addr),
|
|
718
|
+
"-Speed", str(self.speed)]
|
|
719
|
+
pages = len(plan.get("writes") or [])
|
|
720
|
+
windows = len(plan.get("windows") or [])
|
|
721
|
+
# 预算: 页写/回读节奏 + 擦除 + 三次断电复位 + 固定裕量; plan["budget_ms"] 可覆盖 (测试用)
|
|
722
|
+
budget_ms = int(plan.get("budget_ms") or (
|
|
723
|
+
pages * (int(plan.get("page_gap_ms", PAGE_WRITE_GAP_MS)) + 60)
|
|
724
|
+
+ windows * (int(plan.get("read_gap_ms", PAGE_READ_GAP_MS)) + 40)
|
|
725
|
+
+ int(plan.get("erase_ms", 2000))
|
|
726
|
+
+ int(plan.get("off_ms", DEFAULT_OFF_MS)) * 3 + 30000))
|
|
727
|
+
t0 = time.monotonic()
|
|
728
|
+
proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
|
729
|
+
stderr=subprocess.PIPE, text=True, encoding="utf-8",
|
|
730
|
+
errors="replace", bufsize=1)
|
|
731
|
+
lines: list = []
|
|
732
|
+
state = {"last_progress": time.monotonic()}
|
|
733
|
+
|
|
734
|
+
def _reader() -> None:
|
|
735
|
+
try:
|
|
736
|
+
for raw in proc.stdout:
|
|
737
|
+
line = (raw or "").strip()
|
|
738
|
+
if not line:
|
|
739
|
+
continue
|
|
740
|
+
if line.startswith("#progress"):
|
|
741
|
+
state["last_progress"] = time.monotonic() # 进度续期 (stall 守护)
|
|
742
|
+
print(f"[flash] {line[len('#progress'):].strip()}",
|
|
743
|
+
file=sys.stderr, flush=True)
|
|
744
|
+
continue
|
|
745
|
+
if line.startswith("{"):
|
|
746
|
+
lines.append(line)
|
|
747
|
+
except Exception:
|
|
748
|
+
pass
|
|
749
|
+
|
|
750
|
+
reader = threading.Thread(target=_reader, daemon=True)
|
|
751
|
+
reader.start()
|
|
752
|
+
try:
|
|
753
|
+
try:
|
|
754
|
+
proc.stdin.write(self._bridge_plan_json(plan))
|
|
755
|
+
proc.stdin.close()
|
|
756
|
+
except Exception as exc:
|
|
757
|
+
proc.kill()
|
|
758
|
+
raise NdtBoxError("UNKNOWN_ERROR", f"向桥 flash 写入计划失败: {exc}") from exc
|
|
759
|
+
# 守护 = "无进度"判定, 而非固定总时长: 桥逐页/逐窗吐 #progress, 每次续期;
|
|
760
|
+
# 健康但慢的全片擦除 (长 erase_ms / 大镜像) 不会被误杀 (评审 3.2-①)。
|
|
761
|
+
# stall_s / hard_timeout_s 可按 plan 覆盖 (默认 30s 无进度判卡; 硬上限 3x 预算且 >=180s)
|
|
762
|
+
stall_s = max(1.0, float(plan.get("stall_s") or 30.0))
|
|
763
|
+
hard_s = float(plan.get("hard_timeout_s") or max(180.0, 3.0 * budget_ms / 1000.0))
|
|
764
|
+
hard_deadline = t0 + hard_s
|
|
765
|
+
while True:
|
|
766
|
+
if proc.poll() is not None and not reader.is_alive():
|
|
767
|
+
break
|
|
768
|
+
now = time.monotonic()
|
|
769
|
+
if now > hard_deadline:
|
|
770
|
+
proc.kill()
|
|
771
|
+
raise NdtBoxError(
|
|
772
|
+
"BUS_TIMEOUT",
|
|
773
|
+
f"桥内 flash 超过硬上限 (预算 {budget_ms}ms, {pages} 页/{windows} 窗): "
|
|
774
|
+
"已终止桥进程。检查目标是否卡在擦除/页写; 可先 fw_ndtdbg_power_cycle 复位",
|
|
775
|
+
None)
|
|
776
|
+
if now - state["last_progress"] > stall_s:
|
|
777
|
+
proc.kill()
|
|
778
|
+
recover = self._post_kill_recover()
|
|
779
|
+
raise NdtBoxError(
|
|
780
|
+
"INCOMPLETE_FLASH",
|
|
781
|
+
f"桥内 flash 连续 {int(stall_s)}s 无任何进度 ⇒ 目标疑似卡在写入中途。"
|
|
782
|
+
"已终止桥进程并尝试复位, 但**芯片可能处于半擦写状态, 请勿直接使用, "
|
|
783
|
+
"必须重新完整烧录**",
|
|
784
|
+
f"最后一条桥输出: {(lines[-1] if lines else '无')[:120]}",
|
|
785
|
+
{"engine": "bridge", "chip_state": "partially_erased",
|
|
786
|
+
"pages_written": pages, "read_windows": windows, **recover,
|
|
787
|
+
"hint": "重新调用 fw_ndtdbg_flash 完整烧录; 若反复卡住, 先 "
|
|
788
|
+
"fw_ndtdbg_power_cycle 复位再试"})
|
|
789
|
+
time.sleep(0.05)
|
|
790
|
+
elapsed_ms = round((time.monotonic() - t0) * 1000)
|
|
791
|
+
if not lines:
|
|
792
|
+
err = ""
|
|
793
|
+
try:
|
|
794
|
+
err = (proc.stderr.read() or "")[-300:]
|
|
795
|
+
except Exception:
|
|
796
|
+
pass
|
|
797
|
+
raise NdtBoxError("UNKNOWN_ERROR",
|
|
798
|
+
f"桥内 flash 未返回 JSON 结果 (exit={proc.returncode})", err or None)
|
|
799
|
+
try:
|
|
800
|
+
body = json.loads(lines[-1])
|
|
801
|
+
except ValueError as exc:
|
|
802
|
+
raise NdtBoxError("UNKNOWN_ERROR", f"桥内 flash 结果解析失败: {exc}",
|
|
803
|
+
lines[-1][:200]) from exc
|
|
804
|
+
if not body.get("ok"):
|
|
805
|
+
cls = body.get("error_class") or "UNKNOWN_ERROR"
|
|
806
|
+
msg = str(body.get("error") or "桥内 flash 失败")
|
|
807
|
+
detail = body.get("detail")
|
|
808
|
+
extra: dict = {"engine": "bridge"}
|
|
809
|
+
m = re.search(r"@0x([0-9A-Fa-f]{4})", msg)
|
|
810
|
+
if m:
|
|
811
|
+
extra["first_mismatch_offset"] = int(m.group(1), 16)
|
|
812
|
+
mm = re.search(r"expect=([0-9A-Fa-f]*) got=([0-9A-Fa-f]*)", str(detail or ""))
|
|
813
|
+
if mm:
|
|
814
|
+
extra["first_mismatch_expect"] = mm.group(1).upper()
|
|
815
|
+
extra["first_mismatch_got"] = mm.group(2).upper()
|
|
816
|
+
raise NdtBoxError(cls, msg, detail, extra)
|
|
817
|
+
data = body.get("data") or {}
|
|
818
|
+
data["elapsed_ms"] = elapsed_ms
|
|
819
|
+
return data
|
|
820
|
+
finally:
|
|
821
|
+
try:
|
|
822
|
+
if proc.poll() is None:
|
|
823
|
+
proc.kill()
|
|
824
|
+
except Exception:
|
|
825
|
+
pass
|
|
826
|
+
|
|
827
|
+
def _flash_exec_bridge(self, plan: dict) -> dict:
|
|
828
|
+
"""桥内单体 flash 引擎 (0.7.2 起为默认): 单进程内 USBIOX(0) 与 USB2IO(1) 句柄同持,
|
|
829
|
+
|
|
830
|
+
帧经 stdin 一次性传入、全程连续无逐笔管道往返 —— 即原厂 GUI 的进程模型, 也是
|
|
831
|
+
现场 (2026-09-11 F72) 6/6 verify pass 的那条路径。校验失败 (桥报
|
|
832
|
+
TARGET_MISMATCH "烧录校验失败") 时按 rewrite_times 整片重跑, 其余错误直接上抛。
|
|
833
|
+
"""
|
|
834
|
+
import time
|
|
835
|
+
rewrite_times = max(0, int(plan.get("rewrite_times", _REWRITE_TIMES)))
|
|
836
|
+
t_all = time.monotonic()
|
|
837
|
+
attempts_detail: list = []
|
|
838
|
+
for attempt in range(rewrite_times + 1):
|
|
839
|
+
try:
|
|
840
|
+
data = self._bridge_flash_once(plan)
|
|
841
|
+
except NdtBoxError as exc:
|
|
842
|
+
attempts_detail.append({
|
|
843
|
+
"attempt": attempt + 1, "ok": False, "error_class": exc.error_class,
|
|
844
|
+
"first_mismatch_offset": exc.extra.get("first_mismatch_offset"),
|
|
845
|
+
"first_mismatch_expect": exc.extra.get("first_mismatch_expect"),
|
|
846
|
+
"first_mismatch_got": exc.extra.get("first_mismatch_got")})
|
|
847
|
+
if (exc.error_class == "TARGET_MISMATCH" and "校验失败" in exc.message
|
|
848
|
+
and attempt < rewrite_times):
|
|
849
|
+
continue # 整片重写 (桥内每次都是完整擦写)
|
|
850
|
+
raise NdtBoxError(
|
|
851
|
+
exc.error_class, exc.message, exc.detail,
|
|
852
|
+
{**exc.extra, "engine": "bridge", "attempts": attempt + 1,
|
|
853
|
+
"attempts_detail": attempts_detail,
|
|
854
|
+
"stage_timings": {"total_ms": round((time.monotonic() - t_all) * 1000)}})
|
|
855
|
+
attempts_detail.append({"attempt": attempt + 1, "ok": True,
|
|
856
|
+
"elapsed_ms": data.get("elapsed_ms"),
|
|
857
|
+
"verify": data.get("verify"),
|
|
858
|
+
"pages_written": data.get("pages_written")})
|
|
859
|
+
total_ms = round((time.monotonic() - t_all) * 1000)
|
|
860
|
+
return {
|
|
861
|
+
"verify": data.get("verify", "pass"),
|
|
862
|
+
"chip_state": "verified" if data.get("verify", "pass") == "pass" else "unknown",
|
|
863
|
+
"pages_written": data.get("pages_written"),
|
|
864
|
+
"read_windows": data.get("read_windows"),
|
|
865
|
+
"rewrite_count": attempt,
|
|
866
|
+
"attempts": attempt + 1,
|
|
867
|
+
"attempts_detail": attempts_detail,
|
|
868
|
+
"engine": "bridge",
|
|
869
|
+
"boot_judge": "n/a (bridge engine: 桥内无探测事务, 逐窗校验为唯一判据)",
|
|
870
|
+
"boot_evidence": "not_evaluated",
|
|
871
|
+
"probe_hex": None,
|
|
872
|
+
"probe_before_hex": None,
|
|
873
|
+
"off_ms": int(plan.get("off_ms", DEFAULT_OFF_MS)),
|
|
874
|
+
"stage_timings": {"total_ms": total_ms},
|
|
875
|
+
"total_ms": total_ms,
|
|
876
|
+
}
|
|
877
|
+
raise NdtBoxError("UNKNOWN_ERROR", "flash_exec(bridge) 未产出结果", None) # pragma: no cover
|
|
878
|
+
|
|
663
879
|
def flash_exec(self, plan: dict, timeout_ms: int | None = None) -> dict:
|
|
880
|
+
"""烧录引擎分派: "bridge" (默认, 桥内单体 flash) / "serve" (逐笔 Python 驱动)。
|
|
881
|
+
|
|
882
|
+
现场实证 (2026-09-11, F72, 同一批固件 + 同一台设备):
|
|
883
|
+
桥内单体 flash (帧经 stdin 一次传入) -> 6/6 {"ok":true,"verify":"pass"}
|
|
884
|
+
逐笔 serve 路径 (每页一笔 raw 事务) -> 100% "擦除生效但页写不落地"
|
|
885
|
+
(probe FFFFFFFF -> 00000000 说明 7 字节擦除帧到达; 99 页 write_ms 7594ms
|
|
886
|
+
≈ 77ms/页; 校验读回全 FF)
|
|
887
|
+
两条路径的**帧完全相同** (build_page_write_frame, 命令行核对无误), 故差异在
|
|
888
|
+
进程/传输模型而非帧组装 ⇒ 默认走桥内单体, serve 引擎保留供 A/B 复现与排查。
|
|
889
|
+
"""
|
|
890
|
+
engine = str(plan.get("engine", "bridge") or "bridge").lower()
|
|
891
|
+
if engine == "bridge":
|
|
892
|
+
return self._flash_exec_bridge(plan)
|
|
893
|
+
if engine == "serve":
|
|
894
|
+
return self._flash_exec_serve(plan)
|
|
895
|
+
raise NdtBoxError("CONFIG_ERROR", "flash engine 非法 (bridge/serve)", engine)
|
|
896
|
+
|
|
897
|
+
def _flash_exec_serve(self, plan: dict, timeout_ms: int | None = None) -> dict:
|
|
664
898
|
"""Python 驱动整条 UpdateFW 序列 (0.4.0 serve 化): usb2io 断电复位进 boot +
|
|
665
899
|
擦除 -> 页写 -> 回读校验 -> 完成魔数, 全部 I2C 事务经 serve 会话 (同进程同
|
|
666
900
|
会话连续, 复刻原厂 GUI 进程模型)。校验 (逐窗 vs expect_hex) 在本模块完成,
|
|
@@ -1190,9 +1424,61 @@ class ChipSeaFxx:
|
|
|
1190
1424
|
|
|
1191
1425
|
# -- 固件烧录 (对齐 ChipSea.cs UpdateFW: 仅芯海 Fxx, 整片擦写) --
|
|
1192
1426
|
|
|
1427
|
+
def cold_boot_check(self, off_ms: int = DEFAULT_OFF_MS, reg: int = 0x10,
|
|
1428
|
+
expect: str | None = None) -> dict:
|
|
1429
|
+
"""烧后冷启动冒烟 (评审 §4): 断电重上电 -> 读已知寄存器 -> 判定固件是否真的跑起来。
|
|
1430
|
+
|
|
1431
|
+
只校验 Flash 字节的流程抓不到"镜像烧对了但跑不起来"——现场 `.18` 正是: GUI 报
|
|
1432
|
+
`FW Upgrade Success` 且当场可读, 断电重上电后 `Fw_ver = -1`。这里 fail-closed:
|
|
1433
|
+
expect 给定时逐字节比对; 未给定时判"有无效应答"(读不到或全 00/FF 都算失败)。
|
|
1434
|
+
"""
|
|
1435
|
+
import time
|
|
1436
|
+
self._io.vbrt_reset(off_ms) # 冷启动 (真 POR 上电)
|
|
1437
|
+
time.sleep(0.3) # 让固件跑到能响应从机的程度
|
|
1438
|
+
want = bytes.fromhex(str(expect).replace(" ", "")) if expect else None
|
|
1439
|
+
raw: bytes | None = None
|
|
1440
|
+
err: str | None = None
|
|
1441
|
+
for _ in range(3):
|
|
1442
|
+
try:
|
|
1443
|
+
raw = self._io.read_reg(reg, len(want) if want else 4)
|
|
1444
|
+
break
|
|
1445
|
+
except NdtBoxError as exc:
|
|
1446
|
+
err = f"{exc.error_class}: {exc.message}"
|
|
1447
|
+
time.sleep(0.2)
|
|
1448
|
+
out: dict = {"checked": True, "reg": f"0x{reg:02X}",
|
|
1449
|
+
"raw_hex": raw.hex().upper() if raw else None,
|
|
1450
|
+
"expect_hex": want.hex().upper() if want else None,
|
|
1451
|
+
"read_error": err}
|
|
1452
|
+
if raw is None:
|
|
1453
|
+
out["ok"] = False
|
|
1454
|
+
out["conclusion"] = ("冷启动后该寄存器无应答: 固件可能未起振/未使能 I2C 从机 "
|
|
1455
|
+
"—— Flash 字节已验证, 但目标跑不起来 (现场 .18 类问题的特征)")
|
|
1456
|
+
return out
|
|
1457
|
+
if want is not None:
|
|
1458
|
+
if raw[:len(want)] != want:
|
|
1459
|
+
out["ok"] = False
|
|
1460
|
+
out["conclusion"] = (f"冷启动后 {out['reg']} 读回 {out['raw_hex']} "
|
|
1461
|
+
f"!= 期望 {out['expect_hex']}")
|
|
1462
|
+
return out
|
|
1463
|
+
out["ok"] = True
|
|
1464
|
+
out["conclusion"] = f"冷启动读回与期望一致 ({out['raw_hex']})"
|
|
1465
|
+
return out
|
|
1466
|
+
if all(b in (0x00, 0xFF) for b in raw):
|
|
1467
|
+
out["ok"] = False
|
|
1468
|
+
out["conclusion"] = (f"冷启动后 {out['reg']} 读回全 00/FF ({out['raw_hex']}): 无有效应答 "
|
|
1469
|
+
"—— 疑似固件未起振; 若该寄存器本就不该有内容, 请用 cold_boot_expect "
|
|
1470
|
+
"指定期望值或关闭 cold_boot_check")
|
|
1471
|
+
return out
|
|
1472
|
+
out["ok"] = True
|
|
1473
|
+
out["conclusion"] = f"冷启动读回 {out['raw_hex']} (有有效应答)"
|
|
1474
|
+
return out
|
|
1475
|
+
|
|
1193
1476
|
def flash_bin(self, file_path: str, erase_ms: int = 2000,
|
|
1194
1477
|
off_ms: int | None = None, rewrite_times: int | None = None,
|
|
1195
|
-
boot_judge: str | None = None,
|
|
1478
|
+
boot_judge: str | None = None, engine: str | None = None,
|
|
1479
|
+
cold_boot_check: bool = True, cold_boot_reg: int = 0x10,
|
|
1480
|
+
cold_boot_expect: str | None = None,
|
|
1481
|
+
progress=None) -> dict:
|
|
1196
1482
|
"""经 NdtBox IIC 烧录 .bin/.nfw 固件到芯海 Fxx (UpdateFW 语义)。
|
|
1197
1483
|
|
|
1198
1484
|
时序逐行对齐 ChipSea.cs UpdateFW, 进程模型对齐原厂 STDataCollection GUI:
|
|
@@ -1221,6 +1507,7 @@ class ChipSeaFxx:
|
|
|
1221
1507
|
"read_gap_ms": PAGE_READ_GAP_MS,
|
|
1222
1508
|
"rewrite_times": _REWRITE_TIMES if rewrite_times is None else max(0, int(rewrite_times)),
|
|
1223
1509
|
"boot_judge": str(boot_judge or "diff").lower(),
|
|
1510
|
+
"engine": str(engine or "bridge").lower(),
|
|
1224
1511
|
"writes": [build_page_write_frame(off, fw[off:off + FLASH_WRITE_PAGE]).hex()
|
|
1225
1512
|
for off in pages],
|
|
1226
1513
|
"windows": [{"off": off, "expect_hex": expected_read_window(fw, off).hex()}
|
|
@@ -1229,6 +1516,22 @@ class ChipSeaFxx:
|
|
|
1229
1516
|
res = self._io.flash_exec(plan)
|
|
1230
1517
|
if progress:
|
|
1231
1518
|
progress("verify", len(windows), len(windows))
|
|
1519
|
+
# 冷启动冒烟 (评审 §4, 默认开): Flash 字节校验通过 ≠ 固件跑得起来
|
|
1520
|
+
cold: dict | None = None
|
|
1521
|
+
if cold_boot_check and res.get("verify", "pass") == "pass":
|
|
1522
|
+
cold = self.cold_boot_check(off_ms=plan["off_ms"], reg=int(cold_boot_reg),
|
|
1523
|
+
expect=cold_boot_expect)
|
|
1524
|
+
if not cold.get("ok"):
|
|
1525
|
+
raise NdtBoxError(
|
|
1526
|
+
"COLD_BOOT_VERIFY_FAILED",
|
|
1527
|
+
f"烧录逐窗校验通过, 但冷启动冒烟失败: {cold.get('conclusion')}",
|
|
1528
|
+
"Flash 字节已写入并通过回读校验; 失败发生在'断电重上电后能否工作'这一步",
|
|
1529
|
+
{"verify": "pass", "engine": res.get("engine", plan["engine"]),
|
|
1530
|
+
"pages_written": len(pages), "window_verified": True,
|
|
1531
|
+
"cold_boot": cold,
|
|
1532
|
+
"hint": "①确认目标固件在本寄存器上确有可读内容 (否则用 cold_boot_expect 指定)"
|
|
1533
|
+
"; ②按现场 .18 类问题排查冷启动路径 (看门狗/时钟/外设初始化); "
|
|
1534
|
+
"③如确不需要该校验, 用 cold_boot_check=false / --no-cold-boot-check 关闭"})
|
|
1232
1535
|
return {
|
|
1233
1536
|
"file": file_path,
|
|
1234
1537
|
"file_type": fw_type,
|
|
@@ -1237,13 +1540,17 @@ class ChipSeaFxx:
|
|
|
1237
1540
|
"read_windows": len(windows),
|
|
1238
1541
|
"erase_ms": int(erase_ms),
|
|
1239
1542
|
"off_ms": plan["off_ms"],
|
|
1543
|
+
"chip_state": res.get("chip_state"),
|
|
1544
|
+
"cold_boot": cold,
|
|
1240
1545
|
"rewrite_times": plan["rewrite_times"],
|
|
1241
|
-
"
|
|
1546
|
+
"engine": res.get("engine", plan["engine"]),
|
|
1547
|
+
"boot_judge": res.get("boot_judge", plan["boot_judge"]),
|
|
1242
1548
|
"boot_evidence": res.get("boot_evidence"),
|
|
1243
1549
|
"probe_hex": res.get("probe_hex"),
|
|
1244
1550
|
"probe_before_hex": res.get("probe_before_hex"),
|
|
1245
1551
|
"rewrite_count": res.get("rewrite_count", 0),
|
|
1246
1552
|
"attempts": res.get("attempts", 1),
|
|
1553
|
+
"attempts_detail": res.get("attempts_detail"),
|
|
1247
1554
|
"stage_timings": res.get("stage_timings"),
|
|
1248
1555
|
"verify": res.get("verify", "pass"),
|
|
1249
1556
|
"duration_ms": int((time.monotonic() - started) * 1000),
|
|
@@ -994,6 +994,122 @@ class SerialSession:
|
|
|
994
994
|
return out
|
|
995
995
|
|
|
996
996
|
|
|
997
|
+
_PORT_HOG_HINTS = ("stdatacollection", "ndtdebug", "ndt debug", "serialassistant", "sscom",
|
|
998
|
+
"comassistant", "putty", "xshell", "securecrt", "minicom", "logic", "saleae")
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
def suspected_port_holders(session_pid: int | None = None) -> list[dict]:
|
|
1002
|
+
"""列出可能占着串口的本机进程 (tasklist 扫描, best-effort; 失败返回空列表)。
|
|
1003
|
+
|
|
1004
|
+
Windows 没有便宜的"谁持有 COMx"API, 但现场 90% 的 PermissionError(13) 都是
|
|
1005
|
+
NDT Debug Tool GUI (STDataCollection.exe) 或残留的 fwloop serve 会话 —— 直接给
|
|
1006
|
+
出嫌疑名单比只报一句 PermissionError 更有用。session_pid 用于把"本会话 serve"
|
|
1007
|
+
与"其它 python (很可能是 MCP server, 勿盲杀)"区分开。
|
|
1008
|
+
"""
|
|
1009
|
+
out: list[dict] = []
|
|
1010
|
+
if os.name != "nt":
|
|
1011
|
+
return out
|
|
1012
|
+
try:
|
|
1013
|
+
res = subprocess.run(["tasklist", "/FO", "CSV", "/NH"], capture_output=True,
|
|
1014
|
+
text=True, timeout=15, errors="replace")
|
|
1015
|
+
except Exception: # noqa: BLE001
|
|
1016
|
+
return out
|
|
1017
|
+
self_pid = os.getpid()
|
|
1018
|
+
for line in (res.stdout or "").splitlines():
|
|
1019
|
+
cols = [c.strip().strip('"') for c in line.split('","')]
|
|
1020
|
+
if len(cols) < 2:
|
|
1021
|
+
continue
|
|
1022
|
+
name, pid_s = cols[0], cols[1]
|
|
1023
|
+
try:
|
|
1024
|
+
pid = int(pid_s)
|
|
1025
|
+
except ValueError:
|
|
1026
|
+
continue
|
|
1027
|
+
low = name.lower()
|
|
1028
|
+
if any(k in low for k in _PORT_HOG_HINTS):
|
|
1029
|
+
out.append({"name": name, "pid": pid,
|
|
1030
|
+
"why": "GUI/上位机软件可能独占串口 (关闭后再重试)"})
|
|
1031
|
+
elif low.startswith("python") and pid not in (self_pid, session_pid):
|
|
1032
|
+
out.append({"name": name, "pid": pid,
|
|
1033
|
+
"why": "python 进程 (可能是残留 serve 会话; 若为 MCP server 请勿终止)"})
|
|
1034
|
+
if session_pid:
|
|
1035
|
+
out = [h for h in out if h["pid"] != session_pid]
|
|
1036
|
+
out.append({"name": "(本会话 serve)", "pid": session_pid, "why": "正常: fw_serial_close 会回收"})
|
|
1037
|
+
return out
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
def port_exclusive_probe(port: str | None, baud: int = 115200) -> dict:
|
|
1041
|
+
"""直接试开端口 ⇒ 给出"当前能否独占打开"的**硬结论**(评审 3.2-②)。
|
|
1042
|
+
|
|
1043
|
+
`tasklist` 看不到 COM 端口持有者(进程加载了模块 ≠ 打开了端口),任何进程名单都只是
|
|
1044
|
+
推断;试开才是判据。返回 {port, openable, error, conclusion}。
|
|
1045
|
+
"""
|
|
1046
|
+
if not port:
|
|
1047
|
+
return {"port": None, "openable": None, "error": "未指定端口",
|
|
1048
|
+
"conclusion": "无端口可探测 (未配置 serial.port)"}
|
|
1049
|
+
try:
|
|
1050
|
+
import serial as pyserial
|
|
1051
|
+
except ImportError as exc: # noqa: BLE001
|
|
1052
|
+
return {"port": port, "openable": None, "error": f"pyserial 未安装: {exc}",
|
|
1053
|
+
"conclusion": "无法探测 (缺 pyserial)"}
|
|
1054
|
+
ser = None
|
|
1055
|
+
try:
|
|
1056
|
+
ser = pyserial.Serial(port=port, baudrate=int(baud), timeout=0.2, write_timeout=0.5)
|
|
1057
|
+
return {"port": port, "openable": True, "error": None,
|
|
1058
|
+
"conclusion": f"{port} 当前可被本进程独占打开 ⇒ 若会话仍读不到数据, "
|
|
1059
|
+
"原因不在端口占用 (检查波特率/接线/目标是否在输出)"}
|
|
1060
|
+
except Exception as exc: # noqa: BLE001
|
|
1061
|
+
return {"port": port, "openable": False,
|
|
1062
|
+
"error": f"{type(exc).__name__}: {exc}",
|
|
1063
|
+
"conclusion": f"{port} 当前无法独占打开 ⇒ 被其它程序占用或设备不在位"}
|
|
1064
|
+
finally:
|
|
1065
|
+
try:
|
|
1066
|
+
if ser is not None:
|
|
1067
|
+
ser.close()
|
|
1068
|
+
except Exception: # noqa: BLE001
|
|
1069
|
+
pass
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
def port_holder_candidates(port: str | None, session_pid: int | None = None) -> list[dict]:
|
|
1073
|
+
"""端口占用**候选名单**(需人工确认;候选 ≠ 持有者)。
|
|
1074
|
+
|
|
1075
|
+
两个来源, 按置信度标注:
|
|
1076
|
+
- `source="cmdline"`(较准): Win32_Process 命令行含端口名 ⇒ 该进程可能在用这个口;
|
|
1077
|
+
- `source="name"`(较低): 进程名像 GUI/上位机/残留 python serve。
|
|
1078
|
+
**硬结论请看 port_exclusive_probe()。**
|
|
1079
|
+
"""
|
|
1080
|
+
out: list[dict] = []
|
|
1081
|
+
if os.name != "nt":
|
|
1082
|
+
return out
|
|
1083
|
+
self_pid = os.getpid()
|
|
1084
|
+
if port:
|
|
1085
|
+
try:
|
|
1086
|
+
ps = ("Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -like "
|
|
1087
|
+
f"'*{port}*' }} | Select-Object -First 12 ProcessId,Name,CommandLine | "
|
|
1088
|
+
"ConvertTo-Json -Compress")
|
|
1089
|
+
res = subprocess.run(["powershell", "-NoProfile", "-NonInteractive", "-Command", ps],
|
|
1090
|
+
capture_output=True, text=True, timeout=30, errors="replace")
|
|
1091
|
+
raw = (res.stdout or "").strip()
|
|
1092
|
+
if raw:
|
|
1093
|
+
data = json.loads(raw)
|
|
1094
|
+
if isinstance(data, dict):
|
|
1095
|
+
data = [data]
|
|
1096
|
+
for item in data:
|
|
1097
|
+
pid = int(item.get("ProcessId") or 0)
|
|
1098
|
+
if pid in (self_pid, session_pid):
|
|
1099
|
+
continue
|
|
1100
|
+
out.append({"name": item.get("Name") or "?", "pid": pid,
|
|
1101
|
+
"why": f"命令行含 {port}", "source": "cmdline",
|
|
1102
|
+
"confidence": "medium", "cmdline": (item.get("CommandLine") or "")[:200]})
|
|
1103
|
+
except Exception: # noqa: BLE001
|
|
1104
|
+
pass
|
|
1105
|
+
known = {h["pid"] for h in out}
|
|
1106
|
+
for h in suspected_port_holders(session_pid):
|
|
1107
|
+
if h["pid"] in known or h["pid"] == self_pid:
|
|
1108
|
+
continue
|
|
1109
|
+
out.append({**h, "source": "name", "confidence": "low"})
|
|
1110
|
+
return out
|
|
1111
|
+
|
|
1112
|
+
|
|
997
1113
|
def pid_alive(pid: int | None) -> bool:
|
|
998
1114
|
"""进程存活探测。
|
|
999
1115
|
|
|
@@ -249,9 +249,17 @@ def cmd_status(io: NdtBoxIo) -> None:
|
|
|
249
249
|
# P2-1 分层判据表: 把"全 FF/无应答"的几种成因摊开, 避免一句 hint 把人带偏
|
|
250
250
|
data["diagnosis_table"] = [
|
|
251
251
|
{"symptom": "能读到任一已知寄存器", "likely": "从机在跑, 链路正常 (判活以此为准)"},
|
|
252
|
-
{"symptom": "读回全 FF/FE、无异常",
|
|
252
|
+
{"symptom": "读回全 FF/FE、无异常",
|
|
253
|
+
"likely": "①目标固件未使能 I2C 从机 (最常见, 与掉电现象一致) ②目标掉电 ③从机地址不符"},
|
|
253
254
|
{"symptom": "TARGET_MISMATCH: IIC 事务无应答",
|
|
254
255
|
"likely": "地址未被 ACK (外设未使能/复位中/芯片未上电)"},
|
|
256
|
+
{"symptom": "只有写事务 NACK, 读事务正常",
|
|
257
|
+
"likely": "不是从机死: 该寄存器不可写/写保护, 或目标固件未实现该写寄存器 "
|
|
258
|
+
"(此时应回读邻近寄存器确认链路仍活)"},
|
|
259
|
+
{"symptom": "目标固件刚被改动过",
|
|
260
|
+
"likely": "按序排除: ①从机是否真的使能 (初始化是否提前 return); ②冷启动 vs 热复位"
|
|
261
|
+
"行为差异 (热复位可读、断电重上电读不到属另一类问题); ③改动静态寄存器表/"
|
|
262
|
+
"RAM 布局后整套读取是否仍正常 (表必须按 addr 升序, 且不与 0x0000 冲突)"},
|
|
255
263
|
{"symptom": "BUS_TIMEOUT", "likely": "时钟拉伸、关中断死循环 (fault handler 自旋饿死 I2C 中断)"},
|
|
256
264
|
]
|
|
257
265
|
ok("status", data, log="Open + ReadFwVersion(0x10) + ReadModuleConnect(0x29)")
|
|
@@ -288,9 +296,15 @@ def cmd_read_reg(io: NdtBoxIo, reg: int, length: int, retry: int = 0) -> None:
|
|
|
288
296
|
"io_ms": round((time.monotonic() - t0) * 1000, 1),
|
|
289
297
|
"retries": attempts - 1}
|
|
290
298
|
if data and all(b in (0xFF, 0xFE) for b in data):
|
|
291
|
-
# 总线无应答时上拉/悬空读回默认电平,
|
|
292
|
-
|
|
293
|
-
|
|
299
|
+
# 总线无应答时上拉/悬空读回默认电平, 不能当作真实寄存器值误导调用方。
|
|
300
|
+
# P2-1: 第一候选是"目标固件没使能从机"(现象与掉电完全一样), 而不是硬件掉了
|
|
301
|
+
body["warning"] = ("读回全部 0xFF/0xFE: 疑似 IIC 目标无应答。第一候选是【目标固件"
|
|
302
|
+
"根本没使能 I2C 从机】(从机表初始化提前 return / 未注册), 现象与掉电"
|
|
303
|
+
"完全一样; 其次才是掉电/接线/上拉/从机地址。可参考 fw_ndtdbg_status "
|
|
304
|
+
"的 diagnosis_table 逐条排除")
|
|
305
|
+
body["candidates"] = ["目标固件未使能 I2C 从机 (最常见, 现象与掉电一致)",
|
|
306
|
+
"目标掉电 / 复位中", "接线/上拉/供电异常",
|
|
307
|
+
"从机地址不符 (lab.yaml ndtdbg.slave_addr)"]
|
|
294
308
|
ok("read-reg", body, log=f"ReadReg(0x{reg:02X}, {length})")
|
|
295
309
|
|
|
296
310
|
|
|
@@ -505,7 +519,9 @@ def cmd_stream(io: NdtBoxIo, config: dict, specs: list, interval_ms, duration_s:
|
|
|
505
519
|
|
|
506
520
|
def cmd_flash_bin(io: NdtBoxIo, config: dict, file_path: str, erase_ms: int, confirm: bool,
|
|
507
521
|
off_ms: int | None = None, rewrite_times: int | None = None,
|
|
508
|
-
boot_judge: str | None = None
|
|
522
|
+
boot_judge: str | None = None, engine: str | None = None,
|
|
523
|
+
cold_boot_check: bool | None = None, cold_boot_reg: int | None = None,
|
|
524
|
+
cold_boot_expect: str | None = None) -> None:
|
|
509
525
|
# 烧录 = 整片擦除 + 页写, 破坏性高于 write-reg, 同款双闸门
|
|
510
526
|
ndt_cfg = config.get("ndtdbg") or {}
|
|
511
527
|
allowed = ndt_cfg.get("write_allowed", False)
|
|
@@ -524,20 +540,33 @@ def cmd_flash_bin(io: NdtBoxIo, config: dict, file_path: str, erase_ms: int, con
|
|
|
524
540
|
# 目标时, 用 off 让页写后的逐窗校验做唯一判据 —— 即桥内单体 flash 的语义)
|
|
525
541
|
if boot_judge is None:
|
|
526
542
|
boot_judge = flash_cfg.get("boot_judge")
|
|
543
|
+
# 0.7.2: 烧录引擎 (bridge 默认 = 桥内单体 flash; serve = 逐笔 Python 驱动, 供 A/B 复现)
|
|
544
|
+
if engine is None:
|
|
545
|
+
engine = flash_cfg.get("engine")
|
|
546
|
+
# 冷启动冒烟 (评审 §4): 默认开; lab.yaml ndtdbg.flash.cold_boot_check / reg / expect 可覆盖
|
|
547
|
+
if cold_boot_check is None:
|
|
548
|
+
cold_boot_check = flash_cfg.get("cold_boot_check", True)
|
|
549
|
+
if cold_boot_reg is None:
|
|
550
|
+
cold_boot_reg = flash_cfg.get("cold_boot_reg", 0x10)
|
|
551
|
+
if cold_boot_expect is None:
|
|
552
|
+
cold_boot_expect = flash_cfg.get("cold_boot_expect")
|
|
527
553
|
|
|
528
554
|
def progress(phase: str, done: int, total: int) -> None:
|
|
529
555
|
print(f"[flash-bin] {phase} {done}/{total}", file=sys.stderr, flush=True)
|
|
530
556
|
|
|
531
557
|
result = ChipSeaFxx(io).flash_bin(file_path, erase_ms=erase_ms, off_ms=off_ms,
|
|
532
558
|
rewrite_times=rewrite_times, boot_judge=boot_judge,
|
|
559
|
+
engine=engine, cold_boot_check=bool(cold_boot_check),
|
|
560
|
+
cold_boot_reg=int(cold_boot_reg),
|
|
561
|
+
cold_boot_expect=cold_boot_expect,
|
|
533
562
|
progress=progress)
|
|
534
563
|
result["authorization"] = {"write_allowed": True,
|
|
535
564
|
"granted_by": write_allowed_source() or "(default false)",
|
|
536
565
|
"chain": list(_CONFIG_FILES)}
|
|
537
566
|
ok("flash-bin", result,
|
|
538
567
|
log=f"UpdateFW({file_path}): {result['fw_len']}B, {result['pages_written']} pages, "
|
|
539
|
-
f"
|
|
540
|
-
f"
|
|
568
|
+
f"engine={result.get('engine')}, off_ms={result.get('off_ms')}, "
|
|
569
|
+
f"rewrite={result.get('rewrite_count', 0)}, verify={result['verify']}")
|
|
541
570
|
|
|
542
571
|
|
|
543
572
|
# --------------------------------------------------------------------------- main
|
|
@@ -590,7 +619,20 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
590
619
|
help="校验不一致时整片重写次数上限 (默认对齐 ChipSea.cs 的 3; 0=不重写)")
|
|
591
620
|
f.add_argument("--boot-judge", choices=["diff", "off"], default=None,
|
|
592
621
|
help="boot 判据 (默认 diff: 只有'擦除魔数前后同一条非平凡应答'才熔断; "
|
|
593
|
-
"off: 完全关闭探测判据, 仅记录证据, 由逐窗校验做唯一判据)"
|
|
622
|
+
"off: 完全关闭探测判据, 仅记录证据, 由逐窗校验做唯一判据); "
|
|
623
|
+
"仅 serve 引擎适用")
|
|
624
|
+
f.add_argument("--flash-engine", choices=["bridge", "serve"], default=None,
|
|
625
|
+
help="烧录引擎 (默认 bridge = 桥内单体 flash: 单进程、帧经 stdin 一次传入、"
|
|
626
|
+
"现场 6/6 verify pass; serve = 逐笔 raw 事务的 Python 驱动, 供 A/B 复现)")
|
|
627
|
+
f.add_argument("--cold-boot-check", dest="cold_boot_check", action="store_true", default=None,
|
|
628
|
+
help="烧后冷启动冒烟 (默认开): 断电重上电 -> 读 cold-boot-reg -> 判定固件是否"
|
|
629
|
+
"真的跑起来; 失败报 COLD_BOOT_VERIFY_FAILED (Flash 字节已通过校验)")
|
|
630
|
+
f.add_argument("--no-cold-boot-check", dest="cold_boot_check", action="store_false",
|
|
631
|
+
help="关闭冷启动冒烟")
|
|
632
|
+
f.add_argument("--cold-boot-reg", type=lambda x: int(x, 0), default=None,
|
|
633
|
+
help="冷启动冒烟读的寄存器 (默认 0x10 版本寄存器)")
|
|
634
|
+
f.add_argument("--cold-boot-expect", default=None,
|
|
635
|
+
help="冷启动冒烟期望值 (hex, 如 '51 17 64 11'); 不传则只判'有无效应答'")
|
|
594
636
|
|
|
595
637
|
st = sub.add_parser("stream", parents=[common],
|
|
596
638
|
help="高速连续采集寄存器组到 CSV (单会话长驻, 只读)")
|
|
@@ -651,7 +693,10 @@ def main(argv=None) -> None:
|
|
|
651
693
|
elif args.cmd == "flash-bin":
|
|
652
694
|
cmd_flash_bin(io, config, args.file, args.erase_ms, args.confirm,
|
|
653
695
|
off_ms=args.off_ms, rewrite_times=args.rewrite_times,
|
|
654
|
-
boot_judge=args.boot_judge
|
|
696
|
+
boot_judge=args.boot_judge, engine=args.flash_engine,
|
|
697
|
+
cold_boot_check=args.cold_boot_check,
|
|
698
|
+
cold_boot_reg=args.cold_boot_reg,
|
|
699
|
+
cold_boot_expect=args.cold_boot_expect)
|
|
655
700
|
elif args.cmd == "stream":
|
|
656
701
|
specs = [parse_reg_spec(s) for s in args.regs]
|
|
657
702
|
cmd_stream(io, config, specs, args.interval_ms, args.duration_s,
|
|
@@ -36,6 +36,9 @@ from lib.serial_assistant import ( # noqa: E402
|
|
|
36
36
|
parse_hex,
|
|
37
37
|
probe_session,
|
|
38
38
|
to_hex,
|
|
39
|
+
port_exclusive_probe,
|
|
40
|
+
port_holder_candidates,
|
|
41
|
+
suspected_port_holders,
|
|
39
42
|
wait_pid_exit,
|
|
40
43
|
)
|
|
41
44
|
|
|
@@ -122,6 +125,10 @@ def cmd_status(_args: argparse.Namespace) -> None:
|
|
|
122
125
|
"started_at": stats.get("started_at")},
|
|
123
126
|
"conclusion": f"会话存活 (port={sess.get('port') or stats.get('port')}, "
|
|
124
127
|
f"opened={alive})" if alive else "serve 进程存活但串口未打开",
|
|
128
|
+
# P1-4 / 评审 3.2-②: 先给硬结论 (端口能否独占打开), 再给需人工确认的候选名单
|
|
129
|
+
"port_probe": port_exclusive_probe(sess.get("port") or stats.get("port")),
|
|
130
|
+
"holder_candidates": port_holder_candidates(sess.get("port") or stats.get("port"),
|
|
131
|
+
sess.get("pid")),
|
|
125
132
|
})
|
|
126
133
|
|
|
127
134
|
|
|
@@ -149,6 +156,8 @@ def cmd_open(args: argparse.Namespace) -> None:
|
|
|
149
156
|
"holder_hint",
|
|
150
157
|
"端口可能被 GUI 上位机占用: NDT Debug Tool (STDataCollection.exe) 打开时会同时占用 "
|
|
151
158
|
"Box 串口与 USB-IIC 通道; 请关闭占用方后重试, 残留会话可用 fw_serial_close 清理")
|
|
159
|
+
extra.setdefault("port_probe", port_exclusive_probe(cfg.get("port")))
|
|
160
|
+
extra.setdefault("holder_candidates", port_holder_candidates(cfg.get("port")))
|
|
152
161
|
fail(exc.error_class, exc.detail, extra=extra)
|
|
153
162
|
data = {k: info.get(k) for k in
|
|
154
163
|
("port", "baud", "simulated", "log_path", "reused", "pid", "started_at")}
|
|
@@ -212,7 +221,7 @@ def cmd_send(args: argparse.Namespace) -> None:
|
|
|
212
221
|
time.sleep(delay / 1000.0)
|
|
213
222
|
stats = session.stats()
|
|
214
223
|
except SerialAssistantError as exc:
|
|
215
|
-
fail(exc.error_class, exc.detail, extra=exc
|
|
224
|
+
fail(exc.error_class, exc.detail, extra=_port_error_extra(exc))
|
|
216
225
|
ok("send", {"frames_sent": sent, "frames_defined": len(frames),
|
|
217
226
|
"elapsed_ms": round((time.monotonic() - t0) * 1000, 2),
|
|
218
227
|
"tx_bytes": stats.get("tx_bytes"), "rx_bytes": stats.get("rx_bytes")},
|
|
@@ -229,7 +238,7 @@ def cmd_read(args: argparse.Namespace) -> None:
|
|
|
229
238
|
else:
|
|
230
239
|
result = session.read(max_bytes=RX_BUFFER_LIMIT if args.drain else args.max_bytes)
|
|
231
240
|
except SerialAssistantError as exc:
|
|
232
|
-
fail(exc.error_class, exc.detail, extra=exc
|
|
241
|
+
fail(exc.error_class, exc.detail, extra=_port_error_extra(exc))
|
|
233
242
|
|
|
234
243
|
if args.drain and not args.expect:
|
|
235
244
|
# P2-3 (0909 提案): 单次排空整个缓冲; 大 payload 落盘而非进 MCP 响应,
|
|
@@ -321,7 +330,7 @@ def cmd_parse(args: argparse.Namespace) -> None:
|
|
|
321
330
|
frames = parser.feed(data_bytes)
|
|
322
331
|
frames += parser.finalize()
|
|
323
332
|
except SerialAssistantError as exc:
|
|
324
|
-
fail(exc.error_class, exc.detail, extra=exc
|
|
333
|
+
fail(exc.error_class, exc.detail, extra=_port_error_extra(exc))
|
|
325
334
|
valid_n = sum(1 for f in frames if f["valid"])
|
|
326
335
|
ok("parse", {"source": src, "frames_n": len(frames), "valid_n": valid_n,
|
|
327
336
|
"invalid_n": len(frames) - valid_n, "bytes": len(data_bytes),
|
|
@@ -329,6 +338,21 @@ def cmd_parse(args: argparse.Namespace) -> None:
|
|
|
329
338
|
log=f"SerialParse({src}): {len(frames)} frames, {valid_n} valid")
|
|
330
339
|
|
|
331
340
|
|
|
341
|
+
def _port_error_extra(exc: SerialAssistantError) -> dict:
|
|
342
|
+
"""串口类错误的统一附加信息 (P1-4 / 评审 3.2-②)。
|
|
343
|
+
|
|
344
|
+
顺序说明设计: **硬结论在前** (port_probe = 直接试开端口能否独占), 候选名单在后
|
|
345
|
+
(cmdline 匹配较准 → 进程名匹配较低, 都只是"需人工确认"的候选)。
|
|
346
|
+
"""
|
|
347
|
+
extra = dict(exc.extra)
|
|
348
|
+
if exc.error_class in ("SERIAL_PORT_ERROR", "UART_BUSY"):
|
|
349
|
+
port = extra.get("port") or (_load_session_file() or {}).get("port")
|
|
350
|
+
extra.setdefault("port", port)
|
|
351
|
+
extra.setdefault("port_probe", port_exclusive_probe(port))
|
|
352
|
+
extra.setdefault("holder_candidates", port_holder_candidates(port))
|
|
353
|
+
return extra
|
|
354
|
+
|
|
355
|
+
|
|
332
356
|
def _run_power_cycle(off_ms: int) -> dict:
|
|
333
357
|
"""P2-4: 触发一次 NdtBox 断电复位 (复用 ndtdbg_cli power-cycle, 同 lab.yaml 解析链)。"""
|
|
334
358
|
cli = os.path.join(os.path.dirname(os.path.abspath(__file__)), "ndtdbg_cli.py")
|
|
@@ -389,9 +413,15 @@ def cmd_capture(args: argparse.Namespace) -> None:
|
|
|
389
413
|
result = box.get("r") or {}
|
|
390
414
|
stats = session.stats()
|
|
391
415
|
except SerialAssistantError as exc:
|
|
392
|
-
fail(exc.error_class, exc.detail, extra=exc
|
|
416
|
+
fail(exc.error_class, exc.detail, extra=_port_error_extra(exc))
|
|
393
417
|
payload = {**result, "tx_bytes": stats.get("tx_bytes"),
|
|
394
418
|
"simulated": stats.get("simulated")}
|
|
419
|
+
if args.duration_ms >= 10000:
|
|
420
|
+
# P2: MCP stdio 循环单线程 —— 长调用会让同会话的其它调用排队, 客户端可能先超时
|
|
421
|
+
payload["blocking_notice"] = (
|
|
422
|
+
f"服务端本次阻塞 {args.duration_ms}ms: MCP stdio 是单线程的, 同一会话内其它工具"
|
|
423
|
+
"调用会排在它后面 (客户端超时往往先到)。长采集建议缩短窗口, 或用 ndtdbg stream "
|
|
424
|
+
"job 模式 (fw_ndtdbg_stream_start/status/stop) 让采集不占调用通道")
|
|
395
425
|
if power_off_ms is not None:
|
|
396
426
|
payload["power_cycle"] = pc_result
|
|
397
427
|
if not (pc_result or {}).get("ok"):
|
|
@@ -498,7 +528,7 @@ def main() -> None:
|
|
|
498
528
|
try:
|
|
499
529
|
handler(args)
|
|
500
530
|
except SerialAssistantError as exc:
|
|
501
|
-
fail(exc.error_class, exc.detail, extra=exc
|
|
531
|
+
fail(exc.error_class, exc.detail, extra=_port_error_extra(exc))
|
|
502
532
|
|
|
503
533
|
|
|
504
534
|
if __name__ == "__main__":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<#
|
|
2
2
|
.SYNOPSIS
|
|
3
|
-
Dual-Tier MCP setup and registration helper (v0.7.
|
|
3
|
+
Dual-Tier MCP setup and registration helper (v0.7.3).
|
|
4
4
|
Inspects installed AI coding agents (Qoder, Claude Code, Antigravity, Cursor)
|
|
5
5
|
and configures global MCP / skills or prints exact registration commands.
|
|
6
6
|
|
|
@@ -242,7 +242,7 @@ if ($Json) {
|
|
|
242
242
|
Write-FwJson ([pscustomobject]$report)
|
|
243
243
|
} else {
|
|
244
244
|
Write-Host "============================================================" -ForegroundColor Cyan
|
|
245
|
-
Write-Host " FirmwareLoop Dual-Tier MCP & Agent Setup Helper (v0.7.
|
|
245
|
+
Write-Host " FirmwareLoop Dual-Tier MCP & Agent Setup Helper (v0.7.3)" -ForegroundColor Green
|
|
246
246
|
Write-Host "============================================================" -ForegroundColor Cyan
|
|
247
247
|
Write-Host ""
|
|
248
248
|
Write-Host "[1] Google Antigravity / Gemini CLI:" -ForegroundColor Yellow
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|