重格式化前清空FTL map树(nand_ftl_format):根治新旧树混合致复位后FAT探针失败的重格式化死循环

This commit is contained in:
2026-09-20 05:36:10 +08:00
parent 99d8a8bb59
commit ac2087e3bd
+6
View File
@@ -233,6 +233,10 @@ void StartDefaultTask(void *argument)
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 树(2026-09-20 台架实证:不清则 mkfs 经旧树
* 写新卷 → on-disk 树残留旧节点/旧绑定 → 复位后 resume 混用新旧 →
* FAT 探针失败 → 无限重格式化) */
(void)nand_ftl_format();
fr = f_mkfs("", &opts, fs_work, sizeof(fs_work));
if (fr == FR_OK) {
fr = f_mount(&default_fatfs, "", 1);
@@ -279,6 +283,8 @@ void StartDefaultTask(void *argument)
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 };