GD5F双装载修复:page_read/program_load二次装载消除低VDD提前就绪竞态(半新半旧页致resume读旧树)
This commit is contained in:
@@ -175,21 +175,30 @@ int dhara_nand_prog(const struct dhara_nand *n, dhara_page_t p, const uint8_t *d
|
||||
|
||||
int dhara_nand_is_free(const struct dhara_nand *n, dhara_page_t p) {
|
||||
(void)n;
|
||||
uint32_t i;
|
||||
uint8_t buf[64];
|
||||
uint32_t phy_pg = ftl_phy_page(p);
|
||||
int fre;
|
||||
|
||||
if (gd5f_page_read(phy_pg) != GD5F_OK) {
|
||||
return 0;
|
||||
}
|
||||
gd5f_read_from_cache(0, buf, sizeof(buf));
|
||||
fre = 0;
|
||||
} else {
|
||||
uint8_t buf[64];
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < sizeof(buf); i++) {
|
||||
if (buf[i] != 0xFF) {
|
||||
return 0;
|
||||
gd5f_read_from_cache(0, buf, sizeof(buf));
|
||||
fre = 1;
|
||||
for (i = 0; i < sizeof(buf); i++) {
|
||||
if (buf[i] != 0xFF) {
|
||||
fre = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
if (s_probe_log) {
|
||||
DBG_INFO("probe t %lu isfree pg %lu = %u",
|
||||
(unsigned long)HAL_GetTick(), (unsigned long)phy_pg,
|
||||
(unsigned int)fre);
|
||||
}
|
||||
return fre;
|
||||
}
|
||||
|
||||
int dhara_nand_read(const struct dhara_nand *n, dhara_page_t p, size_t offset, size_t length, uint8_t *data, dhara_error_t *err) {
|
||||
@@ -221,14 +230,17 @@ int dhara_nand_read(const struct dhara_nand *n, dhara_page_t p, size_t offset, s
|
||||
gd5f_read_from_cache((uint16_t)offset, data, length);
|
||||
|
||||
if (s_probe_log && offset == 0 && length == FTL_PAGE_SIZE) {
|
||||
/* 组末页(组内偏移 15)= checkpoint 页:记录 magic/epoch 判定 */
|
||||
if ((p & 63u) == 15u) {
|
||||
/* 组末页(组内偏移 15:页号低 4 位 = 15)= checkpoint 页:
|
||||
* 记录 raw 前 4 字节 + 时间戳(捕捉 stale buffer:
|
||||
* 读到上一页残留 = 13h 就绪信号早于 buffer 装载完成) */
|
||||
if ((p & 15u) == 15u) {
|
||||
const uint8_t *m = data;
|
||||
DBG_INFO("probe pg %lu blk %lu chk: magic=%u epoch=%u",
|
||||
DBG_INFO("probe t %lu pg %lu blk %lu g%lu: %02X %02X %02X %02X",
|
||||
(unsigned long)HAL_GetTick(),
|
||||
(unsigned long)phy_pg, (unsigned long)(p >> 6),
|
||||
(unsigned int)((m[0] == 'D' && m[1] == 'h' &&
|
||||
m[2] == 'a') ? 1 : 0),
|
||||
(unsigned int)m[3]);
|
||||
(unsigned long)((p >> 4) & 3u),
|
||||
(unsigned int)m[0], (unsigned int)m[1],
|
||||
(unsigned int)m[2], (unsigned int)m[3]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user