Files
STM32F4-Base/App/cfg
wandering1 12e0617909 fix(gates): close the BOM gate hole that let new files skip the check
The BOM gate claimed to stop BOMs from being stripped, but it only ever
inspected files that were already tracked AND already had a BOM. A new
file under a BOM-listed directory could be born without one and never
be noticed, because the scan never returned it and, even if it had, the
"no HEAD version" branch skipped it. Editing a listed file and losing
its BOM is a real accident that already happened once; creating one
without a BOM was the same accident with no safety net at all.

Measured before and after on the same untracked file with no BOM:

  before: checked 101 files, no drift, exit 0
  after:  FAIL, names the file, exit 1

The count of 101 was itself the symptom: with one more file present the
honest number is 102. The old code was not "silently passing a clean
tree", it was not looking.

The scan now includes untracked files, and a listed file with no HEAD
version must carry a BOM. Files that are tracked without a BOM keep
their historical pass so this does not flood existing code with
failures; instead the two that were listed but had no BOM were given one
so the list means what it says.

That exposed a conflict nobody had hit yet. The font file is generated,
and the generator rewrites it from scratch on every run, so a hand-added
BOM survived until the next regeneration and then vanished. The BOM gate
and the generated-fresh gate could not both pass. The generator now puts
the BOM back as its last step, idempotently, so the two gates agree and
the whole UI directory keeps its uniform encoding. Font content is
untouched: everything after the first three bytes is byte-identical.

The menu generator gains a real read-only mode. It previously had no
options at all and always rewrote its outputs; the arrows it printed
were accurate. That made it easy to mistake for a checker, since an
unchanged tree produces identical bytes and looks untouched. --check now
reports up to date or stale without writing anything, and the
registration tables are checked the same way. Default behaviour and
output are unchanged.

The telemetry page header no longer restates the board's input hardware
facts. They live in the IOBOARD README, which is where the board's
electrical behaviour belongs; the page keeps only what it alone can say:
that the output rows show the shadow register rather than contact
feedback, why an invalid sample draws -- instead of 分, and that these
twelve rows are not in the point table. One fact, one place.

The team rule for experiments now requires the file hash, the located
line number, and both runs. A report once cited a line number that did
not exist in the final file, which left no way to confirm which version
had actually been tested.
2026-11-16 23:59:49 +08:00
..

App/cfg/ — 配置引擎

/config.ini 配置引擎:分层解析、持久化(原子写)。 属主 = defaultTask(单任务收敛,静态态);其它任务不得直接触碰。

文件一览

文件 作用
cfg_file.c/h 配置引擎核心:解析 / 查询 / 保存 / 2s 周期 cfg_file_poll
cfg_file_store.h 存储后端抽象接口(MCU=FreeRTOS 堆 / 模拟器=宿主堆,共享核心零分配符号)
cfg_file_store_mcu.c MCU 端后端实现:/config.ini(临时名由目标路径同目录推导 + f_rename 原子写)
prot_set_store.c/h 保护定值持久化胶水:/prot_set.bin blob 读写(blob 格式/校验/原子装载在 App/algo/prot_set.c 纯逻辑层);装载 = storage bring-up(屏障前),落盘 = defaultTask 消费 SYS_EVT_PROT_SET_SAVE

设计要点

  • 单任务收敛:cfg_file 为静态态,只有 defaultTask 操作;UI 保存请求经 SYS_EVT_CFG_SAVE 事件唤醒 defaultTask 执行(netTask/uiTask 不得直接调用); 定值落盘同构——iec104Task 只置事件位(SYS_EVT_PROT_SET_SAVE),不碰文件系统
  • 零分配共享核心:核心逻辑不含任何分配符号,动态内存收进平台后端 (cfg_store_alloc/free:MCU→pvPortMalloc,模拟器→宿主堆)
  • 原子写:写 /config.TMP 后 f_rename 替换,避免掉电损坏
  • 自研代码禁用 C 库堆分配:MicroLIB 堆仅 512B(malloc 必返回 NULL)

相关文档

  • docs/子系统设计/配置文件设计.md — 完整设计(分层/解析/持久化)
  • docs/子系统设计/网络配置说明.md — 网络段