da66c500ea
B1 on-board closed loop surfaced a byte-level console interleave: before the console writer (defaultTask) registers, con_append() routes to dbg_console_write_raw() -> con_tx_bounded(), which is register-level polling with no mutual exclusion. adcTask logged every 1 ms, so its first-frame line collided with defaultTask's [NAND_FTL] init line and the required marker spanned two interleaved lines -> false FAIL. - console_log: add dbg_console_writer_ready() (returns s_con_writer_up) - adc_task: gate first-frame and 10 s stats logs on writer readiness; defer the first-frame report until the writer is up - docs: close B1/P1-1 in the registry; flip stale "remaining @test" notes; correct the console doc's obsolete "drop-only, no interleave" claim (that held for HAL gState, not register-level raw send) Bench (run_boot_test.py): VERDICT PASS, readback OK. adcTask frames/seq +10000 per 10 s = 1000 Hz, idle=0, frst_err=0; stack 496/2048 (75%). @build 0/0.
App/log/ — 日志子系统
两类日志:持久化运行日志(
sys_log,落 NAND)与控制台日志(console_log,走串口)。 两者都遵循单写者模型,避免多任务交错输出。
文件一览
| 文件 | 作用 |
|---|---|
sys_log.h |
日志接口(平台无关):定长 64B 记录写入 /log/run.log·selftest.log |
sys_log_mcu.c |
sys_log 的 MCU 端后端实现(NAND + FatFs) |
console_log.c/h |
控制台单写者日志:多任务日志经队列汇入唯一写者,避免串口输出交错 |
关键机制
syslog(运行/自检记录)
- 唯一写者 = defaultTask;其它任务只投递,不直接写盘
- 单记录定长 64 B,循环写;待机页可显示记录
- 内核启动前的日志走无锁静态缓冲
s_preboot[8]暂存(因为内核启动前不能建队列), 内核启动后由syslog_drain惰性创建真队列并排空 - ⚠️ 写盘必须校验
f_write返回的字节数(该 FatFs 移植在簇分配失败时返回FR_OK+ 短写, 不报错误码);追加写必须FA_WRITE|FA_OPEN_APPEND(FA_OPEN_APPEND单独用不含写位)
console_log(控制台单写者)
- 多任务的生产者 → 单写者消费者,消除任务间日志行交错
- 设计详见
docs/子系统设计/控制台单写者日志设计说明.md
相关文档
docs/子系统设计/控制台单写者日志设计说明.mddocs/子系统设计/运行与自检记录设计说明.md- FatFs 陷阱:
AGENTS.md「平台约束」