diag(ui/wave): 枚举扫描诊断留痕第二组(临时构建,随根因修复收敛)

第一组埋点烧后开回放页串口零留痕(既无 FR 失败也无零条目
行),剩余唯一静默分支 = try 闸取锁失败直接返回/扫描成功但有条目
不打印/段头与窗口读取失败不打印。本组补齐:

- scan:每次尝试编号 #N;try 闸失败行带 vol_lock_get_stats 计数(消费方
  观测,不取锁,符合看门狗设计说明 §4.3 口径);完成行改为无条件打印
  cnt/np/tt/ac(排除「成功但页面仍空」歧义)
- load_head / seg_win:try 闸、路径构造、开档 FR 码与读失败出口全部留痕

临时诊断构建,判性后随根因修复收敛到最小永久集。
/keil-build 0 错误 0 警告(Code +604 B,RAM 不变)。

Refs #38
This commit is contained in:
2026-11-02 17:39:47 +08:00
parent ee002d7ead
commit 3e01e9d98e
5 changed files with 58 additions and 22 deletions
+45 -9
View File
@@ -423,6 +423,8 @@ static const ui_soe_reader_t s_soe_reader = { ui_task_soe_count, ui_task_soe_get
static uint8_t s_wave_idx[WAVE_ST_SEG_MAX]; /* 盘上现存段号升序表 */
static uint8_t s_wave_cnt; /* 表内条数 */
static uint8_t s_wave_scanned; /* 表是否有效(manual_req 后作废) */
static uint8_t s_wave_dbg_seq; /* 诊断留痕(第一幕第二组):本 boot
* 扫描尝试序号,供各行对齐 */
static uint8_t s_wave_cached_idx; /* 段头缓存属于哪一段 */
static uint8_t s_wave_cache_ok; /* 该段已验完整(头+数据 CRC) */
static wave_seg_meta_t s_wave_meta; /* 已验段的头(172B,唯一驻留) */
@@ -459,7 +461,15 @@ static int ui_task_wave_scan(void) {
uint8_t i;
uint8_t full; /* 1 = 本轮拿到完整事实,允许钉表 */
s_wave_dbg_seq++; /* 诊断留痕(第一幕第二组):每次尝试一个序号 */
if (vol_lock_wait(0u) == 0u) {
/* try 闸此前无任何留痕(看门狗设计说明 §4.3 只禁「锁层自身」打日志——
* 这里是消费方的一次性观测,计数走不取锁的 vol_lock_get_stats) */
vol_lock_stats_t vs;
vol_lock_get_stats(&vs);
DBG_ERROR("ui wave scan #%u try fail tt=%lu ac=%lu fo=%lu",
(unsigned)s_wave_dbg_seq, (unsigned long)vs.try_timeout,
(unsigned long)vs.acquired, (unsigned long)vs.failopen);
return -1;
}
s_wave_cnt = 0u;
@@ -487,22 +497,29 @@ static int ui_task_wave_scan(void) {
}
(void)f_closedir(&dir);
if (full == 0u) {
DBG_ERROR("ui wave scan readdir fail fr=%d got=%u", (int)rr,
(unsigned)s_wave_cnt);
DBG_ERROR("ui wave scan #%u readdir fail fr=%d got=%u",
(unsigned)s_wave_dbg_seq, (int)rr, (unsigned)s_wave_cnt);
}
} else if (fr == FR_NO_PATH) {
full = 1u; /* 从未录过波 = 0 段,完整事实 */
} else {
DBG_ERROR("ui wave scan opendir fail fr=%d", (int)fr);
DBG_ERROR("ui wave scan #%u opendir fail fr=%d", (unsigned)s_wave_dbg_seq,
(int)fr);
}
vol_lock_release();
if (full == 0u) {
s_wave_cnt = 0u; /* 半截计数不外泄:本轮按「无段」显示 */
return -1;
}
if (s_wave_cnt == 0u) {
/* 判读表第三条(FR_OK 但零条目):钉盘级证据,供板级远程定性 */
DBG_INFO("ui wave scan done: dir ok, 0 seg entries");
{
/* 判读表补全(诊断):每一次完成扫描都留一行(含非零条目——
* 「扫描成功但页面仍空」也要能被排除),随根因修复收敛删减 */
vol_lock_stats_t vs;
vol_lock_get_stats(&vs);
DBG_INFO("ui wave scan #%u done cnt=%u np=%d tt=%lu ac=%lu",
(unsigned)s_wave_dbg_seq, (unsigned)s_wave_cnt,
(fr == FR_NO_PATH) ? 1 : 0, (unsigned long)vs.try_timeout,
(unsigned long)vs.acquired);
}
/* 插入排序:条数上限 100,不引 qsort 的 stdlib 依赖 */
for (i = 1u; i < s_wave_cnt; i++) {
@@ -572,7 +589,8 @@ static int ui_task_wave_load_head(uint8_t a_idx) {
static FIL f; /* static:FIL = 528B,理由同 soe_store_read */
char path[WAVE_ST_PATH_MAX]; /* 容量 = WAVE_ST_PATH_MAX(17 字节口径,
* 自己声明路径缓冲不得写死 16) */
FRESULT fr;
FRESULT fr = FR_OK; /* 诊断留痕可能未走到任何 f_read 就读它 */
FRESULT ofr = FR_OK; /* 诊断留痕(第一幕第二组):开档 FR 码 */
UINT br = 0u;
int rc;
@@ -580,13 +598,18 @@ static int ui_task_wave_load_head(uint8_t a_idx) {
return UI_WAVE_OK;
}
if (wave_store_seg_path(path, (uint32_t)sizeof(path), a_idx) != 0) {
DBG_ERROR("ui wave head #%u path fail idx=%u", (unsigned)s_wave_dbg_seq,
(unsigned)a_idx);
return UI_WAVE_NONE;
}
if (vol_lock_wait(0u) == 0u) {
DBG_ERROR("ui wave head #%u try fail idx=%u", (unsigned)s_wave_dbg_seq,
(unsigned)a_idx);
return UI_WAVE_NONE; /* 卷忙 = 本轮按无段处理(不阻塞 uiTask) */
}
rc = UI_WAVE_NONE;
if (f_open(&f, path, FA_READ) == FR_OK) {
ofr = f_open(&f, path, FA_READ);
if (ofr == FR_OK) {
uint32_t size;
uint32_t total;
uint32_t n;
@@ -644,6 +667,9 @@ static int ui_task_wave_load_head(uint8_t a_idx) {
s_wave_cache_ok = 1u;
} else {
s_wave_cache_ok = 0u;
DBG_ERROR("ui wave head #%u rc=%d idx=%u ofr=%d fr=%d br=%u",
(unsigned)s_wave_dbg_seq, rc, (unsigned)a_idx, (int)ofr,
(int)fr, (unsigned)br);
}
return rc;
}
@@ -785,6 +811,7 @@ static int ui_task_wave_seg_win(uint8_t a_idx, uint8_t a_ch,
int16_t *a_codes, int32_t *a_peak_milli) {
static FIL f;
char path[WAVE_ST_PATH_MAX];
FRESULT fr = FR_OK; /* 诊断留痕(第一幕第二组):开档 FR 码 */
UINT br = 0u;
uint32_t off;
uint32_t want;
@@ -816,13 +843,18 @@ static int ui_task_wave_seg_win(uint8_t a_idx, uint8_t a_ch,
return UI_WAVE_BAD; /* 窗口贴不出完整 40 点:显式不可读 */
}
if (wave_store_seg_path(path, (uint32_t)sizeof(path), a_idx) != 0) {
DBG_ERROR("ui wave win #%u path fail idx=%u", (unsigned)s_wave_dbg_seq,
(unsigned)a_idx);
return UI_WAVE_NONE;
}
if (vol_lock_wait(0u) == 0u) {
DBG_ERROR("ui wave win #%u try fail idx=%u ch=%u", (unsigned)s_wave_dbg_seq,
(unsigned)a_idx, (unsigned)a_ch);
return UI_WAVE_NONE;
}
rc = UI_WAVE_BAD;
if (f_open(&f, path, FA_READ) == FR_OK) {
fr = f_open(&f, path, FA_READ);
if (fr == FR_OK) {
if ((f_lseek(&f, off) == FR_OK) &&
(f_read(&f, s_wave_buf, want, &br) == FR_OK) && (br == want)) {
if ((wave_store_le_decode(s_wave_buf, want, raw, UI_WAVE_WIN_PTS,
@@ -863,6 +895,10 @@ static int ui_task_wave_seg_win(uint8_t a_idx, uint8_t a_ch,
}
}
*a_peak_milli = peak;
} else {
DBG_ERROR("ui wave win #%u rc=%d idx=%u ch=%u ofr=%d br=%u",
(unsigned)s_wave_dbg_seq, rc, (unsigned)a_idx, (unsigned)a_ch,
(int)fr, (unsigned)br);
}
return rc;
}