nand_ecclayout
该结构体定义如下: struct nand_ecclayout { uint32_t eccbytes; ? ?//表示使用几个ecc字节 uint32_t eccpos[128]; //表示ecc占用的位置,因为现在大页面4kbyte也就128个,所以这里写了128, ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //以后有更大页面的,这里也要改了。 uint32_t oobavail; ? ? ? //有几个oob可用,这个跟下面的成员有点像,一般用下面的 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES]; ?//定义oob有效个数,从哪开始等 }; 给个例子: static struct nand_ecclayout mylayout = { #ifdef CONFIG_SYS_NAND_PAGE_2K .eccbytes = 40, .eccpos = {? 24,25,26,27,28,51); font-family:Arial; font-size:14px; line-height:26px; text-align:left; margin-top:1em; margin-bottom:0.5em; padding-top:0px; padding-bottom:0px"> 29,30,31,32,33,34,35,36,37,38,51); font-family:Arial; font-size:14px; line-height:26px; text-align:left; margin-top:1em; margin-bottom:0.5em; padding-top:0px; padding-bottom:0px"> 39,40,41,42,43,44,45,46,47,48,51); font-family:Arial; font-size:14px; line-height:26px; text-align:left; margin-top:1em; margin-bottom:0.5em; padding-top:0px; padding-bottom:0px"> 49,50,52,53,54,55,56,57,58,51); font-family:Arial; font-size:14px; line-height:26px; text-align:left; margin-top:1em; margin-bottom:0.5em; padding-top:0px; padding-bottom:0px"> 59,60,61,62,63,? },51); font-family:Arial; font-size:14px; line-height:26px; text-align:left; margin-top:1em; margin-bottom:0.5em; padding-top:0px; padding-bottom:0px"> .oobfree = { {.offset = 2,.length = 22,},51); font-family:Arial; font-size:14px; line-height:26px; text-align:left; margin-top:1em; margin-bottom:0.5em; padding-top:0px; padding-bottom:0px"> #endif } ? nand->ecc.size = 512;? nand->ecc.bytes = 10; 恩,这下明朗了,我们需要每512个字节产生10个ecc字节,因此对2kbyte页面的flash来说,一页就是4个512,因此需要4*10=40个ecc字节。 .eccpos就是告诉驱动,这些ecc字节放在哪里,一般是按顺序存放,不要覆盖芯片默认的坏块标记位,对2kbyte的flash来说,厂家说是前两个即第0、1个字节是坏块标志。 所以分配为eccbytes和eccpos后,后面有个oobfree,这样看来也很明白了: offset=2表示从第2个字节开始(因为前面2个是坏块标志啊~~),length=22表示(从offset开始)共22个ecc字节可以用户随便用。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |