diff --git a/AGENTS.md b/AGENTS.md index d5ae670a..4ac47747 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -90,7 +90,7 @@ ## 提交门禁(pre-commit) -- 任一失败即拦截,共 **49 个钩子**(2026-10-25 道E 连加 `bom-guard` / `setview-check` / `uinav-selftest` 三条;**每种门禁一篇详解(查什么 / 拦下过什么真事 / 限制与盲区 / 基线口径)→ `docs/门禁说明/README.md` 索引**;通用机制与整体口径 → `docs/代码规范/pre-commit使用说明.md`):通用 5 + `gitlint` + `cppcheck` / `test-cppcheck` + `no-mojibake` + `coding-standard` + 文档三件套 `doc-links` / `task-table` / `mem-numbers` + `id-check`(**编号门禁**,`docs/编号规范.md` §8 八项校验;**已关闸为【增量拦截】**:只拦 `scripts/id_known_backlog.json` 台账之外的新错误级问题,存量按指纹豁免、台账只减不增;另有一根恒生效的线——可判定比例跌破 `id_registry.json` 基线即失败)+ `lv-conf-sync`(两份 `lv_conf.h` 特性子集一致)+ `cubemx-survival` + 主机侧单测 22 个(`-unit-test` 后缀,2026-10-25 增补 adc-cal / prot-dim / vol-idle-sync / ui-data / meas / run-par 六个)+ `test-coverage`(**覆盖率总闸**:跑全部 39 套并守基线回退;缺 mscoverage 组件时按用户裁定 **FAIL**、不 skip,2026-10-24)+ `test-suite-switch` + `registration-check`(双端注册反向校验 + UI 页面描述符表接线,N-23/U4)+ `mem-budget`(RAM 92% 预算门禁,N-27)+ `font-charset`(UI 字符集差集检查,防缺字白框,U4)+ `ui-golden`(UI 像素回归,菜单 8 状态 + 内容页 18 页黄金参考,U4)+ `layer-deps`(**分层方向**:`Drivers/BSP/**` 不得 include `App/**` 的头;存量 3 条基线只减不增(2026-10-25 记录 reader 注入削掉 UI 记录 3 条边,6→3),报告 S-1)+ `bsp-err`(**BSP 错误码与超时命名约定**:公开 API 不得拿 `HAL_StatusTypeDef`/`bool` 当错误通道、`*_TIMEOUT` 宏不得取负值、非 void 须写「返回值:」、**返回错误码的函数不得裸丢弃返回值**(须接住或显式 `(void)`;实测编译器与 cppcheck 都不报这类,只有这条会响);约定正文 `Drivers/BSP/bsp_err.h`,存量基线只减不增(2026-10-23 首清点 19 条 → 已还 18;`consume-result` 上线又暴露 37 条存量丢弃 → **现 38 条**),报告 S-5) +- 任一失败即拦截,共 **49 个钩子**(2026-10-25 道E 连加 `bom-guard` / `setview-check` / `uinav-selftest` 三条;**每种门禁一篇详解(查什么 / 拦下过什么真事 / 限制与盲区 / 基线口径)→ `docs/门禁说明/README.md` 索引**;通用机制与整体口径 → `docs/代码规范/pre-commit使用说明.md`):通用 5 + `gitlint` + `cppcheck` / `test-cppcheck` + `no-mojibake` + `coding-standard` + 文档三件套 `doc-links` / `task-table` / `mem-numbers` + `id-check`(**编号门禁**,`docs/编号规范.md` §8 八项校验;**已关闸为【增量拦截】**:只拦 `scripts/id_known_backlog.json` 台账之外的新错误级问题,存量按指纹豁免、台账只减不增;另有一根恒生效的线——可判定比例跌破 `id_registry.json` 基线即失败)+ `lv-conf-sync`(两份 `lv_conf.h` 特性子集一致)+ `cubemx-survival` + 主机侧单测 23 个(`-unit-test` 后缀,2026-10-25 增补 adc-cal / prot-dim / vol-idle-sync / ui-data / meas / run-par / ui-sink 七个)+ `test-coverage`(**覆盖率总闸**:跑全部 40 套并守基线回退;缺 mscoverage 组件时按用户裁定 **FAIL**、不 skip,2026-10-24)+ `test-suite-switch` + `registration-check`(双端注册反向校验 + UI 页面描述符表接线,N-23/U4)+ `mem-budget`(RAM 92% 预算门禁,N-27)+ `font-charset`(UI 字符集差集检查,防缺字白框,U4)+ `ui-golden`(UI 像素回归,菜单 8 状态 + 内容页 18 页黄金参考,U4)+ `layer-deps`(**分层方向**:`Drivers/BSP/**` 不得 include `App/**` 的头;存量 3 条基线只减不增(2026-10-25 记录 reader 注入削掉 UI 记录 3 条边,6→3),报告 S-1)+ `bsp-err`(**BSP 错误码与超时命名约定**:公开 API 不得拿 `HAL_StatusTypeDef`/`bool` 当错误通道、`*_TIMEOUT` 宏不得取负值、非 void 须写「返回值:」、**返回错误码的函数不得裸丢弃返回值**(须接住或显式 `(void)`;实测编译器与 cppcheck 都不报这类,只有这条会响);约定正文 `Drivers/BSP/bsp_err.h`,存量基线只减不增(2026-10-23 首清点 19 条 → 已还 18;`consume-result` 上线又暴露 37 条存量丢弃 → **现 38 条**),报告 S-5) - **范围 = 项目代码**:第三方(`Lib/`、`Middlewares/`、CMSIS、HAL、`lftpd`、`dhara`、`MDK-ARM`)排除;`cppcheck`/`coding-standard` 另排除 `test/`,规范检查再排除 CubeMX 生成的 `Src/`/`Inc/`。**`simulator/` 已纳入全部钩子**(2026-10-11)——生成物只靠 `.gitignore` 挡,**不在 `exclude` 里写目录名**(教训见 `docs/代码规范/pre-commit使用说明.md` §5.5) - ⚠ **pre-commit 4.x 已移除 `always: true`**(实测对 `local` 钩子只告警 `Unexpected key(s)` 并跳过)→ 想"总是跑"的钩子**必须让 `files:` 覆盖到所有会触发它的文件**,没有兜底开关 - **改写型钩子(`trailing-whitespace` + `end-of-file-fixer`)豁免 CubeMX/Keil 生成文件**(配置里 YAML 锚点 `&cubemx-generated`);⚠ **只读检查不受影响**:`cppcheck` / 乱码 / `cubemx-survival` / `task-table` / `mem-numbers` 仍覆盖 `Src/`、`Inc/` diff --git a/docs/内存管理/RAM使用分析与优化方案.md b/docs/内存管理/RAM使用分析与优化方案.md index c88e254d..4556355c 100644 --- a/docs/内存管理/RAM使用分析与优化方案.md +++ b/docs/内存管理/RAM使用分析与优化方案.md @@ -47,10 +47,10 @@ C2 dhara 失败类 +84;RO 另 +208,全是 C2 的失败类名表)→ `ER_IR | 区域 | 用量 | 容量 | 占比 | |---|---|---|---| -| ER_IROM1 | 249,408 B (243.56 KB) | 1,048,576 B (1024 KB) | 23.8% | -| RW_IRAM1 | 79,000 B (77.15 KB) | 131,072 B (128 KB) | 60.3% | +| ER_IROM1 | 249,500 B (243.65 KB) | 1,048,576 B (1024 KB) | 23.8% | +| RW_IRAM1 | 79,008 B (77.16 KB) | 131,072 B (128 KB) | 60.3% | | RW_CCM | 57,376 B (56.03 KB) | 65,280 B (64 KB) | 87.9% | -| **Flash (ROM 合计)** | **250,736 B (244.9 KB)** | 1,048,576 B (1024 KB) | **23.9%** | +| **Flash (ROM 合计)** | **250,832 B (245.0 KB)** | 1,048,576 B (1024 KB) | **23.9%** | 各区的容量与常量来源: diff --git a/docs/内存管理/RAM预算台账.md b/docs/内存管理/RAM预算台账.md index 91123c70..245f9054 100644 --- a/docs/内存管理/RAM预算台账.md +++ b/docs/内存管理/RAM预算台账.md @@ -15,16 +15,16 @@ | 区域 | 用量 | 容量 | 占比 | 门禁(≤92%) | |---|---|---|---|---| -| ER_IROM1 (Flash) | 249,408 B | 1,048,576 B | 23.8% | 参考 | +| ER_IROM1 (Flash) | 249,500 B | 1,048,576 B | 23.8% | 参考 | | RW_CCM | 57,376 B | 65,280 B | 87.9% | PASS | | UNINIT_CCM | 48 B | 256 B | 18.8% | 参考 | -| RW_IRAM1 | 79,000 B | 131,072 B | 60.3% | PASS | +| RW_IRAM1 | 79,008 B | 131,072 B | 60.3% | PASS | | 子系统(静态 RW+ZI;除 RTOS 堆在 CCM 外均在 SRAM1) | 现值 | 配额 | 状态 | |---|---|---|---| | 网络 | 13,702 B | 12 KB | ⚠ 超 1.4 KB | | 存储 | 7,056 B | 12 KB | OK | -| UI | 32,331 B | 16 KB | ⚠ 超 15.6 KB | +| UI | 32,335 B | 16 KB | ⚠ 超 15.6 KB | | RTOS 堆 | 57,376 B | 56 KB | 堆=配额 | | 应用 | 15,422 B | 8 KB | ⚠ 超 7.1 KB | | 其它 | 10,499 B | — | 参考 | diff --git a/scripts/ram_baseline.tsv b/scripts/ram_baseline.tsv index 7e3ffde0..a2d5e286 100644 --- a/scripts/ram_baseline.tsv +++ b/scripts/ram_baseline.tsv @@ -7,4 +7,4 @@ date code ro rw zi er_irom1 er_pct iram1 iram1_pct ccm ccm_pct top_rwzi 2026-10-22 213436 18652 1188 131500 232088 22.1 75264 57.4 57376 87.9 heap_4.o=57376;lv_mem_core_builtin.o=16384;lftpd.o=7884;ui_net_sink.o=6766;ui_port.o=6420;nand_ftl.o=6216;ch395f.o=4162;console_log.o=4120;sys_log_mcu.o=3588;default_task.o=2736 2026-10-23 213676 18860 1188 131500 232536 22.2 75264 57.4 57376 87.9 heap_4.o=57376;lv_mem_core_builtin.o=16384;lftpd.o=7884;ui_net_sink.o=6766;ui_port.o=6420;nand_ftl.o=6216;ch395f.o=4162;console_log.o=4120;sys_log_mcu.o=3588;default_task.o=2736 2026-10-24 213780 18860 1204 131852 232640 22.2 75632 57.7 57376 87.9 heap_4.o=57376;lv_mem_core_builtin.o=16384;lftpd.o=7884;ui_net_sink.o=6766;ui_port.o=6420;nand_ftl.o=6216;ch395f.o=4162;console_log.o=4128;sys_log_mcu.o=3944;default_task.o=2736 -2026-10-25 224768 24640 1328 135096 249408 23.8 79000 60.3 57376 87.9 heap_4.o=57376;lv_mem_core_builtin.o=16384;lftpd.o=7884;ui_net_sink.o=6766;ui_port.o=6420;nand_ftl.o=6216;ch395f.o=4162;console_log.o=4128;sys_log_mcu.o=3944;default_task.o=2736 +2026-10-25 224860 24640 1332 135100 249500 23.8 79008 60.3 57376 87.9 heap_4.o=57376;lv_mem_core_builtin.o=16384;lftpd.o=7884;ui_net_sink.o=6770;ui_port.o=6420;nand_ftl.o=6216;ch395f.o=4162;console_log.o=4128;sys_log_mcu.o=3944;default_task.o=2736 diff --git a/scripts/size_attestation.json b/scripts/size_attestation.json index 20c93f0c..fa1b8f36 100644 --- a/scripts/size_attestation.json +++ b/scripts/size_attestation.json @@ -1,25 +1,25 @@ { - "built_at": "2026-10-25T18:03:15+08:00", - "fingerprint": "e05ca262a6f07c2bf7ca2a5927cf0801af0442a2c542f10428941beafbbc3481", + "built_at": "2026-10-25T18:46:17+08:00", + "fingerprint": "101b6500c00ec55bba062c4141f5942479e329bba1b839be5d25be287751c228", "fingerprint_files": 1422, "fingerprint_source": "git-index", "gated_regions": [ "RW_IRAM1", "RW_CCM" ], - "git_head": "66f862e7705d6b4e27816eecd4e47c9d2d83b527", + "git_head": "9d90e00d52bba74834c80f8fef483dc00e6f7507", "map": "MDK-ARM/STM32F407-Demo/STM32F407-Demo.map", - "map_mtime": 1792922569, + "map_mtime": 1792925151, "pct": { "ER_IROM1": 23.79, "RW_CCM": 87.89, - "RW_IRAM1": 60.27, + "RW_IRAM1": 60.28, "UNINIT_CCM": 18.75 }, "regions": { "ER_IROM1": { "max": 1048576, - "size": 249408 + "size": 249500 }, "RW_CCM": { "max": 65280, @@ -27,7 +27,7 @@ }, "RW_IRAM1": { "max": 131072, - "size": 79000 + "size": 79008 }, "UNINIT_CCM": { "max": 256, @@ -37,10 +37,10 @@ "schema": 2, "scope_note": "\u540c\u7801\u51ed\u8bc1\uff1a\u6307\u7eb9\u8986\u76d6\u56fa\u4ef6\u4f53\u79ef\u76f8\u5173\u6e90\u7801\uff0c\u53e3\u5f84\u89c1\u672c\u811a\u672c docstring", "sizes": { - "code": 224768, + "code": 224860, "ro_data": 24640, - "rw_data": 1328, - "zi_data": 135096 + "rw_data": 1332, + "zi_data": 135100 }, "threshold_pct": 92.0, "worktree_dirt_at_stamp": 0, diff --git a/scripts/test_coverage_baseline.json b/scripts/test_coverage_baseline.json index ff960bcb..0cd194ea 100644 --- a/scripts/test_coverage_baseline.json +++ b/scripts/test_coverage_baseline.json @@ -336,6 +336,14 @@ "lines_covered": 52, "lines_valid": 65 }, + "Drivers/BSP/UI/ui_net_sink.c": { + "func_rate": 0.7692, + "funcs_covered": 10, + "funcs_valid": 13, + "line_rate": 0.7302, + "lines_covered": 157, + "lines_valid": 215 + }, "Drivers/BSP/UI/ui_w_soe.c": { "func_rate": 1.0, "funcs_covered": 6, @@ -634,6 +642,13 @@ "lines_total": 127, "ok": true }, + "ui_sink": { + "files": { + "Drivers/BSP/UI/ui_net_sink.c": 215 + }, + "lines_total": 215, + "ok": true + }, "vol_idle_sync": { "files": { "App/fs/vol_idle_sync.c": 21 @@ -701,20 +716,21 @@ "Drivers/BSP/NETCFG/ftp_cfg.c", "Drivers/BSP/NETCFG/net_cfg.c", "Drivers/BSP/UI/ui_data.c", + "Drivers/BSP/UI/ui_net_sink.c", "Drivers/BSP/UI/ui_w_soe.c" ], "totals": { "files_generated_excluded": 5, - "files_tested": 43, - "files_untested": 136, - "func_rate": 0.9299, - "funcs_covered": 451, - "funcs_valid": 485, - "line_rate": 0.8969, - "lines_covered": 6222, - "lines_valid": 6937, - "modules_ok": 39, - "modules_total": 39 + "files_tested": 44, + "files_untested": 135, + "func_rate": 0.9257, + "funcs_covered": 461, + "funcs_valid": 498, + "line_rate": 0.8919, + "lines_covered": 6379, + "lines_valid": 7152, + "modules_ok": 40, + "modules_total": 40 }, "untested_sources": [ { @@ -729,10 +745,6 @@ "code_lines": 329, "path": "Drivers/BSP/UI/ui_menu_view.c" }, - { - "code_lines": 323, - "path": "Drivers/BSP/UI/ui_net_sink.c" - }, { "code_lines": 300, "path": "Drivers/BSP/UI/ui_content_page.c" @@ -793,6 +805,10 @@ "code_lines": 140, "path": "App/app/app_main.c" }, + { + "code_lines": 126, + "path": "App/task/ui_task.c" + }, { "code_lines": 126, "path": "Drivers/BSP/UI/ui_menu.c" @@ -801,10 +817,6 @@ "code_lines": 123, "path": "App/task/net_task.c" }, - { - "code_lines": 122, - "path": "App/task/ui_task.c" - }, { "code_lines": 117, "path": "App/task/protect_task.c" @@ -1049,6 +1061,10 @@ "code_lines": 20, "path": "App/log/console_log.h" }, + { + "code_lines": 20, + "path": "Drivers/BSP/UI/ui_net_sink.h" + }, { "code_lines": 19, "path": "App/app/sys_events.h" @@ -1065,10 +1081,6 @@ "code_lines": 18, "path": "Drivers/BSP/NET/net_listener.h" }, - { - "code_lines": 18, - "path": "Drivers/BSP/UI/ui_net_sink.h" - }, { "code_lines": 17, "path": "App/algo/sample_ring.h" diff --git a/test/host/ui_sink/stub/dbg_log.h b/test/host/ui_sink/stub/dbg_log.h index 36d641db..24667b7d 100644 --- a/test/host/ui_sink/stub/dbg_log.h +++ b/test/host/ui_sink/stub/dbg_log.h @@ -9,4 +9,4 @@ extern int g_uisink_err_count; #define DBG_WARN(...) do { } while (0) #define DBG_ERROR(...) do { g_uisink_err_count++; } while (0) -#endif /* DBG_LOG_H */ \ No newline at end of file +#endif /* DBG_LOG_H */ diff --git a/test/host/ui_sink/stub/net_latency_test.h b/test/host/ui_sink/stub/net_latency_test.h index 36c16a6f..5770038f 100644 --- a/test/host/ui_sink/stub/net_latency_test.h +++ b/test/host/ui_sink/stub/net_latency_test.h @@ -3,4 +3,4 @@ /* 主机侧桩:M3 探针头(TEST_LATENCY_PROBE 未定义时 ui_net_sink.c 不用其符号) */ -#endif /* NET_LATENCY_TEST_H */ \ No newline at end of file +#endif /* NET_LATENCY_TEST_H */ diff --git a/test/host/ui_sink/stub/net_socket.h b/test/host/ui_sink/stub/net_socket.h index 6404ea13..ff3a44ac 100644 --- a/test/host/ui_sink/stub/net_socket.h +++ b/test/host/ui_sink/stub/net_socket.h @@ -42,4 +42,4 @@ int net_close(int sockfd); int net_get_errno(void); void *net_get_sock(int sockfd); -#endif /* NET_SOCKET_H */ \ No newline at end of file +#endif /* NET_SOCKET_H */ diff --git a/test/host/ui_sink/stub/net_types.h b/test/host/ui_sink/stub/net_types.h index eab1c62d..465e0aeb 100644 --- a/test/host/ui_sink/stub/net_types.h +++ b/test/host/ui_sink/stub/net_types.h @@ -3,4 +3,4 @@ /* 主机侧桩:ui_net_sink.c 仅经 net_socket.h 取类型;本头在 PC 上为空壳 */ -#endif /* NET_TYPES_H */ \ No newline at end of file +#endif /* NET_TYPES_H */ diff --git a/test/host/ui_sink/stub/test_config.h b/test/host/ui_sink/stub/test_config.h index 13684dc2..57bfef28 100644 --- a/test/host/ui_sink/stub/test_config.h +++ b/test/host/ui_sink/stub/test_config.h @@ -3,4 +3,4 @@ /* 主机侧桩:产品形态(无任何板级套件宏 / 探针宏被打开) */ -#endif /* TEST_CONFIG_H */ \ No newline at end of file +#endif /* TEST_CONFIG_H */ diff --git a/test/host/ui_sink/stub/ui_port.h b/test/host/ui_sink/stub/ui_port.h index e5f7920f..547ab29c 100644 --- a/test/host/ui_sink/stub/ui_port.h +++ b/test/host/ui_sink/stub/ui_port.h @@ -13,4 +13,4 @@ #define UI_KEY_DOWN 2 #define UI_KEY_ESC 27 -#endif /* UI_PORT_H */ \ No newline at end of file +#endif /* UI_PORT_H */