1.当往NAND FLASH 的PAGE中写入数据时,每写入512字节产生3字节ECC。并写入到OOB得ECC位置,此ECC叫做原始ECC。
2.当从NAND FLASH读数据时,每读取512字节产生3字节ECC,叫做新ECC。
3.原始ECC异或新ECC
=12 表示有1位错误,可以纠正;
=1 表示有表示OOB错误
=其他表示无法纠正的错误
4.ECC[2];
32位ECC值=(ECC[2]&0XF0<<20)|ECC[1]<<16 |(ECC[2]&0X0F<<8)|ECC[0]
5.计算ECC值
6.调试结果
7.ECC.MODE=NAND_ECC_HW
8.OOBINFO.ECCBYTES=12;
9.OOBINFO.OOBFREE->OFFSET=1;
10.OOBINFO.OOBFREE->LENGTH=51
11.更改后可以互相写FLASH,但出现ECC效验。
12.nandwrite �Cm /dev/mtd5 uImgae 成功启动;
对比UBOOT和KERNELECC配置
u-boot |
kernel |
|
Ecc_size_config |
Eccsize1+eccsize0+eccsize0sel |
Eccsize1+0xf |
Ecc_config |
dev_width << 7) | (cs << 1) | (0x1 |
dev_width << 7) | (cs << 1) | (0x1 |
Ecc_control |
0x101 |
0x101 |
Oob.oobfree.offset |
13 |
1 |
Oob.oobfree.length |
51 |
51 |
针对上面问题的修改:
gpmc_write_reg(GPMC_ECC_CONTROL,0x00000101);
//ecc_size_conf_val = (eccsize1<< 22) | 0x0000000F;
ecc_size_conf_val = (eccsize1<< 22) | (eccsize0 << 12)|0x0f;
ecc_conf_val = (dev_width<< 7) | (cs << 1) | (0x1);
ecc_size_conf_val = (eccsize1 << 22)| (eccsize0 << 12)|0x0f;
没有0X0F就不会进入控制台,加了会进去,会面研究;
修改:
case GPMC_ECC_WRITE:
if (ecc_type== OMAP_ECC_BCH4_CODE_HW) {
eccsize1 = 0x20; eccsize0 = 0x00;
bch_mod = 0;
bch_wrapmode = 0x06;
} else if(ecc_type == OMAP_ECC_BCH8_CODE_HW) {
eccsize1 = 0x20; eccsize0 = 0x00;
bch_mod = 1;
bch_wrapmode = 0x06;
} else
{
eccsize1= ((ecc_size >> 1) - 1) ;
//add
eccsize0 = ((ecc_size >> 1) - 1) ;
}
break;
制作文件系统问题:
./mkfs.jffs2 -lqnp -e 128 -r sufs -o sufs.jffs2
取消p属性。
./mkfs.jffs2 -lqn -e 128 -r sufs -o sufs.jffs2
[9.548004]jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0149b358: 0x0200instead
[9.557434]jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0149b36c: 0x4004 instead
[9.566802]jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0149b380: 0x0020instead
[9.576171]jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0149b3a8: 0x0080 instead
[9.585540]jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0149b468: 0x0010instead
[9.594909]jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0149b470: 0x0010instead
[9.604248]jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0149b47c: 0x0004 instead
[9.613616]jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0149b504: 0x0400instead
[9.622985]jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0149b570: 0x1000instead
[9.632354] jffs2_scan_eraseblock(): Magicbitmask 0x1985 not found at 0x0149b580: 0x0040 instead
[9.641693] Further suchevents for this erase block will not be printed
[9.652618] Empty flash at0x0149c000 ends at 0x0149c0a8
处理:
./mkfs.jffs2 -lqn -e 128KiB -r sufs -o sufs.jffs2
FLASH空处理
注释掉打印信息: fs/jffs2/scan.c
inbuf_ofs = ofs - buf_ofs;
while(inbuf_ofs < scan_end) {
if (unlikely(*(uint32_t *)(&buf[inbuf_ofs]) != 0xffffffff)) {
//printk(KERN_WARNING"Empty flash at 0x%08x ends at 0x%08x\n",
//empty_start, ofs);
if((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start)))
return err;
gotoscan_more;
}
root@am3517-evm:~# cat /proc/mtd
dev:sizeerasesizename
mtd0: 00080000 00020000 "xloader-nand"
mtd1: 001c000000020000 "uboot-nand"
mtd2: 00040000 00020000 "params-nand"
mtd3: 00640000 00020000 "linux-nand"
mtd4: 03e80000 00020000 "jffs2-nand"
mtd5: 00640000 00020000 "linux.bak-nand"
mtd6: 03e80000 00020000 "jffs2.bak-nand"
mtd7: 37400000 00020000 "share-data"