Files
STM32F4-Base/MDK-ARM/README.md
T
wandering1 e4981aa2f6 refactor(docs): point entry-file references at their new homes
AGENTS.md stopped being the store of record for build steps, Python env,
hardware pins, doc conventions, log cost and task ownership. Those facts
already live in docs, skills and role files; the entry file now only
points at them. This commit moves every reference that used to name the
entry file to the authoritative landing point, so a reader who follows a
link arrives at the fact instead of at a sentence that no longer exists.

What changed is links and prose, not behaviour. Code, scripts and tests
only have comment and docstring lines touched; the only non-comment edit
in the whole changeset is one note string inside the generated pin table
JSON, and its generator was changed in the same step so the two stay
byte-identical.

New landing points created before the references were retargeted:
- The console single-writer log design doc, section 7.1, is now the single
  authority for log cost: about 90 B flash and 216 B stack per DBG_ line,
  and the rule that deep call chains must predefine DBG_LINE_BUF_MAX.
  It also carries the full list of the twelve translation units that have
  tightened it, plus the grep command that decides the truth if the list
  and the code ever disagree.
- The document writing standard, section 2, now holds the BOM list.
- keil-build skill gains an exit code table: 0 success, 1 build failure,
  2 BuildEnvError, 3 usage, 4 build lock held. This corrects a belief
  that was never actually written down anywhere: exit 2 does not simply
  mean environment error, argparse also exits 2 and the wrapper script
  was remapped so the two no longer collide.

Regenerated and checked byte for byte:
- The end-to-end architecture SVG in docs/images from its generator.
- tools/netlist_semantics/pinout_kb.json from gen_kb.py.
Both are idempotent; running the generators again produces no diff.

Deliberately not touched, because machines read them:
- scripts/check_bom_drift.py joins every line containing BOM and asserts
  four paths are present, so the entry file BOM line must stay one line.
- scripts/gen_task_table.py reads the TASK_TABLE anchors directly.
- scripts/rename_maps and scripts/archive keep their historical wording;
  they describe what happened, not what is true now.

Verified: doc links report the same six pre-existing findings as the base
commit and no new ones, generated-fresh passes, bom drift is clean across
101 files, and AGENTS.md itself is unchanged in this commit.
2026-11-16 19:38:27 +08:00

3.4 KiB
Raw Blame History

MDK-ARM/ — Keil MDK-ARM v5 工程与构建/烧录/探针脚本

唯一工具链:Keil MDK-ARM v5(ARMCC,C99)。本目录含工程文件、启动文件、 命令行构建/烧录脚本,以及台架探针与判读脚本。

关键文件

文件/目录 作用
STM32F407-Demo.uvprojx Keil 工程文件(源文件清单、编译选项、目标配置)
STM32F407-Demo.uvoptx Keil 用户选项(调试器、断点等)
startup_stm32f407xx.s 启动文件(Heap_Size EQU 0x200(512B)在此限定)
.dsh/skills/stlink-flash/scripts/stlink_flash.py 复位/烧录/回读(ST-LINK_CLI 封装,见下;原 reset.bat 已于 2026-10-10 删除)

构建与烧录

# 编译(keil-build skill 的 keil_build.py;相对路径,勿用绝对路径)
& '.venv\Scripts\python.exe' .dsh\skills\keil-build\scripts\keil_build.py   # 退出码 0 = 0 errors, 0 warnings

# 烧录 + 复位运行(@download = stlink-flash skill)
& '.venv\Scripts\python.exe' .dsh\skills\stlink-flash\scripts\stlink_flash.py flash <文件.hex|.bin>

# 仅复位
& '.venv\Scripts\python.exe' .dsh\skills\stlink-flash\scripts\stlink_flash.py reset

⚠️ 烧录铁律

  • stlink_flash.py flash = ST-LINK_CLI -c SWD -P <文件> -Rst -Run——-Rst -Run 不可省略! 裸 -P 会报 Programming Complete,但目标核处于异常状态时写入并不落地(芯片内容不变)
  • 烧录后必须回读校验:ST-LINK_CLI -c SWD -CmpFile <文件> 0x08000000(No difference found 才算真写入)
  • 本机 3 线接线(nRST 未接),只重启不烧录用 stlink_flash.py reset

台架探针与判读脚本

脚本 作用
bench_verdict.py 台架判读(把运行结果判为 PASS/FAIL)
ftp_freeze_probe.py FTP 上传+回读哈希(真实路径冻结探针)——被 Trap 记录当作可信判据引用,保留;2026-10-22 起用设备账号登录(设备无匿名通道)
tcp_reconnect_probe.py TCP 快速复连探针(TRAP-NET-17)
audit_runs.py / audit_tcpclient.py 运行记录审计 / TCP 客户端审计
check_crecipe_content.py 检查创建配方内容

子目录

目录 内容
RTE/ Keil Run-Time Environment 配置
DebugConfig/ 调试会话配置
STM32F407-Demo/ 构建输出(.o/.axf/.map 等,产物不提交)
bench_diag/ 2026-10-22 删除:4 个一次性台架诊断脚本,全库零引用、且自设备启用 FTP 鉴权起就登录不上(需要时从 git 历史取回)
retracted_bench_20260922/ 已撤回的台架数据(存证)

⚠️ 注意

  • 工具路径经 DTU_* 环境变量解析(DTU_KEIL_UV4 = UV4.exe 完整路径,DTU_STLINK_CLI = ST-LINK_CLI.exe 完整路径;换机设变量即可,无需改脚本;契约见 docs/环境与部署/本地工具路径环境变量方案.md)
  • 本目录被 pre-commit 门禁排除
  • 启动文件的 Heap_Size = 512B 是自研代码禁用 malloc 的根因(CODE-RULE-20,依据与豁免 → docs/门禁说明/coding-standard.md)

相关文档

  • 烧录/复位:docs/测试说明/测试工具/ST-LINK_CLI_复位使用说明.md
  • 构建与验证:keil-build skill(.dsh/skills/keil-build/SKILL.md,含 exit 2 三种分型与 "0 错误 0 警告" 判定)
  • 测试流程:docs/测试说明/流程与规范/自动化测试流程.md