控制台日志实现迁出HAL生成文件至App/log并新增设计说明;defaultTask任务体迁至App/task,freertos.c恢复纯CubeMX接线形态
This commit is contained in:
@@ -110,6 +110,6 @@ STM32F407ZGTx @168MHz(HSE 8MHz → PLL M=4/N=168/P=2);**仅 Keil MDK-ARM v
|
||||
|
||||
## 文档与图形
|
||||
|
||||
- 配置文件 `docs/配置文件设计说明.md`;墙钟 `docs/系统墙钟时间维护说明.md`;代码规范 `docs/代码规范/`;测试说明 `docs/测试说明/`;审计发现 `docs/项目审计改进清单.md`;已知待办 `待处理内容.md`(内存预算);引用关系图 `docs/引用关系图说明.md`
|
||||
- 配置文件 `docs/配置文件设计说明.md`;墙钟 `docs/系统墙钟时间维护说明.md`;控制台单写者日志 `docs/控制台单写者日志设计说明.md`;代码规范 `docs/代码规范/`;测试说明 `docs/测试说明/`;审计发现 `docs/项目审计改进清单.md`;已知待办 `待处理内容.md`(内存预算);引用关系图 `docs/引用关系图说明.md`
|
||||
- 图形走 **`draw-diagram` skill**:精确布局图(协议帧/分层/屏障)用 `tools/arch_diagram/gen_*.py` 生成器(产物放 `docs/images/`,脚本与 .svg 一并提交);拓扑图(流程/时序/状态机)用 Mermaid;**勿手绘 ASCII 框图**
|
||||
- **文件引用关系图**走 `tools/refgraph`:`& 'tools\refgraph\gen_refgraph.bat'` 生成文件级 + 模块级引用图(产物 `docs/images/引用关系图.*`,脚本与 .dot/.svg/.json 一并提交,PNG 本地预览不提交);项目文件变化后重跑更新;渲染依赖 Graphviz(winget 可装)
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* 模块名称:Console Single-Writer Logging — 控制台单写者日志(USART1)实现
|
||||
* 模块功能:控制台单写者日志的环形缓冲 + 唯一写者发送实现(API 见 console_log.h);
|
||||
* 兼载 MicroLIB printf 底层 fputc 重定向
|
||||
* 适用平台:STM32F407ZGTx(仅 MCU 端)
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-09-24
|
||||
* 修改记录:
|
||||
* 2026-09-24 王建锋 创建(自 Src/usart.c USER CODE 区迁出,实现逻辑不变,
|
||||
* 仅变更文件位置:HAL 库生成文件不得包含应用代码)
|
||||
*/
|
||||
|
||||
#include "console_log.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "usart.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "sys_events.h"
|
||||
|
||||
/* ===== 控制台单写者日志(2026-09-24 加固,HardFault 定位结论驱动)=====
|
||||
* 背景:旧路径 DBG_* → printf → fputc **每字符一次** HAL_UART_Transmit。HAL 的锁只保证
|
||||
* "单字节"原子,任务切换发生在字符之间 → 两行日志逐字符交错(2026-09-24 崩溃前
|
||||
* 实测:"[2026-[2026-0909-24 15:2-24 15:27:37:39]…");更严重的是字符串指针一旦
|
||||
* 被破坏,脏指针会直接进入 UART 缓冲遍历(同日 HardFault:BFAR=0x10010000 恰为
|
||||
* CCM 末尾+1,PC 落在 HAL_UART_Transmit 的缓冲读取处)。
|
||||
* 架构:**defaultTask 是唯一串口发送者**;其余任务/上下文只把文本写入环形缓冲。
|
||||
* ① 行级原子:整行在一次临界区内拷入环形缓冲,写者按块一次 HAL_UART_Transmit
|
||||
* 发出 → 行与行不可能再交错(UART 只有这一个调用点);
|
||||
* ② 指针可控:进 UART 的缓冲恒为本文件的环形缓冲,调用方脏指针再也到不了 UART;
|
||||
* ③ 写者未注册(内核启动早期/裸机)或中断上下文:回退直接阻塞发送(无并发或必须裸发)。
|
||||
* 约束:不新增任务、不动态分配;环形缓冲为 BSS(SRAM1,非 CCM),无 DMA 可达性冲突。
|
||||
*/
|
||||
#define DBG_CON_RING_SIZE 4096U /* 环形缓冲字节数(必须为 2 的幂) */
|
||||
#define DBG_CON_CHUNK_MAX 256U /* 写者单次 HAL_UART_Transmit 字节上限 */
|
||||
#define DBG_CON_WAIT_MS 200U /* 缓冲满时生产者最长等待(ms),仍满则丢弃并计数 */
|
||||
|
||||
static uint8_t s_con_ring[DBG_CON_RING_SIZE];
|
||||
static volatile uint16_t s_con_head; /* 生产者写入位置 */
|
||||
static volatile uint16_t s_con_tail; /* 写者读取位置 */
|
||||
static volatile uint32_t s_con_drop; /* 因缓冲满丢弃的行数 */
|
||||
static volatile uint8_t s_con_writer_up; /* 1 = 写者已注册(此后走环形缓冲) */
|
||||
static TaskHandle_t s_con_writer_task; /* 写者任务句柄(自等保护用) */
|
||||
|
||||
/*
|
||||
* 函数功能:计算环形缓冲已用字节数(head-tail 差值回绕取模,无锁)
|
||||
* 入口参数:无
|
||||
* 返回值:已用字节数 uint16_t
|
||||
*/
|
||||
static uint16_t con_used(void) {
|
||||
return (uint16_t)((uint16_t)(s_con_head - s_con_tail) & (DBG_CON_RING_SIZE - 1U));
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:控制台裸发送(异常/早期路径专用:有界、单次、不加锁)
|
||||
* 入口参数:buf - 文本缓冲;len - 字节数(超上限截断)
|
||||
* 限定条件:串口已初始化;仅用于写者未注册、中断/异常上下文、崩溃上报
|
||||
*/
|
||||
void dbg_console_write_raw(const char *buf, unsigned len) {
|
||||
if ((buf == NULL) || (len == 0U)) {
|
||||
return;
|
||||
}
|
||||
if (len > DBG_CON_CHUNK_MAX) {
|
||||
len = DBG_CON_CHUNK_MAX;
|
||||
}
|
||||
(void)HAL_UART_Transmit(&huart1, (uint8_t *)buf, (uint16_t)len, 0xFFFFu);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:注册控制台写者(defaultTask 在进入主循环前调用一次)
|
||||
* 函数说明:注册后生产者改走环形缓冲;未注册时直接阻塞发送(内核启动早期)
|
||||
*/
|
||||
void dbg_console_writer_attach(void) {
|
||||
s_con_writer_task = xTaskGetCurrentTaskHandle();
|
||||
s_con_writer_up = 1U;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:排空环形缓冲(仅写者任务调用)
|
||||
* 函数说明:按块一次 HAL_UART_Transmit 发出;每块完成后再推进读指针(临界区保护)
|
||||
*/
|
||||
void dbg_console_drain(void) {
|
||||
uint16_t used;
|
||||
|
||||
if (s_con_writer_up == 0U) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ((used = con_used()) != 0U) {
|
||||
uint16_t tail = s_con_tail;
|
||||
uint16_t contig = (uint16_t)(DBG_CON_RING_SIZE - tail); /* 到环尾的连续段 */
|
||||
uint16_t n = (used < contig) ? used : contig;
|
||||
|
||||
if (n > DBG_CON_CHUNK_MAX) {
|
||||
n = DBG_CON_CHUNK_MAX;
|
||||
}
|
||||
(void)HAL_UART_Transmit(&huart1, &s_con_ring[tail], n, 0xFFFFu);
|
||||
taskENTER_CRITICAL();
|
||||
s_con_tail = (uint16_t)((uint16_t)(s_con_tail + n) & (DBG_CON_RING_SIZE - 1U));
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
/* 丢弃可观测性:缓冲满丢行必须显式可见(否则会掩盖开机自检/测试标记的丢失) */
|
||||
if (s_con_drop != 0U) {
|
||||
char note[64];
|
||||
uint32_t d = s_con_drop;
|
||||
int n;
|
||||
|
||||
s_con_drop = 0U;
|
||||
n = snprintf(note, sizeof(note), "\r\n[ERR] CONSOLE dropped %lu lines\r\n",
|
||||
(unsigned long)d);
|
||||
if (n > 0) {
|
||||
if (n > (int)sizeof(note) - 1) {
|
||||
n = (int)sizeof(note) - 1;
|
||||
}
|
||||
dbg_console_write_raw(note, (unsigned)n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:把一段文本放入控制台(写者已注册)/直接发出(未注册或中断上下文)
|
||||
* 返回值:0 - 已入缓冲或已直发;-1 - 缓冲满丢弃(计入 dbg_console_dropped)
|
||||
* 函数说明:生产者不持锁等待过久:最多 DBG_CON_WAIT_MS,仍满则丢弃该行;
|
||||
* 写者自身记录日志时先排空缓冲,避免自等。
|
||||
*/
|
||||
static int con_append(const char *buf, uint16_t len) {
|
||||
uint32_t waited = 0U;
|
||||
|
||||
if ((buf == NULL) || (len == 0U)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((s_con_writer_up == 0U) || (__get_IPSR() != 0U)) {
|
||||
dbg_console_write_raw(buf, len);
|
||||
return 0;
|
||||
}
|
||||
if (len > (DBG_CON_RING_SIZE / 2U)) {
|
||||
len = (uint16_t)(DBG_CON_RING_SIZE / 2U); /* 超长保护(正常路径不会触发) */
|
||||
}
|
||||
|
||||
if (xTaskGetCurrentTaskHandle() == s_con_writer_task) {
|
||||
dbg_console_drain(); /* 写者自己记录:先腾空,避免自等 */
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
uint16_t used = con_used();
|
||||
uint16_t free_space = (uint16_t)((DBG_CON_RING_SIZE - 1U) - used);
|
||||
|
||||
if (free_space >= len) {
|
||||
break;
|
||||
}
|
||||
if (waited >= DBG_CON_WAIT_MS) {
|
||||
s_con_drop++;
|
||||
return -1;
|
||||
}
|
||||
vTaskDelay(1);
|
||||
waited++;
|
||||
}
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
uint16_t head = s_con_head;
|
||||
uint16_t first = (uint16_t)(DBG_CON_RING_SIZE - head);
|
||||
uint16_t i;
|
||||
|
||||
if (first > len) {
|
||||
first = len;
|
||||
}
|
||||
for (i = 0U; i < first; i++) {
|
||||
s_con_ring[head + i] = (uint8_t)buf[i];
|
||||
}
|
||||
for (i = first; i < len; i++) {
|
||||
s_con_ring[(uint16_t)((uint16_t)(head + i) & (DBG_CON_RING_SIZE - 1U))] =
|
||||
(uint8_t)buf[i];
|
||||
}
|
||||
s_con_head = (uint16_t)((uint16_t)(head + len) & (DBG_CON_RING_SIZE - 1U));
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
if (sys_evtHandle != NULL) {
|
||||
(void)osEventFlagsSet(sys_evtHandle, SYS_EVT_CONSOLE_TX); /* 唤醒写者 */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:把一行已格式化的文本交给单写者控制台(生产者入口,**非可变参数**)
|
||||
* 入口参数:line - 整行文本(含结尾换行);len - 字节数
|
||||
* 返回值:写入字节数;-1 - 参数非法或被丢弃
|
||||
* 函数说明:整行一次入环形缓冲 → 行级原子(不会与他行交错);调用方缓冲随即可复用。
|
||||
* 刻意不用自研可变参数函数(规范 S12 7.6);格式化由 DBG_PRINT 宏内
|
||||
* 库 snprintf 在调用点完成。
|
||||
*/
|
||||
int dbg_console_write_line(const char *line, unsigned len) {
|
||||
if ((line == NULL) || (len == 0U)) {
|
||||
return -1;
|
||||
}
|
||||
if (len > DBG_CON_LINE_MAX) {
|
||||
len = DBG_CON_LINE_MAX; /* 截断(丢尾,保开头的标记信息) */
|
||||
}
|
||||
if (con_append(line, (uint16_t)len) != 0) {
|
||||
return -1;
|
||||
}
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:已丢弃的日志行数(诊断用)
|
||||
*/
|
||||
uint32_t dbg_console_dropped(void) {
|
||||
return s_con_drop;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:MicroLIB printf 底层重定向(库内部/遗留 printf 调用)
|
||||
* 函数说明:同样只把字节交给单写者路径;未注册写者时直发(与旧行为一致)
|
||||
*/
|
||||
int fputc(int ch, FILE *f) {
|
||||
uint8_t b = (uint8_t)ch;
|
||||
|
||||
(void)f;
|
||||
(void)con_append((const char *)&b, 1U);
|
||||
return ch;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 模块名称:Console Single-Writer Logging — 控制台单写者日志(USART1 调试串口)
|
||||
* 模块功能:调试控制台单写者环形缓冲的公共 API:所有任务/上下文(含 printf)只把
|
||||
* 已格式化整行文本入环形缓冲,写者任务(defaultTask)为唯一
|
||||
* HAL_UART_Transmit 发送点(行级原子 + 指针可控)
|
||||
* 使用方法:
|
||||
* 1. 生产者:DBG_ERROR/DBG_INFO/DBG_DEBUG 宏(dbg_log.h,内部用库 snprintf
|
||||
* 有界格式化整行后调 dbg_console_write_line);或直接调 dbg_console_write_line
|
||||
* 2. 写者任务:进入主循环前调 dbg_console_writer_attach() 注册为唯一发送者,
|
||||
* 循环中周期调 dbg_console_drain() 排空(defaultTask 已接线,见 Src/freertos.c)
|
||||
* 适用平台:STM32F407ZGTx(仅 MCU 端;模拟器不编译本模块——模拟器 DBG_*
|
||||
* 直接映射 printf,见 simulator/dbg_log.h)
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-09-24
|
||||
* 修改记录:
|
||||
* 2026-09-24 王建锋 创建(自 Src/usart.c USER CODE 区迁出:
|
||||
* HAL 库生成文件不得包含应用代码)
|
||||
*/
|
||||
|
||||
#ifndef CONSOLE_LOG_H
|
||||
#define CONSOLE_LOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* 单写者控制台 API(与 DBG_ENABLE 无关,任何构建都必须可见):
|
||||
* dbg_console_write_line - 生产者入口:调用方已格式化好的整行文本一次入环形缓冲
|
||||
* (刻意**不用**自研可变参数函数——规范 S12 7.6 禁止;格式化在
|
||||
* DBG_PRINT 宏内用库 snprintf 完成)
|
||||
* dbg_console_write_raw - 异常/早期路径:有界单次直发(不加锁)
|
||||
* dbg_console_writer_attach- 写者任务(defaultTask)注册自己为唯一发送者
|
||||
* dbg_console_drain - 写者任务排空缓冲并发送
|
||||
* dbg_console_dropped - 因缓冲满丢弃的行数(诊断)
|
||||
*/
|
||||
#define DBG_CON_LINE_MAX 192U /* 单行文本上限(含结尾 '\0',超出截断) */
|
||||
int dbg_console_write_line(const char *line, unsigned len);
|
||||
void dbg_console_write_raw(const char *buf, unsigned len);
|
||||
void dbg_console_writer_attach(void);
|
||||
void dbg_console_drain(void);
|
||||
uint32_t dbg_console_dropped(void);
|
||||
|
||||
/*
|
||||
* 函数功能:MicroLIB printf 底层重定向(C 库 retarget 钩子,须为全局符号)
|
||||
* 入口参数:ch - 字符;f - 文件流(忽略)
|
||||
* 返回值:原样返回 ch
|
||||
* 限定条件:printf 调用点执行(任意任务上下文);字节交单写者路径
|
||||
*/
|
||||
int fputc(int ch, FILE *f);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONSOLE_LOG_H */
|
||||
@@ -0,0 +1,434 @@
|
||||
/*
|
||||
* 模块名称:Default Application Task
|
||||
* 模块功能:主控任务(defaultTask)任务体实现:
|
||||
* ① 启动段:存储 bring-up(挂载 + 空卷自动建卷 + 卷健康探针两击 +
|
||||
* 自愈重格式化,E-31 失败后主循环 3×2s 有界重试)+ 网络配置加载
|
||||
* + STORAGE_READY 屏障 + "保存网络配置"回调注册
|
||||
* ② 控制台单写者:dbg_console_writer_attach 注册 + 主循环 dbg_console_drain
|
||||
* 排空(串口唯一发送者,见 App/log/console_log.c 设计说明)
|
||||
* ③ 主循环:配置保存执行 + 2s 配置轮询 + LED 心跳 + syslog 落盘
|
||||
* + 栈水位观测([STACK] 报告)
|
||||
* 适用平台:STM32F407ZGTx + FreeRTOS(CMSIS-RTOS V2)
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-09-25
|
||||
* 修改记录:
|
||||
* v1.0 2026-09-25 王建锋 自 Src/freertos.c 迁出 StartDefaultTask 任务体及
|
||||
* stack_probe_poll / storage_bring_up / 保存通知回调
|
||||
* (CubeMX 生成文件只留任务创建接线与崩溃钩子)
|
||||
*/
|
||||
|
||||
#include "default_task.h"
|
||||
#include "test_config.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "main.h"
|
||||
#include "ff.h"
|
||||
#include "nand_ftl.h"
|
||||
#include "net_cfg.h"
|
||||
#include "cfg_file.h"
|
||||
#include "sys_log.h"
|
||||
#include "sys_events.h"
|
||||
#include "dbg_log.h"
|
||||
|
||||
/* 任务句柄与属性块(CubeMX 生成全局,定义于 Src/freertos.c):
|
||||
* 栈水位观测需 6 任务句柄 + 属性块 stack_size(配置栈大小的唯一定义处) */
|
||||
extern osThreadId_t defaultTaskHandle;
|
||||
extern const osThreadAttr_t defaultTask_attributes;
|
||||
extern osThreadId_t netTaskHandle;
|
||||
extern const osThreadAttr_t netTask_attributes;
|
||||
extern osThreadId_t ftpTaskHandle;
|
||||
extern const osThreadAttr_t ftpTask_attributes;
|
||||
extern osThreadId_t testTaskHandle;
|
||||
extern const osThreadAttr_t testTask_attributes;
|
||||
extern osThreadId_t uiTaskHandle;
|
||||
extern const osThreadAttr_t uiTask_attributes;
|
||||
extern osThreadId_t timeSyncTaskHandle;
|
||||
extern const osThreadAttr_t timeSyncTask_attributes;
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
/* 栈水位观测节奏:首次报告须晚于 bring-up 深链(mount/mkfs/探针/cfg/syslog),
|
||||
* 之后每周期只判定"是否出现更深峰值",无新峰值不打印(保持串口静默窗口) */
|
||||
#define STACK_PROBE_FIRST_MS 5000u
|
||||
#define STACK_PROBE_PERIOD_MS 2000u
|
||||
/* E-31 自愈策略(2026-09-21 审计 P0 修复):启动期存储挂载失败后,
|
||||
* 主循环按 2s 周期重跑完整 bring-up 的次数上限;耗尽则维持无存储降级
|
||||
* (自检已上报、卷保留、不重格式化),等下次上电重新 resume */
|
||||
#define STORAGE_BRINGUP_RETRIES 3u
|
||||
|
||||
/* Private typedef -------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
const char *p_name;
|
||||
const osThreadId_t *p_id;
|
||||
const osThreadAttr_t *p_attr; /* 配置栈大小来源(stack_size) */
|
||||
} stack_probe_task_t;
|
||||
|
||||
static const stack_probe_task_t s_stack_probe[] = {
|
||||
{ "default", &defaultTaskHandle, &defaultTask_attributes },
|
||||
{ "net", &netTaskHandle, &netTask_attributes },
|
||||
{ "ftp", &ftpTaskHandle, &ftpTask_attributes },
|
||||
{ "test", &testTaskHandle, &testTask_attributes },
|
||||
{ "ui", &uiTaskHandle, &uiTask_attributes },
|
||||
{ "timesync", &timeSyncTaskHandle, &timeSyncTask_attributes },
|
||||
};
|
||||
|
||||
#define STACK_PROBE_COUNT (sizeof(s_stack_probe) / sizeof(s_stack_probe[0]))
|
||||
|
||||
static void stack_probe_poll(void);
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
static void default_task_net_cfg_save_notify(void);
|
||||
static FRESULT storage_bring_up(FATFS *fs);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 函数功能:defaultTask 任务体(2026-09-25 自 Src/freertos.c StartDefaultTask 迁出,
|
||||
* 逻辑零改动)
|
||||
* 入口参数:argument - 未用
|
||||
* 返回值:无(任务不返回)
|
||||
* 限定条件:仅由 defaultTask 调用(CubeMX 接线 StartDefaultTask 转调);本任务
|
||||
* 只在内核运行期被调度,启动段允许使用 CMSIS 对象
|
||||
* 函数说明:启动段 = 存储 bring-up + 保存回调注册 + 控制台写者注册;
|
||||
* 主循环 = 事件等待(配置保存/控制台待发,50ms 兜底)→ 控制台排空
|
||||
* → 配置保存执行 → 2s 配置轮询(含 E-31 有界重试)→ LED 心跳
|
||||
* → syslog 落盘 → 栈水位观测
|
||||
*/
|
||||
void default_task_func(void *argument) {
|
||||
(void)argument;
|
||||
|
||||
/* 系统启动期挂载 NAND 上的 FatFS 卷,供 FTP 及其它模块访问。
|
||||
* f_mount(forced=1) 会触发 disk_initialize() → nand_ftl_init()
|
||||
* (dhara_map_resume)。此前默认构建从未挂载,导致 FTP 的
|
||||
* LIST/STOR/RETR 全部返回 550(f_opendir 失败)。
|
||||
* 完整 bring-up 序列(挂载 + 空卷自动建卷 + 健康探针 + 自愈重格式化
|
||||
* + 日志挂载 + 配置加载 + 就绪屏障)实现于 storage_bring_up()。
|
||||
*
|
||||
* E-31(2026-09-21 审计,P0 修复):dhara_map_resume 失败不再被当
|
||||
* "新卷"静默重格式化(扫描中任何一次瞬态毛刺都会销毁全部用户数据)——
|
||||
* nand_ftl 仅把 DHARA_E_TOO_BAD(真空白)判为新卷,其余失败使
|
||||
* disk_initialize 失败 → f_mount 失败 → 下方自检上报并保留卷;
|
||||
* 瞬态失败由主循环有界重试(STORAGE_BRINGUP_RETRIES 次 × 2s),
|
||||
* 成功后补跑"存储就绪"序列(日志挂载/配置加载/屏障置位,均幂等)。
|
||||
* 探针/重格式化自愈策略仍在 storage_bring_up 内(2026-09-20 修复,
|
||||
* 小写两击确认、FR_INVALID_NAME 不入重格式化集、写保护类只上报,
|
||||
* 详见该函数注释)。 */
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
/* E-31 自愈:存储 bring-up 剩余重试次数(0 = 已就绪或已耗尽);
|
||||
* 须在启动块之前声明(启动块失败路径写入、主循环读取) */
|
||||
uint32_t storage_retry = 0u;
|
||||
#endif
|
||||
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
/* STORAGE 套件构建下 defaultTask 完全跳过存储 bring-up(挂载/配置/日志盘写),
|
||||
* 卷由 testTask 的 storage_test_run 独占——测试含 nand_ftl_deinit 掉电模拟,
|
||||
* 与任何后台文件写入并发都会互相踩坏 FTL/FatFs 状态(2026-09-20 台架实证:
|
||||
* 双写并发导致 mkfs 半途冻结 + BBT 被误写) */
|
||||
static FATFS default_fatfs;
|
||||
FRESULT fr = storage_bring_up(&default_fatfs);
|
||||
if (fr != FR_OK) {
|
||||
/* 存储不可写:自检故障仅能滞留待发队列(串口已告警) */
|
||||
syslog_post(SYSLOG_SELFTEST, "filesystem fault");
|
||||
/* E-31 自愈:启动主循环中的有界重试(每 2s 一次) */
|
||||
storage_retry = STORAGE_BRINGUP_RETRIES;
|
||||
}
|
||||
|
||||
/* 注册"保存网络配置"请求通知:UI(uiTask)投递 → 置事件 → 本任务立即执行写盘
|
||||
* (配置引擎属主 = 本任务;UI 保存不再直接触碰配置文件引擎,P1-3) */
|
||||
net_cfg_set_save_req_cb(default_task_net_cfg_save_notify);
|
||||
#else
|
||||
/* STORAGE 套件构建:挂载/配置引擎/日志盘写全部跳过,存储由 testTask 独占 */
|
||||
DBG_INFO("[FS] mount/cfg skipped (STORAGE suite owns storage)");
|
||||
#endif
|
||||
|
||||
/* 配置 poll 周期计数(每 40 次循环 = 2s 轮询一次,与引擎文档/模拟器一致。
|
||||
* 循环基准 50ms:控制台"待发"事件即时唤醒,无事件时 50ms 兜底,日志时延 <=50ms) */
|
||||
uint32_t cfg_poll_cnt = 0u;
|
||||
uint32_t led_tick = HAL_GetTick();
|
||||
|
||||
/* 注册控制台写者:本任务此后是串口唯一发送者(其余任务只写环形缓冲)。
|
||||
* 见 App/log/console_log.c "控制台单写者日志"——消除并发写造成的日志逐字符交错,
|
||||
* 并让脏指针无法再进入 HAL_UART_Transmit 的缓冲遍历。 */
|
||||
dbg_console_writer_attach();
|
||||
|
||||
for (;;) {
|
||||
/* 等待"保存网络配置"或"控制台待发":任一即醒;无事件 50ms 后返回
|
||||
* (日志时延 = 事件唤醒,实测无丢失;50ms 兜底仅防事件位异常) */
|
||||
if (sys_evtHandle != NULL) {
|
||||
(void)osEventFlagsWait(sys_evtHandle,
|
||||
SYS_EVT_CFG_SAVE | SYS_EVT_CONSOLE_TX,
|
||||
osFlagsWaitAny, 50u);
|
||||
}
|
||||
/* 控制台唯一发送点:把环形缓冲中的日志按块发出(无待发时立即返回) */
|
||||
dbg_console_drain();
|
||||
/* 执行待处理保存(配置引擎属主:写盘 + 成功后立即应用);无请求 = 空操作 */
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
net_cfg_save_run();
|
||||
#endif
|
||||
/* 配置文件变更轮询(2s 周期;沉降去抖在引擎内) */
|
||||
if ((cfg_poll_cnt++ % 40u) == 0u) {
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
/* E-31 自愈:启动期挂载失败时,每 2s 重跑完整 bring-up——
|
||||
* 瞬态毛刺(如 dhara resume 扫描的瞬时 SPI 故障)通常第二次
|
||||
* 即恢复;成功后由 storage_bring_up 补跑启动时跳过的
|
||||
* "存储就绪"序列(日志挂载/配置加载/屏障置位,均幂等);
|
||||
* 持续性故障耗尽重试则维持无存储降级(自检已在启动/耗尽时
|
||||
* 上报,卷保留、不重格式化,等下次上电重新 resume) */
|
||||
if (storage_retry > 0u) {
|
||||
FRESULT rfr = storage_bring_up(&default_fatfs);
|
||||
if (rfr == FR_OK) {
|
||||
storage_retry = 0u;
|
||||
DBG_INFO("[FS] storage bring-up OK on retry");
|
||||
} else if (--storage_retry == 0u) {
|
||||
DBG_ERROR("[FS] storage retries exhausted (fr=%d), "
|
||||
"storage disabled", (int)rfr);
|
||||
syslog_post(SYSLOG_SELFTEST, "filesystem fault");
|
||||
}
|
||||
}
|
||||
cfg_file_poll();
|
||||
#endif
|
||||
}
|
||||
/* LED 心跳:500ms 翻转一次(与旧 500ms 循环节奏等效;循环基准改 50ms 后
|
||||
* 不能再每轮翻转,否则变成 10Hz 闪烁) */
|
||||
if ((HAL_GetTick() - led_tick) >= 500u) {
|
||||
led_tick = HAL_GetTick();
|
||||
HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
|
||||
HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin);
|
||||
}
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
/* 排空运行期日志(上电/重启分类与自检故障落盘) */
|
||||
syslog_drain();
|
||||
#endif
|
||||
/* 栈水位观测:首次 5s 后报告,此后每 2s 采样、出现更深峰值才打印 */
|
||||
stack_probe_poll();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:栈水位周期观测(可观测性,2026-09-21 自 Src/freertos.c 迁出,
|
||||
* 逻辑零改动)
|
||||
* 入口参数:无
|
||||
* 返回值:无
|
||||
* 限定条件:仅 defaultTask 主循环调用
|
||||
* 函数说明:
|
||||
* 数据源:任务栈"历史最小剩余"——内核按特征值填充法统计(与
|
||||
* configCHECK_FOR_STACK_OVERFLOW=2 同一机制),osThreadGetStackSpace() 取剩余
|
||||
* 字节,配置字节取各任务 *_attributes.stack_size(唯一定义处,避免常量重复;
|
||||
* 本版 CMSIS 包装只有 GetStackSpace 实现,无 osThreadGetStackSize)。
|
||||
* 峰值占用 = 配置 - 剩余。
|
||||
* 定栈规则(docs/内存管理/RAM使用分析与优化方案.md):新栈 = 峰值*1.5 + 1KB ISR
|
||||
* 余量,并要求 free_min >= 新栈*30% 才算合格。
|
||||
* 节奏:首次 STACK_PROBE_FIRST_MS 后报告(bring-up 深链已跑过),此后每
|
||||
* STACK_PROBE_PERIOD_MS 采样一次,只在出现更深峰值时打印——既不改串口静默
|
||||
* 窗口,也不漏掉之后才走到的更深分支(如卷修复/配置保存路径)。
|
||||
* 输出(纯 ASCII,便于 @test 采集):
|
||||
* [STACK] <task> peak_used=<B>/<cfg> free_min=<B> (<pct>%)
|
||||
* [STACK] heap free=<B> min_ever=<B>
|
||||
* 未覆盖 idle/timer 任务(内核静态小栈、纯循环,未取句柄)。
|
||||
*/
|
||||
static void stack_probe_poll(void) {
|
||||
static uint32_t s_free_min[STACK_PROBE_COUNT]; /* 历史最小剩余(B),0=未采样 */
|
||||
static uint32_t s_last_tick;
|
||||
static uint8_t s_reported;
|
||||
const TickType_t now = xTaskGetTickCount();
|
||||
uint32_t i;
|
||||
uint8_t deeper = 0u;
|
||||
|
||||
if (s_reported == 0u) {
|
||||
if (now < pdMS_TO_TICKS(STACK_PROBE_FIRST_MS)) {
|
||||
return;
|
||||
}
|
||||
} else if ((uint32_t)(now - s_last_tick) < (uint32_t)pdMS_TO_TICKS(STACK_PROBE_PERIOD_MS)) {
|
||||
return;
|
||||
}
|
||||
s_last_tick = (uint32_t)now;
|
||||
|
||||
for (i = 0u; i < (uint32_t)STACK_PROBE_COUNT; i++) {
|
||||
const osThreadId_t th = *(s_stack_probe[i].p_id);
|
||||
uint32_t free_now;
|
||||
|
||||
if (th == NULL) {
|
||||
continue; /* 任务未创建 */
|
||||
}
|
||||
free_now = osThreadGetStackSpace(th);
|
||||
if (free_now == 0u) {
|
||||
continue; /* 句柄不可用:跳过 */
|
||||
}
|
||||
if ((s_free_min[i] == 0u) || (free_now < s_free_min[i])) {
|
||||
s_free_min[i] = free_now; /* 刷新历史最小(= 最深峰值) */
|
||||
deeper = 1u;
|
||||
}
|
||||
}
|
||||
|
||||
if ((s_reported != 0u) && (deeper == 0u)) {
|
||||
return; /* 无新峰值:静默 */
|
||||
}
|
||||
s_reported = 1u;
|
||||
|
||||
for (i = 0u; i < (uint32_t)STACK_PROBE_COUNT; i++) {
|
||||
const uint32_t free_min = s_free_min[i];
|
||||
const uint32_t cfg = (uint32_t)s_stack_probe[i].p_attr->stack_size;
|
||||
|
||||
if (free_min == 0u) {
|
||||
continue;
|
||||
}
|
||||
if (cfg == 0u) {
|
||||
continue;
|
||||
}
|
||||
DBG_INFO("[STACK] %s peak_used=%lu/%lu free_min=%lu (%lu%%)",
|
||||
s_stack_probe[i].p_name,
|
||||
(unsigned long)(cfg - free_min), (unsigned long)cfg,
|
||||
(unsigned long)free_min,
|
||||
(unsigned long)((free_min * 100u) / cfg));
|
||||
}
|
||||
DBG_INFO("[STACK] heap free=%lu min_ever=%lu",
|
||||
(unsigned long)xPortGetFreeHeapSize(),
|
||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:存储 bring-up 完整序列(挂载 + 空卷自动建卷 + 卷健康探针两击 +
|
||||
* 自愈重格式化 + 日志挂载 + 配置加载 + "存储就绪"屏障;
|
||||
* 2026-09-25 自 Src/freertos.c 迁出,逻辑零改动)
|
||||
* 入口参数:fs - 调用方持有的 FATFS 实例(defaultTask 局部 static)
|
||||
* 返回值:FRESULT - FR_OK = 就绪(含屏障已置位);其它 = 失败(卷保留)
|
||||
* 限定条件:仅 defaultTask 调用(配置引擎/日志盘写属主);STORAGE 套件构建
|
||||
* 下整体不参与编译(卷由 testTask 独占)
|
||||
* 函数说明:
|
||||
* 由 defaultTask 调用:启动期一次;若失败,主循环每 2s 重试至多
|
||||
* STORAGE_BRINGUP_RETRIES 次(E-31 自愈策略,2026-09-21):dhara_map_resume
|
||||
* 失败分类修复后(nand_ftl.c 仅真空白判新卷,其余失败保留卷并返回
|
||||
* disk_initialize 失败),重试让瞬态毛刺(SPI 瞬时故障/扫描窗口抖动)
|
||||
* 在数秒内免重启恢复,成功时补跑启动期跳过的就绪序列(日志挂载/配置
|
||||
* 加载/屏障置位,三者均幂等、可重跑);持续故障耗尽重试后进入无存储
|
||||
* 降级态(自检已上报、卷保留、不重格式化,等下次上电重新 resume)。
|
||||
*
|
||||
* 探针/重格式化策略(2026-09-20 台架实证修复,原启动块注释迁入):
|
||||
* 小写两击确认防 FTL 瞬态抖动误触发;仅结构性错误集合(已排除
|
||||
* FR_INVALID_NAME)触发自愈重格式化;写保护/卷锁/参数类只上报不重格式化
|
||||
* (防对写锁卷整卷擦除)。
|
||||
*/
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
static FRESULT storage_bring_up(FATFS *fs) {
|
||||
FRESULT fr = f_mount(fs, "", 1);
|
||||
|
||||
if (fr == FR_NO_FILESYSTEM) {
|
||||
/* 卷为空(如恢复/坏块重建后清空):自动格式化建卷
|
||||
* (MKFS_PARM 与存储测试一致:FM_FAT32 / 无分区表) */
|
||||
DBG_INFO("[FS] no FAT volume, formatting NAND...");
|
||||
static uint8_t fs_work[FF_MAX_SS];
|
||||
MKFS_PARM opts = { FM_FAT32, 0, 0, 0, 0 };
|
||||
/* 格式化前清空 FTL map 树:新卷从空树开始写,journal
|
||||
* 不与旧卷残留共存(结构卫生)。注:这不是"无限重格式化"的根因——
|
||||
* 真根因是 FatFs 探针文件名非法(见下方探针注释)。 */
|
||||
(void)nand_ftl_format();
|
||||
fr = f_mkfs("", &opts, fs_work, sizeof(fs_work));
|
||||
if (fr == FR_OK) {
|
||||
fr = f_mount(fs, "", 1);
|
||||
} else {
|
||||
DBG_ERROR("[FS] f_mkfs failed (fr=%d)", (int)fr);
|
||||
}
|
||||
}
|
||||
|
||||
if (fr == FR_OK) {
|
||||
/* 探针:/fschk.tmp 小写一次,验证 FAT 链真实可用。本移植
|
||||
* f_write 簇分配失败返回 FR_OK+短写 → 必须校验写回字节数;短写按
|
||||
* FR_DENIED 归一化(落入下方结构性集合触发重格式化)。
|
||||
* ⚠ 事故教训(2026-09-20 台架实证,"无限重格式化"真根因):本移植
|
||||
* FF_USE_LFN=0,ff.c create_short 把 ".fschk" 点后的 FSCHK 当扩展域
|
||||
* 解析(5 字符 > 3 上限)→ f_open 恒返 FR_INVALID_NAME(6)(纯 RAM
|
||||
* 判定、不碰盘)→ 曾误入下方结构性错误集合 → 每 boot 假失败 →
|
||||
* 无限重格式化。探针名必须严格 8.3:名≤8、扩展≤3、不以点开头。 */
|
||||
#define FS_VOL_PROBE(h) do { \
|
||||
FIL __chk; \
|
||||
static const uint8_t __chkbuf[8] = { 0 }; \
|
||||
UINT __bw = 0u; \
|
||||
FRESULT __wr; \
|
||||
(h) = f_open(&__chk, "/fschk.tmp", FA_WRITE | FA_OPEN_ALWAYS); \
|
||||
if ((h) == FR_OK) { \
|
||||
__wr = f_write(&__chk, __chkbuf, (UINT)sizeof(__chkbuf), &__bw); \
|
||||
(void)f_close(&__chk); \
|
||||
if (__wr == FR_OK && __bw == (UINT)sizeof(__chkbuf)) { \
|
||||
(h) = FR_OK; \
|
||||
(void)f_unlink("/fschk.tmp"); \
|
||||
} else { \
|
||||
(h) = (__wr != FR_OK) ? __wr : FR_DENIED; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
FRESULT hfr;
|
||||
FS_VOL_PROBE(hfr);
|
||||
if (hfr != FR_OK) {
|
||||
FS_VOL_PROBE(hfr); /* 两击确认 */
|
||||
}
|
||||
if (hfr != FR_OK) {
|
||||
/* ⚠ FR_INVALID_NAME 绝不可入本集合:它是路径名语法错误(纯 RAM 判定、
|
||||
* 不碰盘),与卷健康无关(曾误入 → "无限重格式化"事故) */
|
||||
if (hfr == FR_DENIED || hfr == FR_INVALID_OBJECT ||
|
||||
hfr == FR_INT_ERR || hfr == FR_DISK_ERR ||
|
||||
hfr == FR_NO_FILE || hfr == FR_NO_PATH ||
|
||||
hfr == FR_NO_FILESYSTEM) {
|
||||
DBG_INFO("[FS] volume FAT invalid (fr=%d), reformatting...",
|
||||
(int)hfr);
|
||||
f_mount(NULL, "", 0);
|
||||
/* 格式化前清空 FTL map 树(同首启路径:新卷从空树写起) */
|
||||
(void)nand_ftl_format();
|
||||
{
|
||||
static uint8_t fs_work2[FF_MAX_SS];
|
||||
MKFS_PARM opts2 = { FM_FAT32, 0, 0, 0, 0 };
|
||||
fr = f_mkfs("", &opts2, fs_work2, sizeof(fs_work2));
|
||||
if (fr == FR_OK) {
|
||||
fr = f_mount(fs, "", 1);
|
||||
}
|
||||
}
|
||||
if (fr == FR_OK) {
|
||||
DBG_INFO("[FS] volume reformatted OK");
|
||||
} else {
|
||||
DBG_ERROR("[FS] volume repair failed (fr=%d)", (int)fr);
|
||||
syslog_post(SYSLOG_SELFTEST, "storage fault");
|
||||
}
|
||||
} else {
|
||||
/* 其余错误(写保护/卷锁/参数类)不重格式化——只上报,
|
||||
* 防对写锁卷整卷擦除(FTL 磨损最大操作) */
|
||||
DBG_ERROR("[FS] volume probe failed (fr=%d)", (int)hfr);
|
||||
syslog_post(SYSLOG_SELFTEST, "storage fault");
|
||||
fr = FR_INT_ERR;
|
||||
}
|
||||
}
|
||||
#undef FS_VOL_PROBE
|
||||
if (fr == FR_OK) {
|
||||
DBG_INFO("[FS] FATFS mounted");
|
||||
/* 日志引擎挂载后处理:建 /log 目录 + 写"上电/重启"分类记录(唯一写者) */
|
||||
syslog_mcu_mounted();
|
||||
/* 加载网络配置进 RAM 副本(配置引擎属主 = 本任务;首启含旧档迁移;
|
||||
* 文件缺失/损坏 = 工厂默认,不阻塞组网)。须在置位 STORAGE_READY 前,
|
||||
* 使"存储就绪"屏障蕴含"配置已就绪",netTask 组网时配置恒有效 */
|
||||
(void)net_cfg_load();
|
||||
/* 广播"存储就绪"(= 卷挂载 + 配置加载完成),唤醒依赖文件系统的任务 */
|
||||
if (sys_evtHandle != NULL) {
|
||||
osEventFlagsSet(sys_evtHandle, SYS_EVT_STORAGE_READY);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DBG_ERROR("[FS] f_mount failed (fr=%d)", (int)fr);
|
||||
}
|
||||
|
||||
return fr;
|
||||
}
|
||||
#endif /* !TEST_SUITE_STORAGE */
|
||||
|
||||
/*
|
||||
* 函数功能:"保存网络配置"请求通知(注册给 net_cfg 的保存交接;
|
||||
* 2026-09-25 自 Src/freertos.c 迁出,逻辑零改动)
|
||||
* 入口参数:无
|
||||
* 返回值:无
|
||||
* 限定条件:仅由 uiTask 上下文经 net_cfg 回调调用(只置事件位,无内核对象依赖)
|
||||
* 函数说明:uiTask 投递保存请求 → 置 SYS_EVT_CFG_SAVE → defaultTask 循环
|
||||
* 立即唤醒执行写盘
|
||||
*/
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
static void default_task_net_cfg_save_notify(void) {
|
||||
if (sys_evtHandle != NULL) {
|
||||
(void)osEventFlagsSet(sys_evtHandle, SYS_EVT_CFG_SAVE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 模块名称:Default Application Task
|
||||
* 模块功能:主控任务(defaultTask)任务体:存储 bring-up(挂载/建卷/探针/自愈/
|
||||
* 有界重试)、网络配置引擎属主(保存执行 + 2s 轮询)、控制台单写者
|
||||
* (注册 + 主循环排空)、syslog 落盘、LED 心跳、栈水位观测
|
||||
* 适用平台:STM32F407ZGTx + FreeRTOS(CMSIS-RTOS V2)
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-09-25
|
||||
* 修改记录:
|
||||
* v1.0 2026-09-25 王建锋 自 Src/freertos.c StartDefaultTask 任务体迁出
|
||||
* (CubeMX 生成文件只留任务创建接线与崩溃钩子)
|
||||
*/
|
||||
|
||||
#ifndef DEFAULT_TASK_H
|
||||
#define DEFAULT_TASK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void default_task_func(void *argument);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DEFAULT_TASK_H */
|
||||
@@ -16,7 +16,7 @@ void lftpd_log_internal(const char* level, const char* format, ...) {
|
||||
if (err >= sizeof(buffer)) {
|
||||
return;
|
||||
}
|
||||
/* 走控制台单写者(Src/usart.c):整行一次入缓冲,避免逐字符 fputc 交错 */
|
||||
/* 走控制台单写者(App/log/console_log.c):整行一次入缓冲,避免逐字符 fputc 交错 */
|
||||
int n = snprintf(line, sizeof(line), "%s %s\r\n", level, buffer);
|
||||
if (n > 0) {
|
||||
if (n > (int)sizeof(line) - 1) {
|
||||
|
||||
+4
-17
@@ -30,22 +30,9 @@ extern "C" {
|
||||
#include "sys_clock.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 单写者控制台 API(实现见 Src/usart.c;与 DBG_ENABLE 无关,任何构建都必须可见):
|
||||
* dbg_console_write_line - 生产者入口:调用方已格式化好的整行文本一次入环形缓冲
|
||||
* (刻意**不用**自研可变参数函数——规范 S12 7.6 禁止;格式化在
|
||||
* DBG_PRINT 宏内用库 snprintf 完成)
|
||||
* dbg_console_write_raw - 异常/早期路径:有界单次直发(不加锁)
|
||||
* dbg_console_writer_attach- 写者任务(defaultTask)注册自己为唯一发送者
|
||||
* dbg_console_drain - 写者任务排空缓冲并发送
|
||||
* dbg_console_dropped - 因缓冲满丢弃的行数(诊断)
|
||||
*/
|
||||
#define DBG_CON_LINE_MAX 192U /* 单行文本上限(与 Src/usart.c 内部口径一致) */
|
||||
int dbg_console_write_line(const char *line, unsigned len);
|
||||
void dbg_console_write_raw(const char *buf, unsigned len);
|
||||
void dbg_console_writer_attach(void);
|
||||
void dbg_console_drain(void);
|
||||
uint32_t dbg_console_dropped(void);
|
||||
/* 单写者控制台 API:实现见 App/log/console_log.c(2026-09-24 自 HAL 生成文件
|
||||
* Src/usart.c 迁出);与 DBG_ENABLE 无关,任何构建都必须可见 */
|
||||
#include "console_log.h"
|
||||
|
||||
/*
|
||||
* 总开关:DBG_ENABLE
|
||||
@@ -59,7 +46,7 @@ uint32_t dbg_console_dropped(void);
|
||||
* 可重定向的打印函数,用户可在编译选项或 net_config.h 中预定义
|
||||
* #define DBG_PRINT(...) my_printf(__VA_ARGS__)
|
||||
*
|
||||
* 默认走单写者控制台(Src/usart.c):
|
||||
* 默认走单写者控制台(App/log/console_log.c):
|
||||
* DBG_PRINT 在调用点用库 snprintf 有界格式化整行,再一次性交给 dbg_console_write_line
|
||||
* 入环形缓冲,由 defaultTask 唯一发送——
|
||||
* ① 行与行不会字符级交错(旧 printf→fputc 每字符一次 HAL_UART_Transmit 会交错);
|
||||
|
||||
@@ -774,6 +774,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\App\log\sys_log_mcu.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>console_log.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\App\log\console_log.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sys_clock.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -784,6 +789,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\App\time_sync.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>default_task.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\App\task\default_task.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>net_task.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
||||
@@ -104,6 +104,7 @@ STM32F4-Base/
|
||||
│ ├── sys_events.h # 系统就绪事件定义
|
||||
│ ├── sys_clock.c/h # 墙钟时间管理
|
||||
│ ├── time_sync.c/h # 时间同步任务
|
||||
│ ├── log/ # 日志(sys_log 运行/自检记录、console_log 控制台单写者)
|
||||
│ ├── task/ # FreeRTOS 任务实现
|
||||
│ │ ├── net_task.c/h # 网络任务
|
||||
│ │ ├── ui_task.c/h # UI 任务
|
||||
|
||||
+5
-363
@@ -31,18 +31,12 @@
|
||||
#include "ch395f.h"
|
||||
#include "dbg_log.h"
|
||||
#include "net_socket.h"
|
||||
#include "usart.h"
|
||||
#include "ff.h"
|
||||
#include "gd5f2gq5ue.h"
|
||||
#include "nand_ftl.h"
|
||||
#include "lftpd.h"
|
||||
#include "../test/ch395f_test_task.h"
|
||||
#include "../test/ch395f_test.h" /* ENABLE_NET_LAYER_TESTS:netTask 条件创建 */
|
||||
#include "time_sync.h"
|
||||
#include "sys_events.h"
|
||||
#include "sys_log.h"
|
||||
#include "net_cfg.h"
|
||||
#include "cfg_file.h"
|
||||
#include "default_task.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -52,14 +46,7 @@
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
/* 栈水位观测节奏:首次报告须晚于 bring-up 深链(mount/mkfs/探针/cfg/syslog),
|
||||
* 之后每周期只判定"是否出现更深峰值",无新峰值不打印(保持串口静默窗口) */
|
||||
#define STACK_PROBE_FIRST_MS 5000u
|
||||
#define STACK_PROBE_PERIOD_MS 2000u
|
||||
/* E-31 自愈策略(2026-09-21 审计 P0 修复):启动期存储挂载失败后,
|
||||
* 主循环按 2s 周期重跑完整 bring-up 的次数上限;耗尽则维持无存储降级
|
||||
* (自检已上报、卷保留、不重格式化),等下次上电重新 resume */
|
||||
#define STORAGE_BRINGUP_RETRIES 3u
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
@@ -129,11 +116,6 @@ const osEventFlagsAttr_t sys_evt_attributes = {
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN FunctionPrototypes */
|
||||
void ui_task_func(void *argument);
|
||||
static void stack_probe_poll(void); /* 栈水位观测(可观测性,实现见文件末尾) */
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
static void default_task_net_cfg_save_notify(void);
|
||||
static FRESULT storage_bring_up(FATFS *fs); /* 存储 bring-up(实现见文件末尾) */
|
||||
#endif
|
||||
/* USER CODE END FunctionPrototypes */
|
||||
|
||||
void StartDefaultTask(void *argument);
|
||||
@@ -220,114 +202,9 @@ void MX_FREERTOS_Init(void) {
|
||||
void StartDefaultTask(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN StartDefaultTask */
|
||||
(void)argument;
|
||||
|
||||
/* 系统启动期挂载 NAND 上的 FatFS 卷,供 FTP 及其它模块访问。
|
||||
* f_mount(forced=1) 会触发 disk_initialize() → nand_ftl_init()
|
||||
* (dhara_map_resume)。此前默认构建从未挂载,导致 FTP 的
|
||||
* LIST/STOR/RETR 全部返回 550(f_opendir 失败)。
|
||||
* 完整 bring-up 序列(挂载 + 空卷自动建卷 + 健康探针 + 自愈重格式化
|
||||
* + 日志挂载 + 配置加载 + 就绪屏障)实现于 storage_bring_up()。
|
||||
*
|
||||
* E-31(2026-09-21 审计,P0 修复):dhara_map_resume 失败不再被当
|
||||
* "新卷"静默重格式化(扫描中任何一次瞬态毛刺都会销毁全部用户数据)——
|
||||
* nand_ftl 仅把 DHARA_E_TOO_BAD(真空白)判为新卷,其余失败使
|
||||
* disk_initialize 失败 → f_mount 失败 → 下方自检上报并保留卷;
|
||||
* 瞬态失败由主循环有界重试(STORAGE_BRINGUP_RETRIES 次 × 2s),
|
||||
* 成功后补跑"存储就绪"序列(日志挂载/配置加载/屏障置位,均幂等)。
|
||||
* 探针/重格式化自愈策略仍在 storage_bring_up 内(2026-09-20 修复,
|
||||
* 小写两击确认、FR_INVALID_NAME 不入重格式化集、写保护类只上报,
|
||||
* 详见该函数注释)。 */
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
/* E-31 自愈:存储 bring-up 剩余重试次数(0 = 已就绪或已耗尽);
|
||||
* 须在启动块之前声明(启动块失败路径写入、主循环读取) */
|
||||
uint32_t storage_retry = 0u;
|
||||
#endif
|
||||
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
/* STORAGE 套件构建下 defaultTask 完全跳过存储 bring-up(挂载/配置/日志盘写),
|
||||
* 卷由 testTask 的 storage_test_run 独占——测试含 nand_ftl_deinit 掉电模拟,
|
||||
* 与任何后台文件写入并发都会互相踩坏 FTL/FatFs 状态(2026-09-20 台架实证:
|
||||
* 双写并发导致 mkfs 半途冻结 + BBT 被误写) */
|
||||
static FATFS default_fatfs;
|
||||
FRESULT fr = storage_bring_up(&default_fatfs);
|
||||
if (fr != FR_OK) {
|
||||
/* 存储不可写:自检故障仅能滞留待发队列(串口已告警) */
|
||||
syslog_post(SYSLOG_SELFTEST, "filesystem fault");
|
||||
/* E-31 自愈:启动主循环中的有界重试(每 2s 一次) */
|
||||
storage_retry = STORAGE_BRINGUP_RETRIES;
|
||||
}
|
||||
|
||||
/* 注册"保存网络配置"请求通知:UI(uiTask)投递 → 置事件 → 本任务立即执行写盘
|
||||
* (配置引擎属主 = 本任务;UI 保存不再直接触碰配置文件引擎,P1-3) */
|
||||
net_cfg_set_save_req_cb(default_task_net_cfg_save_notify);
|
||||
#else
|
||||
/* STORAGE 套件构建:挂载/配置引擎/日志盘写全部跳过,存储由 testTask 独占 */
|
||||
DBG_INFO("[FS] mount/cfg skipped (STORAGE suite owns storage)");
|
||||
#endif
|
||||
|
||||
/* 配置 poll 周期计数(每 40 次循环 = 2s 轮询一次,与引擎文档/模拟器一致。
|
||||
* 循环基准 50ms:控制台"待发"事件即时唤醒,无事件时 50ms 兜底,日志时延 <=50ms) */
|
||||
uint32_t cfg_poll_cnt = 0u;
|
||||
uint32_t led_tick = HAL_GetTick();
|
||||
|
||||
/* 注册控制台写者:本任务此后是串口唯一发送者(其余任务只写环形缓冲)。
|
||||
* 见 Src/usart.c "控制台单写者日志"——消除并发写造成的日志逐字符交错,
|
||||
* 并让脏指针无法再进入 HAL_UART_Transmit 的缓冲遍历。 */
|
||||
dbg_console_writer_attach();
|
||||
|
||||
for (;;) {
|
||||
/* 等待"保存网络配置"或"控制台待发":任一即醒;无事件 50ms 后返回
|
||||
* (日志时延 = 事件唤醒,实测无丢失;50ms 兜底仅防事件位异常) */
|
||||
if (sys_evtHandle != NULL) {
|
||||
(void)osEventFlagsWait(sys_evtHandle,
|
||||
SYS_EVT_CFG_SAVE | SYS_EVT_CONSOLE_TX,
|
||||
osFlagsWaitAny, 50u);
|
||||
}
|
||||
/* 控制台唯一发送点:把环形缓冲中的日志按块发出(无待发时立即返回) */
|
||||
dbg_console_drain();
|
||||
/* 执行待处理保存(配置引擎属主:写盘 + 成功后立即应用);无请求 = 空操作 */
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
net_cfg_save_run();
|
||||
#endif
|
||||
/* 配置文件变更轮询(2s 周期;沉降去抖在引擎内) */
|
||||
if ((cfg_poll_cnt++ % 40u) == 0u) {
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
/* E-31 自愈:启动期挂载失败时,每 2s 重跑完整 bring-up——
|
||||
* 瞬态毛刺(如 dhara resume 扫描的瞬时 SPI 故障)通常第二次
|
||||
* 即恢复;成功后由 storage_bring_up 补跑启动时跳过的
|
||||
* "存储就绪"序列(日志挂载/配置加载/屏障置位,均幂等);
|
||||
* 持续性故障耗尽重试则维持无存储降级(自检已在启动/耗尽时
|
||||
* 上报,卷保留、不重格式化,等下次上电重新 resume) */
|
||||
if (storage_retry > 0u) {
|
||||
FRESULT rfr = storage_bring_up(&default_fatfs);
|
||||
if (rfr == FR_OK) {
|
||||
storage_retry = 0u;
|
||||
DBG_INFO("[FS] storage bring-up OK on retry");
|
||||
} else if (--storage_retry == 0u) {
|
||||
DBG_ERROR("[FS] storage retries exhausted (fr=%d), "
|
||||
"storage disabled", (int)rfr);
|
||||
syslog_post(SYSLOG_SELFTEST, "filesystem fault");
|
||||
}
|
||||
}
|
||||
cfg_file_poll();
|
||||
#endif
|
||||
}
|
||||
/* LED 心跳:500ms 翻转一次(与旧 500ms 循环节奏等效;循环基准改 50ms 后
|
||||
* 不能再每轮翻转,否则变成 10Hz 闪烁) */
|
||||
if ((HAL_GetTick() - led_tick) >= 500u) {
|
||||
led_tick = HAL_GetTick();
|
||||
HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
|
||||
HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin);
|
||||
}
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
/* 排空运行期日志(上电/重启分类与自检故障落盘) */
|
||||
syslog_drain();
|
||||
#endif
|
||||
/* 栈水位观测:首次 5s 后报告,此后每 2s 采样、出现更深峰值才打印 */
|
||||
stack_probe_poll();
|
||||
}
|
||||
/* 任务体已迁出至 App/task/default_task.c(2026-09-25):
|
||||
* 本文件只保留 CubeMX 接线(任务创建)与崩溃钩子 */
|
||||
default_task_func(argument);
|
||||
/* USER CODE END StartDefaultTask */
|
||||
}
|
||||
|
||||
@@ -414,241 +291,6 @@ void StartUiTask(void *argument)
|
||||
|
||||
/* Private application code --------------------------------------------------*/
|
||||
/* USER CODE BEGIN Application */
|
||||
/*
|
||||
* 栈水位观测(可观测性,2026-09-21)
|
||||
* 数据源:任务栈"历史最小剩余"——内核按特征值填充法统计(与
|
||||
* configCHECK_FOR_STACK_OVERFLOW=2 同一机制),osThreadGetStackSpace() 取剩余
|
||||
* 字节,配置字节取各任务 *_attributes.stack_size(唯一定义处,避免常量重复;
|
||||
* 本版 CMSIS 包装只有 GetStackSpace 实现,无 osThreadGetStackSize)。
|
||||
* 峰值占用 = 配置 - 剩余。
|
||||
* 定栈规则(docs/内存管理/RAM使用分析与优化方案.md):新栈 = 峰值*1.5 + 1KB ISR
|
||||
* 余量,并要求 free_min >= 新栈*30% 才算合格。
|
||||
* 节奏:首次 STACK_PROBE_FIRST_MS 后报告(bring-up 深链已跑过),此后每
|
||||
* STACK_PROBE_PERIOD_MS 采样一次,只在出现更深峰值时打印——既不改串口静默
|
||||
* 窗口,也不漏掉之后才走到的更深分支(如卷修复/配置保存路径)。
|
||||
* 输出(纯 ASCII,便于 @test 采集):
|
||||
* [STACK] <task> peak_used=<B>/<cfg> free_min=<B> (<pct>%)
|
||||
* [STACK] heap free=<B> min_ever=<B>
|
||||
* 未覆盖 idle/timer 任务(内核静态小栈、纯循环,未取句柄)。
|
||||
*/
|
||||
typedef struct {
|
||||
const char *p_name;
|
||||
const osThreadId_t *p_id;
|
||||
const osThreadAttr_t *p_attr; /* 配置栈大小来源(stack_size) */
|
||||
} stack_probe_task_t;
|
||||
|
||||
static const stack_probe_task_t s_stack_probe[] = {
|
||||
{ "default", &defaultTaskHandle, &defaultTask_attributes },
|
||||
{ "net", &netTaskHandle, &netTask_attributes },
|
||||
{ "ftp", &ftpTaskHandle, &ftpTask_attributes },
|
||||
{ "test", &testTaskHandle, &testTask_attributes },
|
||||
{ "ui", &uiTaskHandle, &uiTask_attributes },
|
||||
{ "timesync", &timeSyncTaskHandle, &timeSyncTask_attributes },
|
||||
};
|
||||
|
||||
#define STACK_PROBE_COUNT (sizeof(s_stack_probe) / sizeof(s_stack_probe[0]))
|
||||
|
||||
static void stack_probe_poll(void)
|
||||
{
|
||||
static uint32_t s_free_min[STACK_PROBE_COUNT]; /* 历史最小剩余(B),0=未采样 */
|
||||
static uint32_t s_last_tick;
|
||||
static uint8_t s_reported;
|
||||
const TickType_t now = xTaskGetTickCount();
|
||||
uint32_t i;
|
||||
uint8_t deeper = 0u;
|
||||
|
||||
if (s_reported == 0u) {
|
||||
if (now < pdMS_TO_TICKS(STACK_PROBE_FIRST_MS)) {
|
||||
return;
|
||||
}
|
||||
} else if ((uint32_t)(now - s_last_tick) < (uint32_t)pdMS_TO_TICKS(STACK_PROBE_PERIOD_MS)) {
|
||||
return;
|
||||
}
|
||||
s_last_tick = (uint32_t)now;
|
||||
|
||||
for (i = 0u; i < (uint32_t)STACK_PROBE_COUNT; i++) {
|
||||
const osThreadId_t th = *(s_stack_probe[i].p_id);
|
||||
uint32_t free_now;
|
||||
|
||||
if (th == NULL) {
|
||||
continue; /* 任务未创建 */
|
||||
}
|
||||
free_now = osThreadGetStackSpace(th);
|
||||
if (free_now == 0u) {
|
||||
continue; /* 句柄不可用:跳过 */
|
||||
}
|
||||
if ((s_free_min[i] == 0u) || (free_now < s_free_min[i])) {
|
||||
s_free_min[i] = free_now; /* 刷新历史最小(= 最深峰值) */
|
||||
deeper = 1u;
|
||||
}
|
||||
}
|
||||
|
||||
if ((s_reported != 0u) && (deeper == 0u)) {
|
||||
return; /* 无新峰值:静默 */
|
||||
}
|
||||
s_reported = 1u;
|
||||
|
||||
for (i = 0u; i < (uint32_t)STACK_PROBE_COUNT; i++) {
|
||||
const uint32_t free_min = s_free_min[i];
|
||||
const uint32_t cfg = (uint32_t)s_stack_probe[i].p_attr->stack_size;
|
||||
|
||||
if (free_min == 0u) {
|
||||
continue;
|
||||
}
|
||||
if (cfg == 0u) {
|
||||
continue;
|
||||
}
|
||||
DBG_INFO("[STACK] %s peak_used=%lu/%lu free_min=%lu (%lu%%)",
|
||||
s_stack_probe[i].p_name,
|
||||
(unsigned long)(cfg - free_min), (unsigned long)cfg,
|
||||
(unsigned long)free_min,
|
||||
(unsigned long)((free_min * 100u) / cfg));
|
||||
}
|
||||
DBG_INFO("[STACK] heap free=%lu min_ever=%lu",
|
||||
(unsigned long)xPortGetFreeHeapSize(),
|
||||
(unsigned long)xPortGetMinimumEverFreeHeapSize());
|
||||
}
|
||||
|
||||
/*
|
||||
* 存储 bring-up:挂载 + 空卷自动建卷 + 卷健康探针(两击)+ 自愈重格式化
|
||||
* + 日志挂载 + 配置加载 + "存储就绪"屏障。
|
||||
*
|
||||
* 由 defaultTask 调用:启动期一次;若失败,主循环每 2s 重试至多
|
||||
* STORAGE_BRINGUP_RETRIES 次(E-31 自愈策略,2026-09-21):dhara_map_resume
|
||||
* 失败分类修复后(nand_ftl.c 仅真空白判新卷,其余失败保留卷并返回
|
||||
* disk_initialize 失败),重试让瞬态毛刺(SPI 瞬时故障/扫描窗口抖动)
|
||||
* 在数秒内免重启恢复,成功时补跑启动期跳过的就绪序列(日志挂载/配置
|
||||
* 加载/屏障置位,三者均幂等、可重跑);持续故障耗尽重试后进入无存储
|
||||
* 降级态(自检已上报、卷保留、不重格式化,等下次上电重新 resume)。
|
||||
*
|
||||
* 探针/重格式化策略(2026-09-20 台架实证修复,原启动块注释迁入):
|
||||
* 小写两击确认防 FTL 瞬态抖动误触发;仅结构性错误集合(已排除
|
||||
* FR_INVALID_NAME)触发自愈重格式化;写保护/卷锁/参数类只上报不重格式化
|
||||
* (防对写锁卷整卷擦除)。
|
||||
*/
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
static FRESULT storage_bring_up(FATFS *fs)
|
||||
{
|
||||
FRESULT fr = f_mount(fs, "", 1);
|
||||
|
||||
if (fr == FR_NO_FILESYSTEM) {
|
||||
/* 卷为空(如恢复/坏块重建后清空):自动格式化建卷
|
||||
* (MKFS_PARM 与存储测试一致:FM_FAT32 / 无分区表) */
|
||||
DBG_INFO("[FS] no FAT volume, formatting NAND...");
|
||||
static uint8_t fs_work[FF_MAX_SS];
|
||||
MKFS_PARM opts = { FM_FAT32, 0, 0, 0, 0 };
|
||||
/* 格式化前清空 FTL map 树:新卷从空树开始写,journal
|
||||
* 不与旧卷残留共存(结构卫生)。注:这不是"无限重格式化"的根因——
|
||||
* 真根因是 FatFs 探针文件名非法(见下方探针注释)。 */
|
||||
(void)nand_ftl_format();
|
||||
fr = f_mkfs("", &opts, fs_work, sizeof(fs_work));
|
||||
if (fr == FR_OK) {
|
||||
fr = f_mount(fs, "", 1);
|
||||
} else {
|
||||
DBG_ERROR("[FS] f_mkfs failed (fr=%d)", (int)fr);
|
||||
}
|
||||
}
|
||||
|
||||
if (fr == FR_OK) {
|
||||
/* 探针:/fschk.tmp 小写一次,验证 FAT 链真实可用。本移植
|
||||
* f_write 簇分配失败返回 FR_OK+短写 → 必须校验写回字节数;短写按
|
||||
* FR_DENIED 归一化(落入下方结构性集合触发重格式化)。
|
||||
* ⚠ 事故教训(2026-09-20 台架实证,"无限重格式化"真根因):本移植
|
||||
* FF_USE_LFN=0,ff.c create_short 把 ".fschk" 点后的 FSCHK 当扩展域
|
||||
* 解析(5 字符 > 3 上限)→ f_open 恒返 FR_INVALID_NAME(6)(纯 RAM
|
||||
* 判定、不碰盘)→ 曾误入下方结构性错误集合 → 每 boot 假失败 →
|
||||
* 无限重格式化。探针名必须严格 8.3:名≤8、扩展≤3、不以点开头。 */
|
||||
#define FS_VOL_PROBE(h) do { \
|
||||
FIL __chk; \
|
||||
static const uint8_t __chkbuf[8] = { 0 }; \
|
||||
UINT __bw = 0u; \
|
||||
FRESULT __wr; \
|
||||
(h) = f_open(&__chk, "/fschk.tmp", FA_WRITE | FA_OPEN_ALWAYS); \
|
||||
if ((h) == FR_OK) { \
|
||||
__wr = f_write(&__chk, __chkbuf, (UINT)sizeof(__chkbuf), &__bw); \
|
||||
(void)f_close(&__chk); \
|
||||
if (__wr == FR_OK && __bw == (UINT)sizeof(__chkbuf)) { \
|
||||
(h) = FR_OK; \
|
||||
(void)f_unlink("/fschk.tmp"); \
|
||||
} else { \
|
||||
(h) = (__wr != FR_OK) ? __wr : FR_DENIED; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
FRESULT hfr;
|
||||
FS_VOL_PROBE(hfr);
|
||||
if (hfr != FR_OK) {
|
||||
FS_VOL_PROBE(hfr); /* 两击确认 */
|
||||
}
|
||||
if (hfr != FR_OK) {
|
||||
/* ⚠ FR_INVALID_NAME 绝不可入本集合:它是路径名语法错误(纯 RAM 判定、
|
||||
* 不碰盘),与卷健康无关(曾误入 → "无限重格式化"事故) */
|
||||
if (hfr == FR_DENIED || hfr == FR_INVALID_OBJECT ||
|
||||
hfr == FR_INT_ERR || hfr == FR_DISK_ERR ||
|
||||
hfr == FR_NO_FILE || hfr == FR_NO_PATH ||
|
||||
hfr == FR_NO_FILESYSTEM) {
|
||||
DBG_INFO("[FS] volume FAT invalid (fr=%d), reformatting...",
|
||||
(int)hfr);
|
||||
f_mount(NULL, "", 0);
|
||||
/* 格式化前清空 FTL map 树(同首启路径:新卷从空树写起) */
|
||||
(void)nand_ftl_format();
|
||||
{
|
||||
static uint8_t fs_work2[FF_MAX_SS];
|
||||
MKFS_PARM opts2 = { FM_FAT32, 0, 0, 0, 0 };
|
||||
fr = f_mkfs("", &opts2, fs_work2, sizeof(fs_work2));
|
||||
if (fr == FR_OK) {
|
||||
fr = f_mount(fs, "", 1);
|
||||
}
|
||||
}
|
||||
if (fr == FR_OK) {
|
||||
DBG_INFO("[FS] volume reformatted OK");
|
||||
} else {
|
||||
DBG_ERROR("[FS] volume repair failed (fr=%d)", (int)fr);
|
||||
syslog_post(SYSLOG_SELFTEST, "storage fault");
|
||||
}
|
||||
} else {
|
||||
/* 其余错误(写保护/卷锁/参数类)不重格式化——只上报,
|
||||
* 防对写锁卷整卷擦除(FTL 磨损最大操作) */
|
||||
DBG_ERROR("[FS] volume probe failed (fr=%d)", (int)hfr);
|
||||
syslog_post(SYSLOG_SELFTEST, "storage fault");
|
||||
fr = FR_INT_ERR;
|
||||
}
|
||||
}
|
||||
#undef FS_VOL_PROBE
|
||||
if (fr == FR_OK) {
|
||||
DBG_INFO("[FS] FATFS mounted");
|
||||
/* 日志引擎挂载后处理:建 /log 目录 + 写"上电/重启"分类记录(唯一写者) */
|
||||
syslog_mcu_mounted();
|
||||
/* 加载网络配置进 RAM 副本(配置引擎属主 = 本任务;首启含旧档迁移;
|
||||
* 文件缺失/损坏 = 工厂默认,不阻塞组网)。须在置位 STORAGE_READY 前,
|
||||
* 使"存储就绪"屏障蕴含"配置已就绪",netTask 组网时配置恒有效 */
|
||||
(void)net_cfg_load();
|
||||
/* 广播"存储就绪"(= 卷挂载 + 配置加载完成),唤醒依赖文件系统的任务 */
|
||||
if (sys_evtHandle != NULL) {
|
||||
osEventFlagsSet(sys_evtHandle, SYS_EVT_STORAGE_READY);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DBG_ERROR("[FS] f_mount failed (fr=%d)", (int)fr);
|
||||
}
|
||||
|
||||
return fr;
|
||||
}
|
||||
#endif /* !TEST_SUITE_STORAGE */
|
||||
|
||||
/*
|
||||
* "保存网络配置"请求通知(注册给 net_cfg 的保存交接):
|
||||
* uiTask 投递保存请求 → 置 SYS_EVT_CFG_SAVE → defaultTask 循环立即唤醒执行写盘
|
||||
*/
|
||||
#if !defined(TEST_SUITE_STORAGE)
|
||||
static void default_task_net_cfg_save_notify(void)
|
||||
{
|
||||
if (sys_evtHandle != NULL) {
|
||||
(void)osEventFlagsSet(sys_evtHandle, SYS_EVT_CFG_SAVE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 名称指针合法性校验(栈溢出/越界可能已破坏 TCB,指针不可信):
|
||||
* 只接受落在 Flash / 主 SRAM / CCM 映射范围内的指针;不校验就直接交给 UART,
|
||||
|
||||
-220
@@ -474,225 +474,5 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
#include <stdio.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "sys_events.h"
|
||||
|
||||
/* ===== 控制台单写者日志(2026-09-24 加固,HardFault 定位结论驱动)=====
|
||||
* 背景:旧路径 DBG_* → printf → fputc **每字符一次** HAL_UART_Transmit。HAL 的锁只保证
|
||||
* "单字节"原子,任务切换发生在字符之间 → 两行日志逐字符交错(2026-09-24 崩溃前
|
||||
* 实测:"[2026-[2026-0909-24 15:2-24 15:27:37:39]…");更严重的是字符串指针一旦
|
||||
* 被破坏,脏指针会直接进入 UART 缓冲遍历(同日 HardFault:BFAR=0x10010000 恰为
|
||||
* CCM 末尾+1,PC 落在 HAL_UART_Transmit 的缓冲读取处)。
|
||||
* 架构:**defaultTask 是唯一串口发送者**;其余任务/上下文只把文本写入环形缓冲。
|
||||
* ① 行级原子:整行在一次临界区内拷入环形缓冲,写者按块一次 HAL_UART_Transmit
|
||||
* 发出 → 行与行不可能再交错(UART 只有这一个调用点);
|
||||
* ② 指针可控:进 UART 的缓冲恒为本文件的环形缓冲,调用方脏指针再也到不了 UART;
|
||||
* ③ 写者未注册(内核启动早期/裸机)或中断上下文:回退直接阻塞发送(无并发或必须裸发)。
|
||||
* 约束:不新增任务、不动态分配;环形缓冲为 BSS(SRAM1,非 CCM),无 DMA 可达性冲突。
|
||||
*/
|
||||
#define DBG_CON_LINE_MAX 192U /* 单行文本上限(含结尾 '\0',超出截断) */
|
||||
#define DBG_CON_RING_SIZE 4096U /* 环形缓冲字节数(必须为 2 的幂) */
|
||||
#define DBG_CON_CHUNK_MAX 256U /* 写者单次 HAL_UART_Transmit 字节上限 */
|
||||
#define DBG_CON_WAIT_MS 200U /* 缓冲满时生产者最长等待(ms),仍满则丢弃并计数 */
|
||||
|
||||
static uint8_t s_con_ring[DBG_CON_RING_SIZE];
|
||||
static volatile uint16_t s_con_head; /* 生产者写入位置 */
|
||||
static volatile uint16_t s_con_tail; /* 写者读取位置 */
|
||||
static volatile uint32_t s_con_drop; /* 因缓冲满丢弃的行数 */
|
||||
static volatile uint8_t s_con_writer_up; /* 1 = 写者已注册(此后走环形缓冲) */
|
||||
static TaskHandle_t s_con_writer_task; /* 写者任务句柄(自等保护用) */
|
||||
|
||||
void dbg_console_write_raw(const char *buf, unsigned len);
|
||||
void dbg_console_writer_attach(void);
|
||||
void dbg_console_drain(void);
|
||||
int dbg_console_write_line(const char *line, unsigned len);
|
||||
uint32_t dbg_console_dropped(void);
|
||||
|
||||
static uint16_t con_used(void)
|
||||
{
|
||||
return (uint16_t)((uint16_t)(s_con_head - s_con_tail) & (DBG_CON_RING_SIZE - 1U));
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:控制台裸发送(异常/早期路径专用:有界、单次、不加锁)
|
||||
* 入口参数:buf - 文本缓冲;len - 字节数(超上限截断)
|
||||
* 限定条件:串口已初始化;仅用于写者未注册、中断/异常上下文、崩溃上报
|
||||
*/
|
||||
void dbg_console_write_raw(const char *buf, unsigned len)
|
||||
{
|
||||
if ((buf == NULL) || (len == 0U)) {
|
||||
return;
|
||||
}
|
||||
if (len > DBG_CON_CHUNK_MAX) {
|
||||
len = DBG_CON_CHUNK_MAX;
|
||||
}
|
||||
(void)HAL_UART_Transmit(&huart1, (uint8_t *)buf, (uint16_t)len, 0xFFFFu);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:注册控制台写者(defaultTask 在进入主循环前调用一次)
|
||||
* 函数说明:注册后生产者改走环形缓冲;未注册时直接阻塞发送(内核启动早期)
|
||||
*/
|
||||
void dbg_console_writer_attach(void)
|
||||
{
|
||||
s_con_writer_task = xTaskGetCurrentTaskHandle();
|
||||
s_con_writer_up = 1U;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:排空环形缓冲(仅写者任务调用)
|
||||
* 函数说明:按块一次 HAL_UART_Transmit 发出;每块完成后再推进读指针(临界区保护)
|
||||
*/
|
||||
void dbg_console_drain(void)
|
||||
{
|
||||
uint16_t used;
|
||||
|
||||
if (s_con_writer_up == 0U) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ((used = con_used()) != 0U) {
|
||||
uint16_t tail = s_con_tail;
|
||||
uint16_t contig = (uint16_t)(DBG_CON_RING_SIZE - tail); /* 到环尾的连续段 */
|
||||
uint16_t n = (used < contig) ? used : contig;
|
||||
|
||||
if (n > DBG_CON_CHUNK_MAX) {
|
||||
n = DBG_CON_CHUNK_MAX;
|
||||
}
|
||||
(void)HAL_UART_Transmit(&huart1, &s_con_ring[tail], n, 0xFFFFu);
|
||||
taskENTER_CRITICAL();
|
||||
s_con_tail = (uint16_t)((uint16_t)(s_con_tail + n) & (DBG_CON_RING_SIZE - 1U));
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
/* 丢弃可观测性:缓冲满丢行必须显式可见(否则会掩盖开机自检/测试标记的丢失) */
|
||||
if (s_con_drop != 0U) {
|
||||
char note[64];
|
||||
uint32_t d = s_con_drop;
|
||||
int n;
|
||||
|
||||
s_con_drop = 0U;
|
||||
n = snprintf(note, sizeof(note), "\r\n[ERR] CONSOLE dropped %lu lines\r\n",
|
||||
(unsigned long)d);
|
||||
if (n > 0) {
|
||||
if (n > (int)sizeof(note) - 1) {
|
||||
n = (int)sizeof(note) - 1;
|
||||
}
|
||||
dbg_console_write_raw(note, (unsigned)n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:把一段文本放入控制台(写者已注册)/直接发出(未注册或中断上下文)
|
||||
* 返回值:0 - 已入缓冲或已直发;-1 - 缓冲满丢弃(计入 dbg_console_dropped)
|
||||
* 函数说明:生产者不持锁等待过久:最多 DBG_CON_WAIT_MS,仍满则丢弃该行;
|
||||
* 写者自身记录日志时先排空缓冲,避免自等。
|
||||
*/
|
||||
static int con_append(const char *buf, uint16_t len)
|
||||
{
|
||||
uint32_t waited = 0U;
|
||||
|
||||
if ((buf == NULL) || (len == 0U)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((s_con_writer_up == 0U) || (__get_IPSR() != 0U)) {
|
||||
dbg_console_write_raw(buf, len);
|
||||
return 0;
|
||||
}
|
||||
if (len > (DBG_CON_RING_SIZE / 2U)) {
|
||||
len = (uint16_t)(DBG_CON_RING_SIZE / 2U); /* 超长保护(正常路径不会触发) */
|
||||
}
|
||||
|
||||
if (xTaskGetCurrentTaskHandle() == s_con_writer_task) {
|
||||
dbg_console_drain(); /* 写者自己记录:先腾空,避免自等 */
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
uint16_t used = con_used();
|
||||
uint16_t free_space = (uint16_t)((DBG_CON_RING_SIZE - 1U) - used);
|
||||
|
||||
if (free_space >= len) {
|
||||
break;
|
||||
}
|
||||
if (waited >= DBG_CON_WAIT_MS) {
|
||||
s_con_drop++;
|
||||
return -1;
|
||||
}
|
||||
vTaskDelay(1);
|
||||
waited++;
|
||||
}
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
uint16_t head = s_con_head;
|
||||
uint16_t first = (uint16_t)(DBG_CON_RING_SIZE - head);
|
||||
uint16_t i;
|
||||
|
||||
if (first > len) {
|
||||
first = len;
|
||||
}
|
||||
for (i = 0U; i < first; i++) {
|
||||
s_con_ring[head + i] = (uint8_t)buf[i];
|
||||
}
|
||||
for (i = first; i < len; i++) {
|
||||
s_con_ring[(uint16_t)((uint16_t)(head + i) & (DBG_CON_RING_SIZE - 1U))] =
|
||||
(uint8_t)buf[i];
|
||||
}
|
||||
s_con_head = (uint16_t)((uint16_t)(head + len) & (DBG_CON_RING_SIZE - 1U));
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
if (sys_evtHandle != NULL) {
|
||||
(void)osEventFlagsSet(sys_evtHandle, SYS_EVT_CONSOLE_TX); /* 唤醒写者 */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:把一行已格式化的文本交给单写者控制台(生产者入口,**非可变参数**)
|
||||
* 入口参数:line - 整行文本(含结尾换行);len - 字节数
|
||||
* 返回值:写入字节数;-1 - 参数非法或被丢弃
|
||||
* 函数说明:整行一次入环形缓冲 → 行级原子(不会与他行交错);调用方缓冲随即可复用。
|
||||
* 刻意不用自研可变参数函数(规范 S12 7.6);格式化由 DBG_PRINT 宏内
|
||||
* 库 snprintf 在调用点完成。
|
||||
*/
|
||||
int dbg_console_write_line(const char *line, unsigned len)
|
||||
{
|
||||
if ((line == NULL) || (len == 0U)) {
|
||||
return -1;
|
||||
}
|
||||
if (len > DBG_CON_LINE_MAX) {
|
||||
len = DBG_CON_LINE_MAX; /* 截断(丢尾,保开头的标记信息) */
|
||||
}
|
||||
if (con_append(line, (uint16_t)len) != 0) {
|
||||
return -1;
|
||||
}
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:已丢弃的日志行数(诊断用)
|
||||
*/
|
||||
uint32_t dbg_console_dropped(void)
|
||||
{
|
||||
return s_con_drop;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:MicroLIB printf 底层重定向(库内部/遗留 printf 调用)
|
||||
* 函数说明:同样只把字节交给单写者路径;未注册写者时直发(与旧行为一致)
|
||||
*/
|
||||
int fputc(int ch, FILE *f)
|
||||
{
|
||||
uint8_t b = (uint8_t)ch;
|
||||
|
||||
(void)f;
|
||||
(void)con_append((const char *)&b, 1U);
|
||||
return ch;
|
||||
}
|
||||
/* USER CODE END 1 */
|
||||
|
||||
@@ -534,7 +534,7 @@ if (nand_ftl_format() == 0) {
|
||||
|
||||
### 10.1 台架实证增补(2026-09,CCM 扩容 + 存储套件排障沉淀)
|
||||
|
||||
7. **单写者规则** — 存储由 **defaultTask 独占**:挂载 / `f_mkfs` / 卷健康探针 / `net_cfg_load` / syslog 落盘 / 配置引擎全收敛于它。netTask / uiTask **不得**直接触碰配置引擎或 FatFS。启用存储测试套件(`TEST_SUITE_STORAGE`)时存储所有权整体移交 testTask,defaultTask 必须**完全跳过**存储 bring-up(`Src/freertos.c` 中 `#if !defined(TEST_SUITE_STORAGE)` 包裹)——否则后台文件写与测试的 `nand_ftl_deinit` 掉电模拟并发,互相踩坏 FTL/FatFs 状态(实测:mkfs 半途冻结 + BBT 被误写)。
|
||||
7. **单写者规则** — 存储由 **defaultTask 独占**:挂载 / `f_mkfs` / 卷健康探针 / `net_cfg_load` / syslog 落盘 / 配置引擎全收敛于它。netTask / uiTask **不得**直接触碰配置引擎或 FatFS。启用存储测试套件(`TEST_SUITE_STORAGE`)时存储所有权整体移交 testTask,defaultTask 必须**完全跳过**存储 bring-up(`App/task/default_task.c` 中 `#if !defined(TEST_SUITE_STORAGE)` 包裹,2026-09-25 自 `Src/freertos.c` 迁出)——否则后台文件写与测试的 `nand_ftl_deinit` 掉电模拟并发,互相踩坏 FTL/FatFs 状态(实测:mkfs 半途冻结 + BBT 被误写)。
|
||||
8. **内存布局与 DMA/CCM 约束** — FreeRTOS 堆(含全部任务栈)已迁至 **CCM `0x10000000`**(64KB,直连 M4 零等待),但 **DMA1/DMA2 物理不可达 CCM**。GD5F 驱动 `GD5F_DMA_THRESHOLD = 1024`:栈上的小缓冲(dhara meta 读 132B、`dhara_nand_is_free` 64B)一律走 **CPU 轮询**、绝不经 DMA;页级大块(2048)才走 DMA 且源/目的**全部是文件作用域静态缓冲**(落 SRAM)。新增任何 DMA 收发缓冲必须①文件作用域静态②大小≥阈值③确认落 SRAM。违反任一条 = 静默数据损坏(CCM 首轮扩容实验实证)。换料注意:克隆片可能缺 SRAM3(CCM),必须重测。
|
||||
9. **LVGL 绘制缓冲越界护栏** — LVGL 9.3.0 对 I1(1bpp) 整帧渲染会在其算出的 `stride*h`(160×160/8=3200) 之后**多写 1 个字节**,紧邻 `g_ui_draw_buf` 之后的 `.bss`(如 `ui_menu_view` 的 `s_frame_box`)指针最低字节被打成 `0xFF` → 野指针 → HardFault(`PC=lv_obj_get_scroll_y`)。`ui_port.c` 的 `g_ui_draw_buf` 已预留 `UI_DRAW_BUF_GUARD=32` 字节护栏吸收该越界写(逻辑尺寸仍按 `UI_FB_SIZE` 上报,渲染数学不变)。**勿删护栏、勿把缓冲缩到与邻接 `.bss` 紧邻**。Lib/LVGL 为第三方不改。
|
||||
10. **FatFs 严格 8.3 短名** — 详见 AGENTS。补充:含冒号 `:` 的名字被 FatFs 先解析为**盘符前缀** → `f_open` 返回 `FR_INVALID_DRIVE`(11) 而非 `FR_INVALID_NAME`(6);两者都属合法拒绝(测试用例须同时接受)。
|
||||
|
||||
+55
-7
@@ -9,11 +9,15 @@ digraph refgraph_full {
|
||||
"App/cfg_file.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/cfg_file_store.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/cfg_file_store_mcu.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/log/console_log.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/log/console_log.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/log/sys_log.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/log/sys_log_mcu.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/sys_events.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/task/adc_task.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/task/adc_task.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/task/default_task.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/task/default_task.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/task/net_task.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/task/net_task.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"App/task/rs485_task.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
@@ -135,6 +139,7 @@ digraph refgraph_full {
|
||||
"simulator/main.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"simulator/sim/cfg_file_store_sim.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"simulator/sim/net_socket_sim.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"simulator/sim/sim_latency_stub.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"simulator/sim/sim_port.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"simulator/sim/sim_port.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"simulator/sim/sim_syslog.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
@@ -144,6 +149,8 @@ digraph refgraph_full {
|
||||
"test/ch395f_test_task.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"test/gd5f_test.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"test/gd5f_test_task.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"test/net_latency_test.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"test/net_latency_test.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"test/net_test_task.c" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"test/net_test_task.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"test/sd2506_test.h" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
@@ -167,13 +174,23 @@ digraph refgraph_full {
|
||||
"App/app_main.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"App/cfg_file.c" -> "App/cfg_file.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/cfg_file.c" -> "App/cfg_file_store.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/cfg_file.c" -> "App/log/sys_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/cfg_file.c" -> "Drivers/BSP/dbg_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/cfg_file.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"App/cfg_file.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"App/cfg_file_store.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"App/cfg_file_store_mcu.c" -> "App/cfg_file_store.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/cfg_file_store_mcu.c" -> "Lib/FatFs/ff.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/cfg_file_store_mcu.c" -> "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/cfg_file_store_mcu.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"App/log/console_log.c" -> "App/log/console_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/log/console_log.c" -> "App/sys_events.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/log/console_log.c" -> "Inc/usart.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/log/console_log.c" -> "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/log/console_log.c" -> "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/log/console_log.c" -> "Middlewares/Third_Party/FreeRTOS/Source/include/task.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/log/console_log.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"App/log/console_log.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"App/log/sys_log.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"App/log/sys_log_mcu.c" -> "App/log/sys_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/log/sys_log_mcu.c" -> "App/util/sys_clock.h" [color="#2563eb", penwidth=1.0];
|
||||
@@ -186,6 +203,19 @@ digraph refgraph_full {
|
||||
"App/task/adc_task.c" -> "Drivers/BSP/TPAFE5160/tpafe5160.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/adc_task.c" -> "Drivers/BSP/dbg_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/adc_task.c" -> "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/task/default_task.c" -> "App/cfg_file.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/default_task.c" -> "App/log/sys_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/default_task.c" -> "App/sys_events.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/default_task.c" -> "App/task/default_task.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/default_task.c" -> "Drivers/BSP/GD5F2GQ5UE/nand_ftl.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/default_task.c" -> "Drivers/BSP/NETCFG/net_cfg.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/default_task.c" -> "Drivers/BSP/dbg_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/default_task.c" -> "Inc/main.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/default_task.c" -> "Lib/FatFs/ff.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/task/default_task.c" -> "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/task/default_task.c" -> "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/task/default_task.c" -> "Middlewares/Third_Party/FreeRTOS/Source/include/task.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/task/default_task.c" -> "test/test_config.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/net_task.c" -> "App/log/sys_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/net_task.c" -> "App/sys_events.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/net_task.c" -> "App/task/net_task.h" [color="#2563eb", penwidth=1.0];
|
||||
@@ -210,6 +240,8 @@ digraph refgraph_full {
|
||||
"App/task/ui_task.c" -> "Drivers/BSP/UI/ui_standby.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/ui_task.c" -> "Drivers/BSP/dbg_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/ui_task.c" -> "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h" [color="#94a3b8", penwidth=0.7];
|
||||
"App/task/ui_task.c" -> "test/net_latency_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/ui_task.c" -> "test/test_config.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/task/ui_task.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"App/time_sync.c" -> "App/sys_events.h" [color="#2563eb", penwidth=1.0];
|
||||
"App/time_sync.c" -> "App/time_sync.h" [color="#2563eb", penwidth=1.0];
|
||||
@@ -266,6 +298,8 @@ digraph refgraph_full {
|
||||
"Drivers/BSP/NET/net_socket.c" -> "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Drivers/BSP/NET/net_socket.c" -> "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Drivers/BSP/NET/net_socket.c" -> "Middlewares/Third_Party/FreeRTOS/Source/include/task.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Drivers/BSP/NET/net_socket.c" -> "test/net_latency_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/NET/net_socket.c" -> "test/test_config.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/NET/net_socket.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"Drivers/BSP/NET/net_socket.h" -> "Drivers/BSP/NET/net_types.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/NET/net_socket.h" -> "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h" [color="#94a3b8", penwidth=0.7];
|
||||
@@ -339,6 +373,8 @@ digraph refgraph_full {
|
||||
"Drivers/BSP/UI/ui_net_sink.c" -> "Drivers/BSP/NET/net_types.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/UI/ui_net_sink.c" -> "Drivers/BSP/UI/ui_net_sink.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/UI/ui_net_sink.c" -> "Drivers/BSP/UI/ui_net_sink_backend.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/UI/ui_net_sink.c" -> "test/net_latency_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/UI/ui_net_sink.c" -> "test/test_config.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/UI/ui_net_sink.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"Drivers/BSP/UI/ui_net_sink.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"Drivers/BSP/UI/ui_net_sink_backend.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
@@ -368,6 +404,7 @@ digraph refgraph_full {
|
||||
"Drivers/BSP/UI/ui_page_selftest.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"Drivers/BSP/UI/ui_page_selftest.h" -> "Drivers/BSP/UI/ui_content_page.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/UI/ui_port.c" -> "Drivers/BSP/UI/ui_port.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/UI/ui_port.c" -> "Drivers/BSP/dbg_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/UI/ui_port.c" -> "Lib/lvgl/lvgl.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Drivers/BSP/UI/ui_port.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"Drivers/BSP/UI/ui_port.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
@@ -378,6 +415,7 @@ digraph refgraph_full {
|
||||
"Drivers/BSP/UI/ui_standby.c" -> "Lib/lvgl/lvgl.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Drivers/BSP/UI/ui_standby.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"Drivers/BSP/UI/ui_standby.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"Drivers/BSP/dbg_log.h" -> "App/log/console_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/dbg_log.h" -> "App/util/sys_clock.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/dbg_log.h" -> "Drivers/BSP/dbg_cfg.h" [color="#2563eb", penwidth=1.0];
|
||||
"Drivers/BSP/dbg_log.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
@@ -401,25 +439,21 @@ digraph refgraph_full {
|
||||
"Inc/stm32f4xx_hal_conf.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"Inc/usart.h" -> "Inc/main.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/dma.c" -> "Inc/dma.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "App/cfg_file.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "App/log/sys_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "App/sys_events.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "App/task/default_task.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "App/task/net_task.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "App/time_sync.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "Drivers/BSP/CH395F/ch395f.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "Drivers/BSP/GD5F2GQ5UE/gd5f2gq5ue.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "Drivers/BSP/NET/lftpd/lftpd.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Src/freertos.c" -> "Drivers/BSP/NET/net_socket.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "Drivers/BSP/NETCFG/net_cfg.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "Drivers/BSP/dbg_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "Inc/main.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "Inc/usart.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "Lib/FatFs/ff.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Src/freertos.c" -> "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Src/freertos.c" -> "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Src/freertos.c" -> "Middlewares/Third_Party/FreeRTOS/Source/include/task.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Src/freertos.c" -> "test/ch395f_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "test/ch395f_test_task.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "test/test_config.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/freertos.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"Src/gpio.c" -> "Inc/gpio.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/i2c.c" -> "Inc/i2c.h" [color="#2563eb", penwidth=1.0];
|
||||
@@ -447,9 +481,9 @@ digraph refgraph_full {
|
||||
"Src/stm32f4xx_hal_timebase_tim.c" -> "Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Src/stm32f4xx_it.c" -> "Inc/main.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/stm32f4xx_it.c" -> "Inc/stm32f4xx_it.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/stm32f4xx_it.c" -> "Inc/usart.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/system_stm32f4xx.c" -> "Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" [color="#94a3b8", penwidth=0.7];
|
||||
"Src/usart.c" -> "Inc/usart.h" [color="#2563eb", penwidth=1.0];
|
||||
"Src/usart.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"simulator/dbg_log.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"simulator/main.c" -> "App/cfg_file.h" [color="#2563eb", penwidth=1.0];
|
||||
"simulator/main.c" -> "App/cfg_file_store.h" [color="#2563eb", penwidth=1.0];
|
||||
@@ -466,6 +500,7 @@ digraph refgraph_full {
|
||||
"simulator/sim/cfg_file_store_sim.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"simulator/sim/net_socket_sim.c" -> "Drivers/BSP/NET/net_socket.h" [color="#2563eb", penwidth=1.0];
|
||||
"simulator/sim/net_socket_sim.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"simulator/sim/sim_latency_stub.c" -> "test/net_latency_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"simulator/sim/sim_port.c" -> "Lib/lvgl/lvgl.h" [color="#94a3b8", penwidth=0.7];
|
||||
"simulator/sim/sim_port.c" -> "simulator/SDL2/SDL2-2.32.10/include/SDL.h" [color="#94a3b8", penwidth=0.7];
|
||||
"simulator/sim/sim_port.c" -> "simulator/sim/sim_port.h" [color="#2563eb", penwidth=1.0];
|
||||
@@ -486,6 +521,7 @@ digraph refgraph_full {
|
||||
"test/ch395f_test_task.c" -> "test/ch395f_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/ch395f_test_task.c" -> "test/ch395f_test_task.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/ch395f_test_task.c" -> "test/gd5f_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/ch395f_test_task.c" -> "test/net_latency_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/ch395f_test_task.c" -> "test/net_test_task.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/ch395f_test_task.c" -> "test/sd2506_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/ch395f_test_task.c" -> "test/storage_test.h" [color="#2563eb", penwidth=1.0];
|
||||
@@ -496,9 +532,19 @@ digraph refgraph_full {
|
||||
"test/gd5f_test_task.c" -> "Drivers/BSP/GD5F2GQ5UE/nand_ftl.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/gd5f_test_task.c" -> "Drivers/BSP/dbg_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/gd5f_test_task.c" -> "Lib/FatFs/ff.h" [color="#94a3b8", penwidth=0.7];
|
||||
"test/gd5f_test_task.c" -> "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h" [color="#94a3b8", penwidth=0.7];
|
||||
"test/gd5f_test_task.c" -> "test/gd5f_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/gd5f_test_task.c" -> "test/test_config.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/gd5f_test_task.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"test/net_latency_test.c" -> "Drivers/BSP/CH395F/ch395f.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_latency_test.c" -> "Drivers/BSP/NET/net_socket.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_latency_test.c" -> "Drivers/BSP/dbg_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_latency_test.c" -> "Inc/main.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_latency_test.c" -> "test/ch395f_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_latency_test.c" -> "test/net_latency_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_latency_test.c" -> "test/test_config.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_latency_test.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"test/net_latency_test.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"test/net_test_task.c" -> "Drivers/BSP/NET/net_select.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_test_task.c" -> "Drivers/BSP/NET/net_socket.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_test_task.c" -> "Drivers/BSP/NET/net_types.h" [color="#2563eb", penwidth=1.0];
|
||||
@@ -506,6 +552,7 @@ digraph refgraph_full {
|
||||
"test/net_test_task.c" -> "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h" [color="#94a3b8", penwidth=0.7];
|
||||
"test/net_test_task.c" -> "test/ch395f_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_test_task.c" -> "test/ch395f_test_task.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_test_task.c" -> "test/net_latency_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_test_task.c" -> "test/net_test_task.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/net_test_task.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"test/sd2506_test.h" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
@@ -523,6 +570,7 @@ digraph refgraph_full {
|
||||
"test/storage_test_task.c" -> "Lib/FatFs/diskio.h" [color="#94a3b8", penwidth=0.7];
|
||||
"test/storage_test_task.c" -> "Lib/FatFs/ff.h" [color="#94a3b8", penwidth=0.7];
|
||||
"test/storage_test_task.c" -> "test/storage_test.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/storage_test_task.c" -> "test/test_config.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/storage_test_task.c" -> "外部/系统头文件" [color="#f59e0b", penwidth=0.6, style=dashed];
|
||||
"test/test_config.c" -> "Drivers/BSP/dbg_log.h" [color="#2563eb", penwidth=1.0];
|
||||
"test/test_config.c" -> "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h" [color="#94a3b8", penwidth=0.7];
|
||||
|
||||
+362
-46
@@ -29,6 +29,14 @@
|
||||
"path": "App/cfg_file_store_mcu.c",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "App/log/console_log.c",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "App/log/console_log.h",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "App/log/sys_log.h",
|
||||
"class": "fp"
|
||||
@@ -49,6 +57,14 @@
|
||||
"path": "App/task/adc_task.h",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "App/task/default_task.c",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "App/task/default_task.h",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "App/task/net_task.c",
|
||||
"class": "fp"
|
||||
@@ -5461,6 +5477,10 @@
|
||||
"path": "simulator/sim/net_socket_sim.c",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "simulator/sim/sim_latency_stub.c",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "simulator/sim/sim_port.c",
|
||||
"class": "fp"
|
||||
@@ -5497,6 +5517,14 @@
|
||||
"path": "test/gd5f_test_task.c",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "test/net_latency_test.c",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "test/net_latency_test.h",
|
||||
"class": "fp"
|
||||
},
|
||||
{
|
||||
"path": "test/net_test_task.c",
|
||||
"class": "fp"
|
||||
@@ -5643,6 +5671,12 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "cfg_file_store.h"
|
||||
},
|
||||
{
|
||||
"from": "App/cfg_file.c",
|
||||
"to": "App/log/sys_log.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "sys_log.h"
|
||||
},
|
||||
{
|
||||
"from": "App/cfg_file.c",
|
||||
"to": "Drivers/BSP/dbg_log.h",
|
||||
@@ -5679,6 +5713,12 @@
|
||||
"kind": "fp-ext",
|
||||
"include": "string.h"
|
||||
},
|
||||
{
|
||||
"from": "App/cfg_file_store_mcu.c",
|
||||
"to": "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h",
|
||||
"kind": "fp-tp",
|
||||
"include": "FreeRTOS.h"
|
||||
},
|
||||
{
|
||||
"from": "App/cfg_file_store_mcu.c",
|
||||
"to": "App/cfg_file_store.h",
|
||||
@@ -5739,6 +5779,60 @@
|
||||
"kind": "fp-ext",
|
||||
"include": "stdint.h"
|
||||
},
|
||||
{
|
||||
"from": "App/log/console_log.c",
|
||||
"to": "App/log/console_log.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "console_log.h"
|
||||
},
|
||||
{
|
||||
"from": "App/log/console_log.c",
|
||||
"to": "外部/系统头文件",
|
||||
"kind": "fp-ext",
|
||||
"include": "stdio.h"
|
||||
},
|
||||
{
|
||||
"from": "App/log/console_log.c",
|
||||
"to": "Inc/usart.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "usart.h"
|
||||
},
|
||||
{
|
||||
"from": "App/log/console_log.c",
|
||||
"to": "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h",
|
||||
"kind": "fp-tp",
|
||||
"include": "FreeRTOS.h"
|
||||
},
|
||||
{
|
||||
"from": "App/log/console_log.c",
|
||||
"to": "Middlewares/Third_Party/FreeRTOS/Source/include/task.h",
|
||||
"kind": "fp-tp",
|
||||
"include": "task.h"
|
||||
},
|
||||
{
|
||||
"from": "App/log/console_log.c",
|
||||
"to": "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h",
|
||||
"kind": "fp-tp",
|
||||
"include": "cmsis_os.h"
|
||||
},
|
||||
{
|
||||
"from": "App/log/console_log.c",
|
||||
"to": "App/sys_events.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "sys_events.h"
|
||||
},
|
||||
{
|
||||
"from": "App/log/console_log.h",
|
||||
"to": "外部/系统头文件",
|
||||
"kind": "fp-ext",
|
||||
"include": "stdio.h"
|
||||
},
|
||||
{
|
||||
"from": "App/log/console_log.h",
|
||||
"to": "外部/系统头文件",
|
||||
"kind": "fp-ext",
|
||||
"include": "stdint.h"
|
||||
},
|
||||
{
|
||||
"from": "App/log/sys_log.h",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -5817,6 +5911,84 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "dbg_log.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "App/task/default_task.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "default_task.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "test/test_config.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "test_config.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h",
|
||||
"kind": "fp-tp",
|
||||
"include": "cmsis_os.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h",
|
||||
"kind": "fp-tp",
|
||||
"include": "FreeRTOS.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "Middlewares/Third_Party/FreeRTOS/Source/include/task.h",
|
||||
"kind": "fp-tp",
|
||||
"include": "task.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "Inc/main.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "main.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "Lib/FatFs/ff.h",
|
||||
"kind": "fp-tp",
|
||||
"include": "ff.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "Drivers/BSP/GD5F2GQ5UE/nand_ftl.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "nand_ftl.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "Drivers/BSP/NETCFG/net_cfg.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "net_cfg.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "App/cfg_file.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "cfg_file.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "App/log/sys_log.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "sys_log.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "App/sys_events.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "sys_events.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/default_task.c",
|
||||
"to": "Drivers/BSP/dbg_log.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "dbg_log.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/net_task.c",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -5961,6 +6133,18 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "sys_clock.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/ui_task.c",
|
||||
"to": "test/test_config.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "test_config.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/ui_task.c",
|
||||
"to": "test/net_latency_test.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "net_latency_test.h"
|
||||
},
|
||||
{
|
||||
"from": "App/task/ui_task.c",
|
||||
"to": "Drivers/BSP/dbg_log.h",
|
||||
@@ -6069,6 +6253,12 @@
|
||||
"kind": "fp-ext",
|
||||
"include": "stddef.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/dbg_log.h",
|
||||
"to": "外部/系统头文件",
|
||||
"kind": "fp-ext",
|
||||
"include": "stdint.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/dbg_log.h",
|
||||
"to": "Drivers/BSP/dbg_cfg.h",
|
||||
@@ -6081,6 +6271,12 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "sys_clock.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/dbg_log.h",
|
||||
"to": "App/log/console_log.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "console_log.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/CH395F/ch395f.c",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -6315,6 +6511,18 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "ch395f.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/NET/net_socket.c",
|
||||
"to": "test/test_config.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "test_config.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/NET/net_socket.c",
|
||||
"to": "test/net_latency_test.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "net_latency_test.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/NET/net_socket.c",
|
||||
"to": "Inc/main.h",
|
||||
@@ -6561,6 +6769,12 @@
|
||||
"kind": "tp-ext",
|
||||
"include": "stdarg.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/NET/lftpd/lftpd_log.c",
|
||||
"to": "Drivers/BSP/dbg_log.h",
|
||||
"kind": "tp-tp",
|
||||
"include": "dbg_log.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/NET/lftpd/lftpd_string.c",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -7053,6 +7267,18 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "ui_net_sink_backend.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/UI/ui_net_sink.c",
|
||||
"to": "test/test_config.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "test_config.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/UI/ui_net_sink.c",
|
||||
"to": "test/net_latency_test.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "net_latency_test.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/UI/ui_net_sink.h",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -7233,6 +7459,12 @@
|
||||
"kind": "fp-tp",
|
||||
"include": "lvgl.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/UI/ui_port.c",
|
||||
"to": "Drivers/BSP/dbg_log.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "dbg_log.h"
|
||||
},
|
||||
{
|
||||
"from": "Drivers/BSP/UI/ui_port.h",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -8775,6 +9007,12 @@
|
||||
"kind": "tp-tp",
|
||||
"include": "diskio.h"
|
||||
},
|
||||
{
|
||||
"from": "Lib/FatFs/ff.c",
|
||||
"to": "Drivers/BSP/dbg_log.h",
|
||||
"kind": "tp-tp",
|
||||
"include": "dbg_log.h"
|
||||
},
|
||||
{
|
||||
"from": "Lib/FatFs/ff.c",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -38259,6 +38497,12 @@
|
||||
"kind": "fp-ext",
|
||||
"include": "stdio.h"
|
||||
},
|
||||
{
|
||||
"from": "simulator/sim/cfg_file_store_sim.c",
|
||||
"to": "外部/系统头文件",
|
||||
"kind": "fp-ext",
|
||||
"include": "stdlib.h"
|
||||
},
|
||||
{
|
||||
"from": "simulator/sim/cfg_file_store_sim.c",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -38307,6 +38551,12 @@
|
||||
"kind": "fp-ext",
|
||||
"include": "stdio.h"
|
||||
},
|
||||
{
|
||||
"from": "simulator/sim/sim_latency_stub.c",
|
||||
"to": "test/net_latency_test.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "net_latency_test.h"
|
||||
},
|
||||
{
|
||||
"from": "simulator/sim/sim_port.c",
|
||||
"to": "simulator/sim/sim_port.h",
|
||||
@@ -38415,6 +38665,12 @@
|
||||
"kind": "fp-tp",
|
||||
"include": "cmsis_os.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/freertos.c",
|
||||
"to": "test/test_config.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "test_config.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/freertos.c",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -38445,24 +38701,6 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "net_socket.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/freertos.c",
|
||||
"to": "Inc/usart.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "usart.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/freertos.c",
|
||||
"to": "Lib/FatFs/ff.h",
|
||||
"kind": "fp-tp",
|
||||
"include": "ff.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/freertos.c",
|
||||
"to": "Drivers/BSP/GD5F2GQ5UE/gd5f2gq5ue.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "gd5f2gq5ue.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/freertos.c",
|
||||
"to": "Drivers/BSP/NET/lftpd/lftpd.h",
|
||||
@@ -38495,21 +38733,9 @@
|
||||
},
|
||||
{
|
||||
"from": "Src/freertos.c",
|
||||
"to": "App/log/sys_log.h",
|
||||
"to": "App/task/default_task.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "sys_log.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/freertos.c",
|
||||
"to": "Drivers/BSP/NETCFG/net_cfg.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "net_cfg.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/freertos.c",
|
||||
"to": "App/cfg_file.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "cfg_file.h"
|
||||
"include": "default_task.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/gpio.c",
|
||||
@@ -38673,6 +38899,12 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "stm32f4xx_it.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/stm32f4xx_it.c",
|
||||
"to": "Inc/usart.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "usart.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/system_stm32f4xx.c",
|
||||
"to": "Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h",
|
||||
@@ -38685,12 +38917,6 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "usart.h"
|
||||
},
|
||||
{
|
||||
"from": "Src/usart.c",
|
||||
"to": "外部/系统头文件",
|
||||
"kind": "fp-ext",
|
||||
"include": "stdio.h"
|
||||
},
|
||||
{
|
||||
"from": "test/ch395f_test.h",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -38721,6 +38947,12 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "net_test_task.h"
|
||||
},
|
||||
{
|
||||
"from": "test/ch395f_test_task.c",
|
||||
"to": "test/net_latency_test.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "net_latency_test.h"
|
||||
},
|
||||
{
|
||||
"from": "test/ch395f_test_task.c",
|
||||
"to": "Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h",
|
||||
@@ -38799,6 +39031,12 @@
|
||||
"kind": "fp-ext",
|
||||
"include": "string.h"
|
||||
},
|
||||
{
|
||||
"from": "test/gd5f_test_task.c",
|
||||
"to": "Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h",
|
||||
"kind": "fp-tp",
|
||||
"include": "FreeRTOS.h"
|
||||
},
|
||||
{
|
||||
"from": "test/gd5f_test_task.c",
|
||||
"to": "test/test_config.h",
|
||||
@@ -38829,6 +39067,60 @@
|
||||
"kind": "fp-tp",
|
||||
"include": "ff.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_latency_test.c",
|
||||
"to": "外部/系统头文件",
|
||||
"kind": "fp-ext",
|
||||
"include": "string.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_latency_test.c",
|
||||
"to": "test/net_latency_test.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "net_latency_test.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_latency_test.c",
|
||||
"to": "test/ch395f_test.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "ch395f_test.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_latency_test.c",
|
||||
"to": "Drivers/BSP/CH395F/ch395f.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "ch395f.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_latency_test.c",
|
||||
"to": "Drivers/BSP/NET/net_socket.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "net_socket.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_latency_test.c",
|
||||
"to": "test/test_config.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "test_config.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_latency_test.c",
|
||||
"to": "Inc/main.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "main.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_latency_test.c",
|
||||
"to": "Drivers/BSP/dbg_log.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "dbg_log.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_latency_test.h",
|
||||
"to": "外部/系统头文件",
|
||||
"kind": "fp-ext",
|
||||
"include": "stdint.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_test_task.c",
|
||||
"to": "外部/系统头文件",
|
||||
@@ -38871,6 +39163,12 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "net_test_task.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_test_task.c",
|
||||
"to": "test/net_latency_test.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "net_latency_test.h"
|
||||
},
|
||||
{
|
||||
"from": "test/net_test_task.c",
|
||||
"to": "Drivers/BSP/dbg_log.h",
|
||||
@@ -38967,6 +39265,12 @@
|
||||
"kind": "fp-fp",
|
||||
"include": "dbg_log.h"
|
||||
},
|
||||
{
|
||||
"from": "test/storage_test_task.c",
|
||||
"to": "test/test_config.h",
|
||||
"kind": "fp-fp",
|
||||
"include": "test_config.h"
|
||||
},
|
||||
{
|
||||
"from": "test/storage_test_task.c",
|
||||
"to": "test/storage_test.h",
|
||||
@@ -39085,6 +39389,13 @@
|
||||
"App/cfg_file_store_mcu.c": [
|
||||
"string.h"
|
||||
],
|
||||
"App/log/console_log.c": [
|
||||
"stdio.h"
|
||||
],
|
||||
"App/log/console_log.h": [
|
||||
"stdint.h",
|
||||
"stdio.h"
|
||||
],
|
||||
"App/log/sys_log.h": [
|
||||
"stddef.h",
|
||||
"stdint.h"
|
||||
@@ -39269,6 +39580,7 @@
|
||||
],
|
||||
"Drivers/BSP/dbg_log.h": [
|
||||
"stddef.h",
|
||||
"stdint.h",
|
||||
"stdio.h"
|
||||
],
|
||||
"Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h": [
|
||||
@@ -40481,9 +40793,6 @@
|
||||
"stdio.h",
|
||||
"string.h"
|
||||
],
|
||||
"Src/usart.c": [
|
||||
"stdio.h"
|
||||
],
|
||||
"simulator/SDL2/SDL2-2.32.10/include/SDL2/SDL_assert.h": [
|
||||
"signal.h"
|
||||
],
|
||||
@@ -40730,6 +41039,7 @@
|
||||
],
|
||||
"simulator/sim/cfg_file_store_sim.c": [
|
||||
"stdio.h",
|
||||
"stdlib.h",
|
||||
"string.h",
|
||||
"sys/stat.h"
|
||||
],
|
||||
@@ -40760,6 +41070,12 @@
|
||||
"test/gd5f_test_task.c": [
|
||||
"string.h"
|
||||
],
|
||||
"test/net_latency_test.c": [
|
||||
"string.h"
|
||||
],
|
||||
"test/net_latency_test.h": [
|
||||
"stdint.h"
|
||||
],
|
||||
"test/net_test_task.c": [
|
||||
"string.h"
|
||||
],
|
||||
@@ -40781,11 +41097,11 @@
|
||||
]
|
||||
},
|
||||
"stats": {
|
||||
"files_indexed": 1396,
|
||||
"includes_parsed": 5588,
|
||||
"resolved": 4539,
|
||||
"unresolved": 1049,
|
||||
"nodes_fp": 126,
|
||||
"files_indexed": 1403,
|
||||
"includes_parsed": 5634,
|
||||
"resolved": 4579,
|
||||
"unresolved": 1055,
|
||||
"nodes_fp": 133,
|
||||
"nodes_tp": 1256,
|
||||
"ext_names": 353
|
||||
},
|
||||
|
||||
+2199
-1911
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 287 KiB After Width: | Height: | Size: 304 KiB |
+33
-26
@@ -28,7 +28,7 @@ digraph refgraph_module {
|
||||
"test" [fillcolor="#dbeafe", color="#1d4ed8"];
|
||||
"其他(第三方)" [fillcolor="#f3f4f6", color="#9ca3af"];
|
||||
"外部/系统头文件" [shape=ellipse, fillcolor="#fef3c7", color="#d97706"];
|
||||
"App" -> "App/log" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App" -> "App/log" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"App" -> "App/util" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"App" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×3"];
|
||||
"App" -> "BSP/GD5F2GQ5UE" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
@@ -37,32 +37,38 @@ digraph refgraph_module {
|
||||
"App" -> "BSP/SD2506" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App" -> "BSP/TPAFE5160" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App" -> "FatFs" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"App" -> "Src/Inc (CubeMX)" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"App" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×7"];
|
||||
"App/log" -> "App" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/log" -> "App/util" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/log" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/log" -> "FatFs" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/log" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/log" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×2"];
|
||||
"App/task" -> "App" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"App/task" -> "App/log" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/log" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"App/log" -> "Src/Inc (CubeMX)" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/log" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×4"];
|
||||
"App/task" -> "App" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"App/task" -> "App/log" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"App/task" -> "App/util" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/task" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"App/task" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×5"];
|
||||
"App/task" -> "BSP/CH395F" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/task" -> "BSP/GD5F2GQ5UE" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/task" -> "BSP/NET" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"App/task" -> "BSP/NETCFG" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/task" -> "BSP/NETCFG" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"App/task" -> "BSP/RS485" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/task" -> "BSP/TPAFE5160" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/task" -> "BSP/UI" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"App/task" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"App/task" -> "test" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/task" -> "FatFs" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/task" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×7"];
|
||||
"App/task" -> "Src/Inc (CubeMX)" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/task" -> "test" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"App/task" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×2"];
|
||||
"App/util" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/util" -> "BSP/SD2506" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/util" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"App/util" -> "Src/Inc (CubeMX)" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"App/util" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×4"];
|
||||
"BSP(公共)" -> "App/log" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"BSP(公共)" -> "App/util" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"BSP(公共)" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×1"];
|
||||
"BSP/CH395F" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
@@ -77,6 +83,7 @@ digraph refgraph_module {
|
||||
"BSP/NET" -> "BSP/CH395F" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"BSP/NET" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×8"];
|
||||
"BSP/NET" -> "Src/Inc (CubeMX)" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"BSP/NET" -> "test" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"BSP/NET" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×3"];
|
||||
"BSP/NETCFG" -> "App" [color="#2563eb", penwidth=1.2, label="×3"];
|
||||
"BSP/NETCFG" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
@@ -87,14 +94,16 @@ digraph refgraph_module {
|
||||
"BSP/TPAFE5160" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"BSP/TPAFE5160" -> "Src/Inc (CubeMX)" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"BSP/UI" -> "App/log" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"BSP/UI" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"BSP/UI" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×5"];
|
||||
"BSP/UI" -> "BSP/NET" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"BSP/UI" -> "BSP/NETCFG" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"BSP/UI" -> "LVGL" [color="#2563eb", penwidth=1.2, label="×9"];
|
||||
"BSP/UI" -> "test" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"BSP/UI" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×20"];
|
||||
"CMSIS" -> "HAL" [color="#94a3b8", penwidth=0.7, label="×1"];
|
||||
"CMSIS" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×22"];
|
||||
"FatFs" -> "App/util" [color="#94a3b8", penwidth=0.7, label="×1"];
|
||||
"FatFs" -> "BSP(公共)" [color="#94a3b8", penwidth=0.7, label="×1"];
|
||||
"FatFs" -> "FreeRTOS" [color="#94a3b8", penwidth=0.7, label="×1"];
|
||||
"FatFs" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×2"];
|
||||
"FreeRTOS" -> "CMSIS" [color="#94a3b8", penwidth=0.7, label="×1"];
|
||||
@@ -109,27 +118,24 @@ digraph refgraph_module {
|
||||
"LVGL" -> "其他(第三方)" [color="#94a3b8", penwidth=0.7, label="×1"];
|
||||
"LVGL" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×204"];
|
||||
"SDL2" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×36"];
|
||||
"Src/Inc (CubeMX)" -> "App" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"Src/Inc (CubeMX)" -> "App/log" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "App/task" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "App" [color="#2563eb", penwidth=1.2, label="×3"];
|
||||
"Src/Inc (CubeMX)" -> "App/task" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"Src/Inc (CubeMX)" -> "App/util" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"Src/Inc (CubeMX)" -> "BSP/CH395F" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"Src/Inc (CubeMX)" -> "BSP/GD5F2GQ5UE" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"Src/Inc (CubeMX)" -> "BSP/GD5F2GQ5UE" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "BSP/NET" [color="#2563eb", penwidth=1.2, label="×3"];
|
||||
"Src/Inc (CubeMX)" -> "BSP/NETCFG" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "BSP/RS485" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "BSP/SD2506" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "BSP/TPAFE5160" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "CMSIS" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "FatFs" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"Src/Inc (CubeMX)" -> "HAL" [color="#2563eb", penwidth=1.2, label="×14"];
|
||||
"Src/Inc (CubeMX)" -> "lftpd" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"Src/Inc (CubeMX)" -> "test" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"Src/Inc (CubeMX)" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×5"];
|
||||
"Src/Inc (CubeMX)" -> "test" [color="#2563eb", penwidth=1.2, label="×3"];
|
||||
"Src/Inc (CubeMX)" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×4"];
|
||||
"dhara" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×5"];
|
||||
"lftpd" -> "BSP(公共)" [color="#94a3b8", penwidth=0.7, label="×3"];
|
||||
"lftpd" -> "BSP(公共)" [color="#94a3b8", penwidth=0.7, label="×4"];
|
||||
"lftpd" -> "BSP/NET" [color="#94a3b8", penwidth=0.7, label="×3"];
|
||||
"lftpd" -> "FatFs" [color="#94a3b8", penwidth=0.7, label="×2"];
|
||||
"lftpd" -> "FreeRTOS" [color="#94a3b8", penwidth=0.7, label="×2"];
|
||||
@@ -141,16 +147,17 @@ digraph refgraph_module {
|
||||
"simulator" -> "BSP/UI" [color="#2563eb", penwidth=1.2, label="×5"];
|
||||
"simulator" -> "LVGL" [color="#2563eb", penwidth=1.2, label="×3"];
|
||||
"simulator" -> "SDL2" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"simulator" -> "test" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"simulator" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×6"];
|
||||
"test" -> "App" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"test" -> "App/task" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"test" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×6"];
|
||||
"test" -> "BSP/CH395F" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"test" -> "BSP(公共)" [color="#2563eb", penwidth=1.2, label="×7"];
|
||||
"test" -> "BSP/CH395F" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"test" -> "BSP/GD5F2GQ5UE" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"test" -> "BSP/NET" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"test" -> "BSP/NET" [color="#2563eb", penwidth=1.2, label="×5"];
|
||||
"test" -> "BSP/SD2506" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"test" -> "FatFs" [color="#2563eb", penwidth=1.2, label="×3"];
|
||||
"test" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×4"];
|
||||
"test" -> "Src/Inc (CubeMX)" [color="#2563eb", penwidth=1.2, label="×1"];
|
||||
"test" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×10"];
|
||||
"test" -> "FreeRTOS" [color="#2563eb", penwidth=1.2, label="×5"];
|
||||
"test" -> "Src/Inc (CubeMX)" [color="#2563eb", penwidth=1.2, label="×2"];
|
||||
"test" -> "外部/系统头文件" [color="#94a3b8", penwidth=0.7, label="×12"];
|
||||
}
|
||||
|
||||
+603
-554
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 97 KiB |
@@ -204,7 +204,7 @@ void vApplicationMallocFailedHook(void)
|
||||
|
||||
#### 0.2 运行时栈水位(已落地:`stack_probe_poll`,2026-09-21)
|
||||
|
||||
实现位置:`Src/freertos.c` 的 USER CODE 区(**不新增文件**,无 Keil/CMake 双端注册成本)。
|
||||
实现位置:`App/task/default_task.c` 的 `stack_probe_poll`(2026-09-21 落地于 `Src/freertos.c` USER CODE 区,2026-09-25 随 defaultTask 任务体整体迁出至 `App/task/` 并注册 Keil 工程 App 组)。
|
||||
数据源是本版 CMSIS/FreeRTOS **已有**的 API:`osThreadGetStackSpace()`(剩余字节,内部走
|
||||
`uxTaskGetStackHighWaterMark`,特征值法与 `configCHECK_FOR_STACK_OVERFLOW=2` 同源)。
|
||||
本版**没有** `osThreadGetStackSize` 实现,也**没有** `ulTaskGetStackDepth` /
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
# 控制台单写者日志设计说明
|
||||
|
||||
> **版本**:v1.1(已实施)
|
||||
> **日期**:2026-09-25
|
||||
> **状态**:已实施并验证——`@build` 0 错误 0 警告、`@test` 硬件闭环 PASS(2026-09-25,见 §10);设计 2026-09-24 加固实施(当时位于 `Src/usart.c` USER CODE 区),2026-09-25 实现迁出至 `App/log/`(HAL 生成文件不含应用代码);同日写者任务体自 `Src/freertos.c` 迁至 `App/task/default_task.c`(与其余 5 任务文件同址归位)
|
||||
> **关联文档**:`项目架构总览.md` · `运行与自检记录设计说明.md`(姊妹模块:持久化日志,同一写者任务) · `测试说明/链路延迟测试说明.md`(D6 日志税 / S8 非阻塞日志,需求出处) · AGENTS.md「平台约束」
|
||||
|
||||
## 1. 背景:实测故障与根因
|
||||
|
||||
### 1.1 实测故障(2026-09-24,双证据)
|
||||
|
||||
| # | 症状 | 实测证据 | 后果 |
|
||||
|---|------|---------|------|
|
||||
| F1 | 日志行字符级交错 | 崩溃前两行日志逐字符交错:`"[2026-[2026-0909-24 15:2-24 15:27:37:39]…"` | @test 必检标记可能假性丢失、日志不可读 |
|
||||
| F2 | HardFault(脏指针直接进入 UART) | BFAR=0x10010000(恰为 CCM 末尾+1),PC 落在 `HAL_UART_Transmit` 的缓冲读取处 | 崩溃上报路径自身再崩;被破坏的字符串指针被 UART 逐字节读取 |
|
||||
|
||||
前兆:2026-09-22 链路延迟测试实测**开机连续丢行**(多任务并发 `printf` → 非重入 `fputc`/`HAL_UART_Transmit` 丢整行,~2s 自恢复;`链路延迟测试说明.md` §9.2)——同类竞态的温和形态,当时列为 S8 待办(日志非阻塞化)。
|
||||
|
||||
### 1.2 根因分析(旧路径:`DBG_*` → `printf` → `fputc`)
|
||||
|
||||
| # | 根因 | 机理 | 对应故障 |
|
||||
|---|------|------|---------|
|
||||
| C1 | 逐字符发送 | `fputc` 每字符一次 `HAL_UART_Transmit(1 字节)`;两次调用之间可发生任务切换 | F1 交错 |
|
||||
| C2 | 调用方缓冲直达 UART | `HAL_UART_Transmit` 的缓冲指针是调用方(可能已被破坏)的指针 | F2 HardFault |
|
||||
| C3 | 多任务并发直触 UART | 轮询 Transmit 的并发保护是 `gState` 状态标志(§3.4):竞争失败方**立即**返回 `HAL_BUSY`(不等待、不重试),返回值被忽略 → 静默丢数据 | 09-22 丢行 |
|
||||
|
||||
HAL 并发语义(本仓库实现实测,`stm32f4xx_hal_uart.c:1135`):轮询版 `HAL_UART_Transmit` **不加** `__HAL_LOCK`(`huart->Lock` 标志仅 IT/DMA 路径使用,`stm32f4xx_hal_def.h:93`);入函数检查 `gState==READY`,全程保持 `BUSY_TX` 直到发完 —— **单次调用是原子的,但调用之间没有排队机制**:并发调用方立即拿到 `HAL_BUSY`。逐字符路径下(C1)"单次调用 = 单字节",原子性退化为字节级(→ F1);整行路径下竞争失败方整行丢失(→ C3)。
|
||||
|
||||
## 2. 设计目标与约束
|
||||
|
||||
### 2.1 目标
|
||||
|
||||
| # | 目标 | 达成方式 |
|
||||
|---|------|---------|
|
||||
| G1 | 行级原子:不同行不再逐字符交错 | 整行一次性入环形缓冲;唯一写者发出(UART 全局只有一个发送调用点) |
|
||||
| G2 | 指针可控:进入 `HAL_UART_Transmit` 的缓冲恒受本模块控制 | 调用方指针只经拷贝入环、到不了 UART;写者发出的缓冲恒为环形缓冲或模块本地静态缓冲 |
|
||||
| G3 | 不新增任务、不用 C 库堆、不新增内核对象 | 复用既有 defaultTask 作写者;环形缓冲 = 4KB 静态 BSS;复用 `sys_evt` 事件标志位 |
|
||||
| G4 | 内核启动前 / 写者未注册 / ISR / 异常钩子路径不降级 | 回退:有界直发(`dbg_console_write_raw`,≤256B 截断、不等待、不死锁、零内核对象) |
|
||||
| G5 | 缓冲满丢行必须可观测 | 丢弃计数 + 写者刷出 `[ERR] CONSOLE dropped N lines` —— 含 `[ERR]` 模式,`@test` Forbidden 判 FAIL,丢失永不静默 |
|
||||
|
||||
### 2.2 约束
|
||||
|
||||
| # | 约束 | 出处 |
|
||||
|---|------|------|
|
||||
| K1 | 内核启动前禁止创建/使用任何 FreeRTOS/CMSIS-RTOS 对象 | AGENTS.md 平台约束(2026-09-20 启动失败实证根因)→ 本模块内核前纯 BSS/寄存器机制 |
|
||||
| K2 | 禁止 `malloc/calloc/realloc`(C 堆仅 512B) | AGENTS.md P0-1 → 全部状态静态 BSS |
|
||||
| K3 | HAL 生成文件(`Src/`、`Inc/`)不含应用代码 | 2026-09-25 迁移动机 → 实现位于 `App/log/` |
|
||||
| K4 | 生产者阻塞时间有界 | 最多 `DBG_CON_WAIT_MS`(200ms),日志不得阻塞业务 |
|
||||
| K5 | RAM 预算紧张,新增静态内存必须核算 | §8 |
|
||||
|
||||
## 3. 总体架构
|
||||
|
||||
### 3.1 单写者模型
|
||||
|
||||
| 角色 | 实体 | 职责 |
|
||||
|------|------|------|
|
||||
| 生产者 | 全部任务 + 内核前主线程 + ISR | 调用点格式化整行(库 `snprintf`)→ `dbg_console_write_line()` |
|
||||
| 写者 | **defaultTask(唯一)** | 进主循环前 `dbg_console_writer_attach()` 注册为唯一发送者;循环内周期 `dbg_console_drain()` |
|
||||
| 物理通道 | USART1(PA9 TX / PA10 RX,115200,8N1) | 轮询发送(`HAL_UART_Transmit`);CubeMX 配置的 DMA TX(DMA2_Stream7)未使用 |
|
||||
| 唤醒 | `SYS_EVT_CONSOLE_TX`(`sys_evt` bit 6) | **消费型命令位**(`osFlagsWaitAny` 默认消费,与 AGENTS.md 事件位语义一致;区别于就绪位必须 `osFlagsNoClear`) |
|
||||
|
||||
**与其他日志子系统的关系**(同一"单写者纪律",同一属主任务):
|
||||
|
||||
| 子系统 | 通道 | 写者 | 持久化 |
|
||||
|--------|------|------|--------|
|
||||
| 控制台单写者(本文档) | USART1 串口 | defaultTask | 无(易失,复位丢失)——实时调试流 |
|
||||
| sys_log 运行/自检记录 | FatFS `/log/*.log` | defaultTask(同一任务) | 是(定长 64B 记录,`运行与自检记录设计说明.md`) |
|
||||
| 配置引擎 | FatFS `/config.ini` | defaultTask(同一任务) | 是 |
|
||||
|
||||
defaultTask 主循环按序处理:控制台排空 → 配置保存执行 → 2s 配置轮询 → LED 心跳 → syslog 落盘 → 栈水位观测——同一任务串行化三类 I/O,任务间零竞争。
|
||||
|
||||
### 3.2 文件清单
|
||||
|
||||
| 文件 | 端 | 角色 |
|
||||
|------|-----|------|
|
||||
| `App/log/console_log.h` | MCU | API 声明:5 个控制台函数 + `fputc` retarget + `DBG_CON_LINE_MAX` |
|
||||
| `App/log/console_log.c` | MCU | 实现:环形缓冲 / 生产者 / 写者 / 裸发 / `fputc` |
|
||||
| `Drivers/BSP/dbg_log.h` | 共享 | `#include "console_log.h"`;`DBG_PRINT` 宏绑定 `dbg_console_write_line`(整行一次入环) |
|
||||
| `simulator/dbg_log.h` | 模拟器 | `printf` stub——模拟器不编译本模块(宿主 `printf` 天然串行,无需单写者) |
|
||||
| `App/task/default_task.c` | MCU | 写者任务体:`dbg_console_writer_attach()` 注册 + 主循环 `dbg_console_drain()`;含存储 bring-up / 配置引擎 / syslog 落盘 / LED / 栈水位(2026-09-25 自 `Src/freertos.c` 迁出) |
|
||||
| `Src/freertos.c` | MCU | CubeMX 接线:6 任务创建 + netMsgQueue + sys_evt;栈溢出/堆失败钩子裸发(任务名先范围校验再拷入本地缓冲) |
|
||||
| `Src/usart.c` | MCU | 纯 CubeMX 生成(UART 初始化 / MspInit / 句柄声明)——零应用代码 |
|
||||
|
||||
### 3.3 拓扑
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph P["生产者(任意上下文)"]
|
||||
P1["netTask / ftpTask / uiTask / timeSync / testTask"]
|
||||
P2["内核前主线程<br/>(MX init / app_main_init)"]
|
||||
P3["ISR / 异常钩子"]
|
||||
end
|
||||
R["环形缓冲 4KB<br/>BSS(SRAM1)<br/>head/tail 16 位回绕"]
|
||||
E["sys_evt bit6<br/>SYS_EVT_CONSOLE_TX"]
|
||||
W["写者 = defaultTask<br/>dbg_console_drain()"]
|
||||
U["USART1 115200<br/>(PA9/PA10, 轮询)"]
|
||||
|
||||
P1 -- "dbg_console_write_line(整行 ≤192B)" --> R
|
||||
R --> E --> W
|
||||
W -- "HAL_UART_Transmit(块 ≤256B)" --> U
|
||||
P2 -- "写者未注册:整行直发" --> U
|
||||
P3 -- "有界直发 ≤256B" --> U
|
||||
```
|
||||
|
||||
### 3.4 HAL 并发语义与本设计的配合(实现实测)
|
||||
|
||||
轮询 `HAL_UART_Transmit`(`stm32f4xx_hal_uart.c:1135`):`gState READY → BUSY_TX(全程)→ READY`;并发调用见非 READY **立即**返回 `HAL_BUSY`(不排队)。本设计的三个运行区间:
|
||||
|
||||
| 区间 | 发送者构成 | 并发行为 |
|
||||
|------|-----------|---------|
|
||||
| 内核启动前 | 仅主线程(单线程) | 无并发,直发安全 |
|
||||
| 写者未注册(内核启动 → defaultTask attach,时长取决于存储 bring-up,通常秒级) | 多任务直发 | 竞争失败方立即 `HAL_BUSY` → **整行丢失(未计数、未告警)**;`gState` 检查跨整行保持 → **只丢不交错** |
|
||||
| 写者已注册(稳态) | 任务上下文唯一调用者 = 写者 | 任务上下文零竞争;残余窗口 = ISR 直发撞写者发送中(立即返回、丢失、不挂死,§7) |
|
||||
|
||||
## 4. 详细设计
|
||||
|
||||
### 4.1 环形缓冲
|
||||
|
||||
| 参数 | 值 | 理由 |
|
||||
|------|-----|------|
|
||||
| 容量 `DBG_CON_RING_SIZE` | 4096B | 2 的幂 → `&(SIZE-1)` 回绕免除法;≈21 整行(192B/行)余量 |
|
||||
| head/tail | `uint16` + `volatile`,单生产者/单写者 | head = 生产者写位置,tail = 写者读位置 |
|
||||
| 已用字节 | `(head - tail) & (SIZE-1)` | 无符号差自然回绕,免锁可读 |
|
||||
| 单行可接收上限 | `SIZE/2 = 2048B` | 保证"一行恒可入环";正常路径受 `DBG_CON_LINE_MAX=192B` 约束,不触发 |
|
||||
| 位置 | BSS(SRAM1,非 CCM) | CCM = FreeRTOS 堆,放 BSS 不占堆;轮询发送不依赖 DMA 可达性(CCM 的 DMA 不可达约束不适用) |
|
||||
|
||||
### 4.2 生产者路径(`con_append`)
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A["dbg_console_write_line / fputc"] --> B{"写者已注册?<br/>(writer_up)"}
|
||||
B -- "否(内核前 / 未 attach)" --> R["write_raw 整行直发<br/>(≤256B 截断, 不等待)"]
|
||||
B -- 是 --> C{"中断/异常上下文?<br/>(__get_IPSR() ≠ 0)"}
|
||||
C -- 是 --> R
|
||||
C -- 否 --> D{"当前任务 == 写者?"}
|
||||
D -- 是 --> E["先 dbg_console_drain()<br/>(腾空环形缓冲, 避免自等)"]
|
||||
D -- 否 --> F{"环内空间 ≥ 行长?"}
|
||||
E --> F
|
||||
F -- 是 --> G["临界区:整行拷贝<br/>(head→环尾 + 回绕两段) + 推进 head"]
|
||||
F -- 否 --> H["vTaskDelay(1) 等待<br/>最多 200ms (200 tick)"]
|
||||
H -- 出现空间 --> G
|
||||
H -- 超时 --> I["丢弃:s_con_drop++<br/>(写者随后刷 [ERR] CONSOLE dropped N lines)"]
|
||||
G --> J["osEventFlagsSet(SYS_EVT_CONSOLE_TX)<br/>唤醒写者(句柄 NULL 保护)"]
|
||||
```
|
||||
|
||||
关键机制:
|
||||
|
||||
- **整行原子入环**:拷贝与 head 推进在同一次 `taskENTER_CRITICAL` 内完成 → 写者永不见"半行";临界区时长有界(≤192B 拷贝,微秒级)。
|
||||
- **自等待规避**:写者自身记录日志时先 `drain` 腾空(否则"等写者腾出的空间"会等自己,死锁);腾空后入环必立即成功。
|
||||
- **丢弃可观测**:丢弃累计 `s_con_drop`,写者每次 drain 后把累计值刷成 `[ERR]` 行(§4.3)——`[ERR]` 触发 `@test` Forbidden 判定,丢行永不静默。
|
||||
- **唤醒**:入环后置 `SYS_EVT_CONSOLE_TX` 命令位 → 写者立即被唤醒(零时延);写者循环另有 50ms 超时兜底(事件位异常也不滞留日志)。
|
||||
|
||||
### 4.3 写者路径(`attach` / `drain`)
|
||||
|
||||
```c
|
||||
/* 注册(defaultTask 进主循环前一次,App/task/default_task.c) */
|
||||
dbg_console_writer_attach(); /* 记录任务句柄 + writer_up=1 */
|
||||
|
||||
/* 写者主循环(事件唤醒 / 50ms 兜底) */
|
||||
osEventFlagsWait(sys_evtHandle, SYS_EVT_CFG_SAVE | SYS_EVT_CONSOLE_TX,
|
||||
osFlagsWaitAny, 50u);
|
||||
dbg_console_drain();
|
||||
```
|
||||
|
||||
`drain` 算法(仅写者任务调用):
|
||||
|
||||
1. 循环 `while (used != 0)`:取连续段 `tail → 环尾`,截断至 `DBG_CON_CHUNK_MAX`(256B) → `HAL_UART_Transmit(&huart1, &s_con_ring[tail], n, 0xFFFFu)` → **临界区内推进 `tail`**(交给 UART 的缓冲指针恒为环形缓冲——G2);
|
||||
2. 刷丢弃计数:`s_con_drop != 0` → 组帧 `"\r\n[ERR] CONSOLE dropped N lines\r\n"` → **`write_raw` 直发**(不经环:写者自身输出若走环会 `con_append` → `drain` 重入当前 `drain`,无限递归)。
|
||||
|
||||
稳态时序:
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant P as 生产者任务(netTask 等)
|
||||
participant R as 环形缓冲 4KB(BSS)
|
||||
participant E as sys_evt 事件标志
|
||||
participant W as 写者 defaultTask
|
||||
participant U as USART1(115200)
|
||||
|
||||
P->>R: dbg_console_write_line(整行 ≤192B)
|
||||
Note over P,R: 临界区:整行拷贝 + 推进 head
|
||||
P->>E: osEventFlagsSet(SYS_EVT_CONSOLE_TX)
|
||||
E-->>W: 唤醒(50ms 超时兜底)
|
||||
loop 直到 used == 0
|
||||
W->>R: dbg_console_drain():取连续段 ≤256B
|
||||
W->>U: HAL_UART_Transmit(块)
|
||||
Note over W,R: 临界区:推进 tail
|
||||
end
|
||||
opt s_con_drop != 0
|
||||
W->>U: "[ERR] CONSOLE dropped N lines"(直发)
|
||||
end
|
||||
```
|
||||
|
||||
### 4.4 裸发(`dbg_console_write_raw`)
|
||||
|
||||
- 有界:`len > 256 → 256`(截尾);单次阻塞 `HAL_UART_Transmit`(超时 `0xFFFF`),不持临界区、不等待状态;
|
||||
- 适用:内核前 / 未注册期、ISR、异常钩子(栈溢出 / 堆失败)、崩溃上报;
|
||||
- 调用方纪律:**只交已知合法的缓冲**——钩子侧先做指针范围校验(Flash / SRAM / CCM 窗口)并拷入本地缓冲再发,TCB 指针不接触 UART(`Src/freertos.c vApplicationStackOverflowHook`,2026-09-24 加固;指针不可信时发占位文本,"上报崩溃的代码不能再崩一次")。
|
||||
|
||||
### 4.5 `fputc` 重定向(MicroLIB `printf`)
|
||||
|
||||
`fputc(ch, f)` → `con_append(&b, 1)`:库内部 / 遗留 `printf` 调用同样收敛到单写者路径(注册期逐字节入环;一条完整 `printf` 行 = 环内连续字节,写者按块发出 → 仍行级原子)。
|
||||
|
||||
**`printf` 是遗留路径**:逐字节 = 一次临界区 + 一次事件置位;新代码一律用 `DBG_*` 宏(调用点格式化整行、一次入环、一次事件)。两路行为一致,仅效率差异。
|
||||
|
||||
### 4.6 时间参数(实测 / 推导)
|
||||
|
||||
| 参数 | 值 | 推导 |
|
||||
|------|-----|------|
|
||||
| 字节率 @115200 8N1 | 86.8 µs/B(10 bit/字节) | 115200 / 10 |
|
||||
| 单块 256B | ≈22 ms | 写者单次 `HAL_UART_Transmit` 上限 |
|
||||
| 单行 192B(最坏) | ≈17 ms | `DBG_CON_LINE_MAX` |
|
||||
| 生产者最长等待 | 200 ms(200 × 1ms tick) | ≈9 个发送块的时间,稳态下环恒被及时排空 |
|
||||
| 写者兜底周期 | 50 ms | 事件位失效时日志滞留上限 |
|
||||
| 实测日志时延 | 事件唤醒级(无丢失) | 2026-09-25 @test:67 行开机日志完整、无交错、无丢行告警 |
|
||||
|
||||
## 5. API 参考
|
||||
|
||||
全部声明位于 `App/log/console_log.h`(仅 MCU 端;模拟器无对应实现,共享代码勿调用):
|
||||
|
||||
| 函数 | 签名 | 调用上下文 | 语义 | 备注 |
|
||||
|------|------|-----------|------|------|
|
||||
| `dbg_console_write_line` | `int (const char *line, unsigned len)` | 生产者(任务上下文) | 整行入环 / 直发;0 = 写入字节数,-1 = 参数非法 / 被丢弃 | 截断 ≤192B(保行首时间戳/标记信息) |
|
||||
| `dbg_console_write_raw` | `void (const char *buf, unsigned len)` | **任意**(ISR / 钩子 / 内核前) | 有界直发 ≤256B,不等待、不加锁 | 缓冲须已知合法 |
|
||||
| `dbg_console_writer_attach` | `void (void)` | 写者任务、主循环前 | 注册唯一写者 | 仅一次(defaultTask) |
|
||||
| `dbg_console_drain` | `void (void)` | **仅写者任务** | 排空环并发出 + 刷丢弃计数 | defaultTask 主循环周期调用 |
|
||||
| `dbg_console_dropped` | `uint32_t (void)` | 任意 | 诊断:累计丢弃行数 | 外部读取 |
|
||||
| `fputc` | `int (int ch, FILE *f)` | `printf` 调用点 | MicroLIB retarget 钩子 → 逐字节 `con_append` | 须为全局符号(C 库链接) |
|
||||
|
||||
## 6. 常量
|
||||
|
||||
| 常量 | 值 | 定义处 | 含义 |
|
||||
|------|-----|--------|------|
|
||||
| `DBG_CON_LINE_MAX` | 192 | `console_log.h` | 单行文本上限(含结尾 `'\0'`);`DBG_PRINT` 宏行缓冲尺寸;超限截断 |
|
||||
| `DBG_CON_RING_SIZE` | 4096 | `console_log.c` | 环形缓冲字节数(必须为 2 的幂) |
|
||||
| `DBG_CON_CHUNK_MAX` | 256 | `console_log.c` | 写者单次发送上限 = 裸发上限 |
|
||||
| `DBG_CON_WAIT_MS` | 200 | `console_log.c` | 缓冲满时生产者最长等待(1ms/轮,仍满 → 丢弃 + 计数) |
|
||||
| 写者循环超时 | 50 ms | `App/task/default_task.c` | `osEventFlagsWait` 兜底周期 |
|
||||
|
||||
## 7. 失效模式与可观测性
|
||||
|
||||
| 失效 | 行为 | 可观测性 | 残余风险 |
|
||||
|------|------|---------|---------|
|
||||
| 缓冲满(日志突发 / 写者卡滞) | 生产者等 200ms 后丢行 | `s_con_drop` 累计 → 写者刷 `[ERR] CONSOLE dropped N lines`(@test FAIL,永不静默) | — |
|
||||
| 写者未注册(内核前) | 单线程直发 | — | 无(无并发) |
|
||||
| 未注册期多任务并发直发 | 竞争失败方立即 `HAL_BUSY` → 整行丢失 | **未计数、未告警**(已知折中,§3.4 / §9-D5) | 启动窗口(秒级);2026-09-25 实测未发生 |
|
||||
| ISR 直发撞写者发送中 | 立即 `HAL_BUSY` 返回 → 丢失,不挂死 | 未计数 | ISR 日志频率极低,best-effort 语义 |
|
||||
| 内核状态损坏(栈溢出 / 堆耗尽) | 钩子裸发固定文本 → 复位(栈溢出)/ 仅告警(堆) | `[ERR] STACK OVERFLOW task=…` / `[ERR] MALLOC FAILED …`;任务名范围校验 + 本地拷贝,TCB 指针不入 UART | — |
|
||||
| 调用方指针损坏(脏指针) | 无法进入 UART(缓冲恒为环 / 模块本地) | 2026-09-24 HardFault 路径结构性消除 | — |
|
||||
| UART 物理失效(发送卡死 / 超时) | `HAL_UART_Transmit` 返回 `HAL_TIMEOUT`;调用点忽略返回值(best-effort 控制台),该块丢弃 | 不入丢弃计数(与"缓冲满"独立);UART 故障由其他可观测面暴露(自检 / 其余日志) | 已知缺口:超时未计数(v2 可加超时计数) |
|
||||
| `sys_evt` 对象缺失(句柄 NULL) | 唤醒空操作,50ms 兜底 | 至多 50ms 时延 | — |
|
||||
|
||||
## 8. 内存预算
|
||||
|
||||
| 项 | 大小 | 位置 |
|
||||
|----|------|------|
|
||||
| `s_con_ring` | 4096 B | BSS(SRAM1,非 CCM) |
|
||||
| `s_con_head/tail/drop/writer_up/writer_task` | ≈14 B | BSS |
|
||||
| 生产者行缓冲 `__con_line`(`DBG_PRINT` 宏局部) | 192 B/调用 | 调用者任务栈(入环后即释放,峰值非累积) |
|
||||
|
||||
**结论:静态 +4.1KB(SRAM1);FreeRTOS 堆零增量、无新任务/栈、无新内核对象。** 2026-09-25 实测:`heap free=8776B, min_ever=4816B`(CCM 堆不受影响);`__con_line` 192B 峰值在各任务既有栈预算内(任务栈按 2026-09-21 实测峰值 ×1.5 + 1KB ISR 余量定档,见 AGENTS.md 任务栈表;当日栈水位复测 6 任务全 PASS)。
|
||||
|
||||
## 9. 设计决策与否决的替代方案
|
||||
|
||||
| # | 替代方案 | 否决 / 采纳理由 |
|
||||
|---|---------|----------------|
|
||||
| D1 | 逐字符 `fputc` + `gState` 检查(旧方案) | 原子性退化为字节级 → 字符交错(F1);调用方脏指针直达 UART(F2);并发立即 `HAL_BUSY` → 静默丢行(C3) |
|
||||
| D2 | 整行 `HAL_UART_Transmit` + `gState` 检查 | 消除交错,但不解决脏指针(调用方缓冲仍入 UART);竞争失败方无等待/重试,整行静默丢;调用方阻塞时长不受控(等 UART 物理速率) |
|
||||
| D3 | 专用日志任务 | 违反 G3(RAM 紧张不新增任务/栈);defaultTask 本就是存储子系统唯一写者,单写者纪律收敛到同一任务,且主循环已是 50ms 事件驱动 |
|
||||
| D4 | TX DMA / 中断驱动发送 | 发送率低(115200、日志行稀疏),收益不足;不解决 G2(DMA 同样读调用方缓冲);DMA 缓冲可达性 / 所有权 / 双缓冲复杂度不值 |
|
||||
| D5 | 环 + 直发双路径(**采纳**) | 注册稳态走环(零丢失、有计数);内核前 / ISR / 钩子走有界直发(G4:不等待、不死锁、零内核对象);未注册期"只丢不交错、未计数"是 K1/K3 约束下的代价,启动窗口秒级、实测未发生(§3.4) |
|
||||
| D6 | 每生产者 SPSC 无锁队列 | 多生产者仍需 MPMC;单环 + 临界区整行拷贝更简,生产者临界区 ≤192B 微秒级;事件位复用免新增内核对象 |
|
||||
| D7 | `printf` 保为主路径 | MicroLIB 逐字符回调开销 + 遗留语义;`DBG_*` 宏调用点格式化整行一次入环(一次入环、一次事件) |
|
||||
|
||||
## 10. 验证记录
|
||||
|
||||
| 日期 | 验证 | 结果 |
|
||||
|------|------|------|
|
||||
| 2026-09-24 | HardFault 定位:BFAR=0x10010000(=CCM 末尾+1),PC 在 `HAL_UART_Transmit` 缓冲读取处;崩溃前交错行留证 | 根因确认(F1/F2)→ 单写者加固实施 |
|
||||
| 2026-09-25 | `@build`(Keil MDK v5 / ARMCC C99) | **0 Error, 0 Warning**(`console_log.c` 注册于 App 组) |
|
||||
| 2026-09-25 | `@test` 硬件闭环(烧录 → 开机日志采集 → 标记校验) | **PASS**:Required 3/3(`App init OK` / `Network Init` / `net init: OK`);Forbidden 5/5 缺席(`FAIL`/`ERROR`/`HardFault`/`assert`/`[ERR]`,大小写不敏感);67 行开机日志完整、无交错、无丢行 |
|
||||
| 2026-09-25 | 静态门禁:C 代码规范 V1.0 + U+FFFD 乱码 + cppcheck(warning, performance, portability, style) | 0 违规 |
|
||||
| 2026-09-25 | 迁移验收:实现迁出 `Src/usart.c`(该文件恢复 478 行纯 CubeMX 形态),双端行为不变 | `@build` 0/0 + `@test` 复测 PASS;引用关系图重生成 |
|
||||
|
||||
## 11. 实施时间线
|
||||
|
||||
| 日期 | 事件 |
|
||||
|------|------|
|
||||
| 2026-09-22 | 链路延迟测试:开机并发 `printf` 丢行(连续 4 行)实证 → S8 非阻塞日志立项(`链路延迟测试说明.md` §10.2) |
|
||||
| 2026-09-24 | 字符交错 + HardFault 实证 → 单写者加固实施(4KB 环 + defaultTask 唯一发送 + 裸发回退 + `fputc` 收敛);当时位于 `Src/usart.c` USER CODE 区 |
|
||||
| 2026-09-25 | 迁出至 `App/log/console_log.{h,c}`(HAL 生成文件不含应用代码);`dbg_log.h` 改 `#include "console_log.h"`;Keil 工程 App 组注册;`@build` 0/0、`@test` PASS、引用关系图与本文档同步 |
|
||||
| 2026-09-25 | 写者任务体迁出:`Src/freertos.c` 的 `StartDefaultTask` 任务体(存储 bring-up / 配置引擎 / 控制台 attach+drain / syslog / LED / 栈水位)整体移入 `App/task/default_task.c`(`default_task_func()`,与其余 5 任务文件同址);`freertos.c` 恢复"接线 + 崩溃钩子"的 CubeMX 形态(719→361 行);行为零变化,`@build` 0/0 + `@test` PASS 复验 |
|
||||
|
||||
## 12. 开放问题
|
||||
|
||||
| # | 项 | 说明 |
|
||||
|---|----|------|
|
||||
| O1 | 未注册期窗口丢行未计数 | 启动窗口(内核启动 → attach)直发竞争丢整行且无计数(HAL `HAL_BUSY` 立即返回);若未来开机日志密度上升,可升级为"内核前静态待发行 + attach 后统一补发"或有界等待直发 |
|
||||
| O2 | `HAL_UART_Transmit` 超时未计数 | 超时块(UART 物理失效)丢弃但不入 `s_con_drop`;v2 可加独立超时计数 |
|
||||
| O3 | `printf` 逐字节开销 | 遗留 `printf` 路径 = 逐字节临界区 + 逐字节事件置位;遗留调用点全部切 `DBG_*` 宏后开销自然消失(不改变机制) |
|
||||
|
||||
## 13. 相关文档
|
||||
|
||||
- `项目架构总览.md` —— 六层分层 / 启动时序 / 6 任务(写者任务与就绪屏障位置)
|
||||
- `运行与自检记录设计说明.md` —— sys_log 持久化日志(姊妹模块:同写者任务、不同通道)
|
||||
- `测试说明/链路延迟测试说明.md` —— D6 日志税 / S8 非阻塞日志(需求出处与 09-22 丢行实证)
|
||||
- `测试说明/自动化测试流程.md` —— `@test` 标记体系(Required / Forbidden 模式,`[ERR]` 语义)
|
||||
- AGENTS.md —— 平台约束(内核前禁内核对象 / C 堆禁令 / 事件位语义 / 内存预算)
|
||||
|
||||
## 修订记录
|
||||
|
||||
| 版本 | 日期 | 说明 |
|
||||
|------|------|------|
|
||||
| v1.0 | 2026-09-25 | 初版:完整设计说明(背景根因 / 单写者模型 / 详细设计 / API / 参数 / 失效模式 / 内存预算 / 设计决策 / 验证记录);实现位于 `App/log/console_log.{h,c}` |
|
||||
| v1.1 | 2026-09-25 | 文件拆分同步:写者任务体迁至 `App/task/default_task.c`(`Src/freertos.c` 只留 CubeMX 接线与崩溃钩子);§3.2 文件清单 / §4.3 / §6 / §11 位置引用更新 |
|
||||
+6
-3
@@ -164,7 +164,7 @@ flowchart LR
|
||||
```
|
||||
|
||||
- 掉电持久化:`net_cfg` 配置(通用配置文件 `/config.ini`,INI `[network]` 段,cfg_file 引擎),保存后下次上电生效、或立即生效(网络重建)、外部变更 4s 沉降后自动重载;旧版 NCFG 二进制(`/cfg/netcfg.bin`)首启自动迁移。
|
||||
- 日志记录:`sys_log` 引擎写定长 64B 文本记录到 `/log/run.log`(运行记录)与 `/log/selftest.log`(自检记录),defaultTask 唯一写者,FTP 可直下(详见 `docs/运行与自检记录设计说明.md`)。
|
||||
- 日志记录:`sys_log` 引擎写定长 64B 文本记录到 `/log/run.log`(运行记录)与 `/log/selftest.log`(自检记录),defaultTask 唯一写者,FTP 可直下(详见 `docs/运行与自检记录设计说明.md`);实时调试流 = 控制台单写者日志(USART1,4KB 环形缓冲 + defaultTask 唯一发送,详见 `docs/控制台单写者日志设计说明.md`)。
|
||||
- NAND 坏块表(BBT)持久化在保留块池,不交给 dhara 管理。
|
||||
|
||||
---
|
||||
@@ -249,14 +249,14 @@ flowchart TB
|
||||
```
|
||||
STM32F4-Base/
|
||||
├── Src/ Inc/ CubeMX 生成:main.c / freertos.c / HAL 外设 / 中断 / 时基
|
||||
│ ├── freertos.c 6 任务 + netMsgQueue + sys_evt 创建(USER CODE 区自定义,含栈水位探针 stack_probe_poll)
|
||||
│ ├── freertos.c 6 任务 + netMsgQueue + sys_evt 创建(CubeMX 接线 + 崩溃钩子;任务体在 App/task/)
|
||||
│ └── main.c 入口 → app_main_init → osKernelStart
|
||||
├── App/ 应用层(业务编排,非 CubeMX)
|
||||
│ ├── app_main.c 启动编排(时间子系统优先)
|
||||
│ ├── time_sync.c TCP 对时服务
|
||||
│ ├── sys_events.h 就绪屏障 bit 定义(就绪位等待须 osFlagsNoClear,见 §2.2)
|
||||
│ ├── app_cfg.h 功能编译开关(APP_NET/ADC/RS485_ENABLE)
|
||||
│ ├── task/ net_task / ui_task / adc_task* / rs485_task*
|
||||
│ ├── task/ default_task / net_task / ui_task / adc_task* / rs485_task*
|
||||
│ ├── log/ sys_log 记录引擎(定长 64B;MCU 后端落盘 /log/*.log)
|
||||
│ └── util/ crc(CRC-16/8)、ringbuf、sys_clock(墙钟)
|
||||
├── Drivers/BSP/ 纯手工驱动/服务(不受 CubeMX 保护)
|
||||
@@ -308,6 +308,7 @@ flowchart LR
|
||||
| 启动顺序 / 就绪屏障 | `docs/项目启动顺序管理.md` |
|
||||
| 存储架构(NAND/FTL/FatFs) | `docs/STM32F4-Base存储架构说明.md` |
|
||||
| 墙钟时间维护 | `docs/系统墙钟时间维护说明.md` |
|
||||
| 控制台单写者日志(USART1 调试流) | `docs/控制台单写者日志设计说明.md` |
|
||||
| RAM 预算与优化 | `docs/内存管理/RAM使用分析与优化方案.md` |
|
||||
| 栈/内存观测工具 | `scripts/stack_report.py`(Keil 静态调用图 × 串口 `[STACK]` 水位,判定取两者更坏者)· `scripts/ram_report.py`(.map 静态占用)—— 用法与基线见内存方案 §0.6 |
|
||||
| FTP 功能与陷阱 | `docs/测试说明/FTP_Test_Guide.md`(启动门 §8.6 / 单客户端 §8.7)· 脚本 `test/ftp_up_dl_test.py`、`test/ftp_speed_test.py` |
|
||||
@@ -338,3 +339,5 @@ flowchart LR
|
||||
| 2026-09-14 | 运行/自检记录:新增 `App/log/sys_log`(定长 64B 文本记录引擎,MCU 后端 `/log/run.log`·`selftest.log`,defaultTask 唯一写者)+ UI 页面插件 `ui_page_runlog`/`ui_page_selftest`(动态列表)+ `ui_standby` 待机屏(空闲超时切入);密码页错误提示;字体 111→122 字(217 字形);详见 `docs/运行与自检记录设计说明.md` |
|
||||
| 2026-09-21 | **§2.2 屏障语义修正 + FTP 永不监听缺陷修复**:`osEventFlagsWait` 默认消费所等位,就绪位(`NET_READY`/`STORAGE_READY`)被 netTask/uiTask/timeSync 先消费后,`ftpTask` 的 `WaitAll(两位)` 永不成立 → 任务永久阻塞、21 端口从未监听(静默);5 处就绪位等待统一加 `osFlagsNoClear`(命令位 `CFG_SAVE`/`NET_RECONFIG` 保持消费型)。同轮新增**栈可观测性**:`Src/freertos.c` 的 `stack_probe_poll`(串口 `[STACK]` 水位)+ `scripts/stack_report.py`(Keil 静态调用图 × 运行时水位,判定取两者更坏者);§2.1 任务表补齐实测栈数据并修正过期的 defaultTask/testTask 栈配置,§3 时序图补 `NoClear` 与 FTP 启动日志,§5 补 FTP 启动门/单客户端实测注意 |
|
||||
| 2026-09-21 | **栈宽整改落地(内存方案 §1.4:lftpd 大局部缓冲静态化)**:`Drivers/BSP/NET/lftpd/lftpd.c` + `lftpd_log.c` 共 **9 处**大局部数组(`message[256]`/`response[512]`/`name[256]`×2/`buffer[1024]`×2/`read_buffer[512]`/`arg_buf[512]`/`client` 会话上下文/日志 `buffer[256]`)改为函数级 `static`(lftpd 单客户端、全部在 ftpTask 内串行);**ftpTask 实测峰值 3480 → 1184 B(余量 15% → 71%,判定 PASS)**,静态调用图 2528 → 472 B,代价静态 BSS +4,616 B(RW_IRAM1 82,048 / 131,072 B,余量仍 ~48 KB);§2.1 栈实测数据同步,原"涨栈到 1600 words"方案取消;FTP 功能回归 10/10 + 128KB 逐字节一致 |
|
||||
| 2026-09-24 → 09-25 | **控制台单写者日志**(09-24 实证驱动:多任务并发日志字符级交错 + HardFault 脏指针直达 UART):4KB 环形缓冲 + defaultTask 唯一发送(行级原子 + 指针可控)+ 内核前/ISR/异常钩子有界直发回退 + `fputc` 收敛到单写者路径;09-24 初版实施于 `Src/usart.c` USER CODE 区,09-25 迁出至 `App/log/console_log.{h,c}`(HAL 生成文件不含应用代码),`dbg_log.h` 改 `#include "console_log.h"`(调用点零改动),`Src/usart.c` 恢复纯 CubeMX 形态;`@build` 0/0 + `@test` PASS;详见 `docs/控制台单写者日志设计说明.md` |
|
||||
| 2026-09-25 | **defaultTask 任务体文件拆分**:`Src/freertos.c` 的 `StartDefaultTask` 任务体(存储 bring-up / 配置引擎属主 / 控制台单写者 attach+drain / syslog 落盘 / LED / 栈水位探针 `stack_probe_poll`)整体迁至 `App/task/default_task.c`(`default_task_func()`,与其余任务文件同址);`freertos.c` 恢复"CubeMX 接线 + 崩溃钩子"形态(719→361 行),`@build` 0/0 复验;栈配置属性仍定义于 `freertos.c`(`stack_report` 数据源不变) |
|
||||
|
||||
Reference in New Issue
Block a user