Files
STM32F4-Base/test/gd5f_test.h
T
wandering1 a6cdebde62 文档体系重组与 D-7 一致性门禁落地,清理芯片手册孤儿图片
- D-6 目录规范化:docs 根目录散落文档归入 UI设计/子系统设计/架构设计/审查记录/
  环境与部署/网络 等子目录,去掉目录名空格,重命名 嵌入式C语言代码规范_V1.0.md
- D-7 三档一致性门禁:新增 scripts/check_doc_links.py(链接存在性)、
  scripts/gen_task_table.py(FreeRTOS 任务表数值)、scripts/check_mem_numbers.py
  (内存/Flash 体积),均支持 --check/--write/--diff,pre-commit 钩子同步注册
- D-5 文档索引:新建 docs/README.md,新建 docs/文档规范.md 约束目录命名与链接写法
- D-1 芯片手册瘦身:删除 1069 张无引用孤儿图片(77.06 MB),
  docs/芯片手册 120 MB → 41 MB,已引用图片零断链
- 同步 C 源码注释中的文档路径引用(D-6 重组后),构建 0 错误 0 警告
2026-09-26 00:51:53 +08:00

92 lines
3.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* 模块名称:GD5F2GQ5UE Driver Test Suite
* 模块功能:GD5F2GQ5UE SPI NAND Flash 驱动测试入口,按阶段组织测试用例,
* 覆盖 gd5f2gq5ue.c 全部公开/私有函数,并延伸到 FTL(nand_ftl)与
* FatFS diskio。详见 docs/测试说明/GD5F2GQ5UE_Test_Guide.md。
* 适用平台:STM32F4 系列(GD5F2GQ5UE SPI NAND)
* 作者:王建锋
* 创建日期:2026-08-26
*
* === 测试阶段一览(与指南 TC 一一对应)===
* Phase | 描述
* ---------|-----------------------------------------------
* Phase 1 | 初始化与 ID 识别(init / read_id / reset)
* Phase 2 | 坏块管理(BBT:scan / is_block_bad / mark+clear / rescan)
* Phase 3 | 页读写(跨页 / 非对齐 / 多页 / 单字节)
* Phase 4 | 块擦除(单块 / 多块 / 非对齐负向 / 擦写读闭环)
* Phase 5 | ECC 验证(开启下写读 / check_ecc)
* Phase 6 | SPI 原语(page_read / program_load+exec / block_erase / write_enable / wait_busy)
* Phase 7 | DMA 边界(阈值 32/33/整页)
* Phase 8 | FTL 层(nand_ftl_init / nand_ftl_format)
* Phase 9 | FatFS diskio(可选)
* Phase 10 | 边界条件(offset 越界 / size=0 / 未擦除写入 / 写保护解除)
* Phase 11 | 13h 锁存 / WIP 提前清零对照复现(编程擦除风暴 + 立即读比对,2026-09-21)
*/
#ifndef GD5F_TEST_H
#define GD5F_TEST_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "gd5f2gq5ue.h"
/* ======================== 阶段使能开关 ======================== */
/* 取消注释对应阶段即可启用;总开关 ENABLE_GD5F_TESTS 控制是否编译并运行测试。
* 启用后,defaultTask 中的常规 FTL/FatFS 存储测试会被跳过(独占 NAND)。
* 注意:测试会擦除/写入若干块,且 Phase 8/9 会格式化 FTL/FatFS,仅用于测试构建。 */
//#define ENABLE_GD5F_TESTS /* 总开关(由 test_config.h 的 TEST_SUITE_GD5F 自动开启) */
//#define ENABLE_GD5F_PHASE1_TESTS
//#define ENABLE_GD5F_PHASE2_TESTS
//#define ENABLE_GD5F_PHASE3_TESTS
//#define ENABLE_GD5F_PHASE4_TESTS
//#define ENABLE_GD5F_PHASE5_TESTS
//#define ENABLE_GD5F_PHASE6_TESTS
//#define ENABLE_GD5F_PHASE7_TESTS
//#define ENABLE_GD5F_PHASE8_TESTS
//#define ENABLE_GD5F_PHASE9_TESTS
//#define ENABLE_GD5F_PHASE10_TESTS
//#define ENABLE_GD5F_PHASE11_TESTS /* 13h 锁存复现(仅擦写最高一块,独立门控,可随时启用) */
/* ======================== 测试统计与断言 ======================== */
typedef struct {
uint16_t total;
uint16_t passed;
uint16_t failed;
} gd5f_test_stats_t;
extern gd5f_test_stats_t g_gd5f_test_stats;
#define GD5F_TEST_CHECK(cond, fmt, ...) do { \
g_gd5f_test_stats.total++; \
if (cond) { \
g_gd5f_test_stats.passed++; \
DBG_INFO("[PASS] " fmt, ##__VA_ARGS__); \
} else { \
g_gd5f_test_stats.failed++; \
DBG_ERROR("[FAIL] " fmt, ##__VA_ARGS__); \
} \
} while (0)
#define GD5F_TEST_REPORT(name) do { \
DBG_INFO("=== %s: %d/%d PASSED (failed=%d) ===", \
name, g_gd5f_test_stats.passed, g_gd5f_test_stats.total, \
g_gd5f_test_stats.failed); \
} while (0)
#if defined(ENABLE_GD5F_TESTS)
void gd5f_test_run(void);
#else
#define gd5f_test_run() ((void)0)
#endif
#ifdef __cplusplus
}
#endif
#endif /* GD5F_TEST_H */