From 022e14398e572a21cc6066ea559a240d11ac3057 Mon Sep 17 00:00:00 2001 From: Wanderingss <1624155937@qq.com> Date: Sun, 20 Sep 2026 04:30:19 +0800 Subject: [PATCH] =?UTF-8?q?FTL=E7=BC=96=E7=A8=8B=E5=9B=9E=E8=AF=BB?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=EF=BC=9Aprogram=E5=90=8E=E5=9B=9E=E8=AF=BB?= =?UTF-8?q?=E6=AF=94=E5=AF=B9+ECC=E6=A3=80=E6=9F=A5=EF=BC=8C=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=A0=87=E8=AE=B0=E5=9D=8F=E5=9D=97=E7=94=B1dhara?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=EF=BC=88=E6=A0=B9=E6=B2=BB=E4=BD=8EVDD?= =?UTF-8?q?=E9=9D=99=E9=BB=98=E4=B8=A2=E6=95=B0=E6=8D=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Drivers/BSP/GD5F2GQ5UE/nand_ftl.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Drivers/BSP/GD5F2GQ5UE/nand_ftl.c b/Drivers/BSP/GD5F2GQ5UE/nand_ftl.c index 0702e20c..4df7f20c 100644 --- a/Drivers/BSP/GD5F2GQ5UE/nand_ftl.c +++ b/Drivers/BSP/GD5F2GQ5UE/nand_ftl.c @@ -132,6 +132,36 @@ int dhara_nand_prog(const struct dhara_nand *n, dhara_page_t p, const uint8_t *d return -1; } + /* 编程回读校验(2026-09-20 台架实证):供电低于标称(3.1V)时 + * program 可"状态成功"但 cell 未可靠 latch(ECC 不可纠或数据错位)—— + * 状态寄存器发现不了,下次复位 journal resume 因 ECC 门拒绝这些 + * checkpoint 页 → 新写入整体静默丢失(重格式化循环的真根因)。 + * 回读比对+ECC 检查,失败则标记坏块由 dhara 迁移,宁可丢块不丢卷。 */ + if (gd5f_page_read(phy_pg) != GD5F_OK) { + dhara_nand_mark_bad(n, p >> n->log2_ppb); + dhara_set_error(err, DHARA_E_ECC); + DBG_ERROR("program verify: readback fail, blk %lu", + (unsigned long)(p >> n->log2_ppb)); + return -1; + } + + if (gd5f_check_ecc() != GD5F_OK) { + dhara_nand_mark_bad(n, p >> n->log2_ppb); + dhara_set_error(err, DHARA_E_ECC); + DBG_ERROR("program verify: ecc uncorrectable, blk %lu", + (unsigned long)(p >> n->log2_ppb)); + return -1; + } + + gd5f_read_from_cache(0, s_copy_buf, FTL_PAGE_SIZE); + if (memcmp(s_copy_buf, data, FTL_PAGE_SIZE) != 0) { + dhara_nand_mark_bad(n, p >> n->log2_ppb); + dhara_set_error(err, DHARA_E_BAD_BLOCK); + DBG_ERROR("program verify: data mismatch, blk %lu", + (unsigned long)(p >> n->log2_ppb)); + return -1; + } + return 0; }