关于ECC、OOB,怎么这么麻烦。
先摘抄看到的相关点吧。
《S5PV210_iROM_ApplicationNote_Preliminary_20091126.pdf》:
1. Nand Boot (with H/W 8/16-Bit ECC)
2. In iROM booting with nand flash, S5PV210 can support 8/16-bit H/W ECC. All nand boot can be supported 8-bit H/W ECC. But, 16-bit ECC is supported only one type of Nand which is 4KB 5cycle.
3.
0xD0037F90,NF8_ReadPage_Adv,This internal function is advanced NF8_ReadPage function. (8-Bit ECC Check) Note. 2048, 4096 Page 8bits-bus Nand Only.
0xD0037F94,NF16_ReadPage_Adv,This internal function is advanced NF16_ReadPage function.(4-Bit ECC Check) Note. 2048 page size, 5 cycle address, 16bits-bus Nand Only.
0xD0037FB0 NF8_ReadPage_Adv128p This internal function is advanced NF8_ReadPage function. (8-Bit ECC Check) Note. This is dedicated for only NAND which has 128 page per block with 2K page size.
4.
/**
* This Function copies a block of page to destination memory.( 8-Bit ECC only )
* @param uint32 block : Source block address number to copy.
* @param uint32 page : Source page address number to copy.
* @param uint8 *buffer : Target Buffer pointer.
* @return int32 - Success or failure.
*/
#define NF8_ReadPage_Adv (a,b,c) (((int(*)(uint32, uint32, uint8*))(*((uint32 *) 0xD0037F90)))(a,b,c))
/**
* This Function copies a block of page to destination memory( 4-Bit ECC only )
* @param u32 block : Source block address number to copy.
* @param u32 page : Source page address number to copy.
* @param u8 *buffer : Target Buffer pointer.
* @return int - Success or failure.
*/
#define NF16_ReadPage_Adv(a,b,c) (((int(*)(uint32, uint32, uint8*))(*((uint32 *) 0xD0037F94)))(a,b,c))
“NF8_ReadPage_Adv128p”函数竟然没有说明?
5.
![S5PV210、ECC、OOB_第1张图片](http://img.e-com-net.com/image/info5/4e572aabcfa1405c9024cf77cc65fc7a.jpg)
如果是NAND启动,那么NAND ECC数据就应该像这样存储。关于Note 2)就耐人寻味了。一说,16bit ECC的储存应该218字节为单位,其中的ECC数据需要是26字节。二说,如果是16bit ECC,那么ECC大小又是随NAND FLASH而改变的。到底想让用户怎样?
6.
总的看下来,一开始说nand启动支持16bit ECC,但后续中并未提供支持16bit ECC的读函数。这是要自己实现的节奏?
还有就是,NF8_ReadPage_Adv的“Note. 2048, 4096 Page 8bits-bus Nand Only.”,这种说明真心看不懂啊!!!根据“Note. 2048 page size, 5 cycle address, 16bits-bus Nand Only.”和“which has 128 page per block with 2K page size.”的表示方式,我该理解为2048、4096页???有每块这么多页的nand flash???
没有!那我又该理解为每页2048字节、每页4096字节。但是,下文又说8-bit ECC 对应的是64字节的存储区,前12字节保留,ECC数据为13字节。这样计算下来,64字节区可以存储4次计算得到的ECC数据。
《S5PV210_UM_REV1.1.pdf》:
1.
4.3.9 8-BIT / 12-BIT / 16-BIT ECC PROGRAMMING GUIDE (ENCODING)
1. To use 8/ 12/ 16-bit ECC in software mode, set the MsgLength(NFECCCONF[25:16]) to 511(512byte
message length) and the ECCType to “001/100/101”(enable 8/12/16-bit ECC, respectively). ECC module
generates ECC parity code for 512 byte write data. Therefore, reset ECC value by writing the InitMECC
(NFECCCONT[2]) bit as ‘1’ before writing data, and clear the MainECCLock(NFCONT[7]) bit to ‘0’(Unlock)
before writing
2.
![S5PV210、ECC、OOB_第3张图片](http://img.e-com-net.com/image/info5/654c45e1f19b452ea28142e518340c30.jpg)
S5PV210使能ECC校验,都是512字节校验一次。8-bit ECC一次生成13字节ECC数据。前面说了64字节区能够存储4次,那64字节区只能支持每页512*4=2096,何来支持每页4096字节之说???
512字节校验一次,16-bit ECC一次生成26字节ECC数据,那么每页4096字节,则校验8次,产生8*26=208字节ECC数据,在加上保留的12字节,需要220字节存储区。真不知道那218字节是怎么来的?难道看到有NAND FLASH每页OBB区是218字节,就直接拿来而不做计算了?
真的希望以后慢慢熟悉了发现现在的想法是错的,不然我要对三星失去信心了!真是苦恼啊!
《MT29F8G08ABABAWP.PDF》
镁光的MT29F8G08ABABA:
– Page size x8: 4320 bytes (4096 + 224 bytes)
– Block size: 128 pages (512K +28 K bytes)
– Plane size: 2 planes x 1024 blocks per plane
– Device size: 8Gb: 2048 blocks
For minimum required ECC, see Error Management (page 93).
Error Management
Each NAND Flash die (LUN) is specified to have a minimum number of valid blocks
(NVB) of the total available blocks. This means the die (LUNs) could have blocks that
are invalid when shipped from the factory. An invalid block is one that contains at least
one page that has more bad bits than can be corrected by the minimum required ECC.
Additional blocks can develop with use. However, the total number of available blocks
per die (LUN) will not fall below NVB during the endurance life of the product.
Table 18: Error Management Details
Description Requirement
Minimum number of valid blocks (NVB) per LUN 2008
Total available blocks per LUN 2048
First spare area location Byte 4096
Bad-block mark 00h
Minimum required ECC 4-bit ECC per 540 bytes of data
最小要求每540字节进行4-bit ECC校验,但是S5PV210最大支持每512字节校验一次,这ECC校验还能做吗?
u-boot 默认支持每页8、16、64、128字节的OOB区,但镁光1G的有224字节OOB区,在u-boot中添加struct nand_ecclayout nand_oob_224,case 224:chip->ecclayout = &nand_oob_224;break;生成u-boot,一到nand,u-boot就死了,你该让我咋办???
还是要先解决oobsize问题,这样就可以尝试16bit hwecc了,或许有希望crc校验成功
一直在看Tiny210的相关资料,对于HWECC这一块,由于和飞凌OK210的板子上搭载的NAND Flash芯片不一样,所以一直都没有做成功。然而,还有一个重要的原因就是没有理解一些小细节东西。这两天不断地问度娘,她也只是说别人告诉她什么,就转告我什么。
看着看着,看到了一直都被我忽视的一个点。关于S5PV210启动方式有很多地方讲到。三星《S5PV210_UM_REV1.1》手册上也有说明。启动流程为:S5PV210上电将从IROM(interal ROM)处执行固化的启动代码,它对时钟等初始化、对启动设备进行判断,并从启动设备中复制BL1(最大16KB)到IRAM(0xd002_0000处,其中0xd002_0010之前的16个字节储存的BL1的校验信息和BL1尺寸)中,并对BL1进行校验,校验OK转入BL1进行执行;
取iROM手册会比较清楚BL1的前16字节头部信息,排列格式如下:
_____________________________
|0x0地址:BL1 size |
|0x4地址:必须设置为0 (是规定)|
|0x8地址:CheckSum |
|0xc地址:必须设置为0 (是规定)|
一直都没去查看CheckSum是怎么生成的,也一直以为这是ECC校验生成的校验码。然而仔细看S5PV210 iROM芯片手册会发现,
2.10 Making checksum example code
for(count=0;count< dataLength;count+=1)
{
buffer = (*(volatile u8*)(uBlAddr+count));
checkSum = checkSum + buffer;
}
- count variable is unsigned int type.
- dataLength variable is unsigned int type. It contains size(byte) of BL1.
- buffer variable is unsigned short type. It is used reading 1 byte data from BL1.
- checksum variable is unsigned int type. It contains sum of BL1
checksum只是一个起校验作用的和,当我把它翻译成“校验和”时,却是把它理解为ECC校验生成的校验码。原来一直都是被自己误导着。
因此,只要BL1的前16字节正确,checksum正确,那么不管是哪种启动方式,BL1都能被执行。
此窍一开,一切也都顺利了。现在终于可以从NAND启动了,而不用看到“NAND Check Sum Error”或者“NAND ECC Error”了。