在海思芯片的uboot下想修改为NAND_ECC_SOFT
进行nand scrub
输入nand write 0xc1500000 0 0x200000
然后输入nand read 0xc1500000 0 0x200000
结果出现nand write 0xc1500000 0 0x200000
通过分析知道ecc_layout的问题
修改hinand.c中的hinand_oob_64_1bit为:
#if 0
static struct nand_ecclayout hinand_oob_64_1bit =
{
.eccbytes = 20,
.eccpos = {
11, 12, 13, 14, 15,
27, 28, 29, 30, 31,
43, 44, 45, 46, 47,
59, 60, 61, 62, 63
},
.oobfree = {{2, 9}, {16, 11}, {32, 11}, {48, 11}}
};
#else
static struct nand_ecclayout hinand_oob_64_1bit =
{
.eccbytes = 24,
.eccpos = {
40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63},
.oobfree = {
{.offset = 2,
.length = 38}}
};
#endif
然后nand read ok。百思不得其解,于是跟踪代码,在nand_scan_tail中有这样一段代码
case NAND_ECC_SOFT:
chip->ecc.calculate = nand_calculate_ecc;
chip->ecc.correct = nand_correct_data;
chip->ecc.read_page = nand_read_page_swecc;
chip->ecc.write_page = nand_write_page_swecc;
chip->ecc.read_oob = nand_read_oob_std;
chip->ecc.write_oob = nand_write_oob_std;
chip->ecc.size = 256;
chip->ecc.bytes = 3;
break;
其中ecc.bytes = 3, 这样我们2k的flash就需要ecclayout中的eccbytes 至少应该大于 3×8 =24字节。
这样也就解释了为什么原来的ecc_layout下nand read failed的问题。