微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Nandflash 驱动移植 二

Nandflash驱动移植系列文章导航:

Nandflash 驱动移植 (一)

Nandflash 驱动移植 (二)

Nandflash 驱动移植 (三)

Nandflash 驱动移植 (四)

Nandflash 驱动移植 (五)

Nandflash 驱动移植 (六)

一共六篇

 

 

 

这里将会介绍一下S3C6410cpu中的NFCON,Nandflash控制寄存器


8.1 OVERVIEW 
 Recently nor flash memory price has increased and pr ice for SDRAM and a NAND flash memory is moderatly placed.    
 The 6410 is equipped with an internal SRAM buffer called ‘Steppingstone’. 
 Generally,the boot code will copy NAND flash content to SDRAM. Using hardware  ECC,the NAND flash data 
 validity will be checked. After the NAND flash content  is copied to SDRAM,main program will be executed on SDRAM. 
 To use NAND Flash,'XSELNAND' pin must be connected to High Level. 
  
 8.2 FEATURES 
 NAND flash controller features include: 
    
 1.  NAND Flash memory I/F: Support 512Bytes and 2KB Page  . 
 2.  Software mode: User can directly access NAND flash memory.  for example this feature can be used in read/erase/program NAND flash memory. 
 3.  Interface: 8-bit NAND flash memory interface bus. 
 4.  Hardware ECC generation,detection and indication (Software correction). 

硬件产生ECC,软件矫正
 5.  Support both SLC and MLC NAND flash memory : 1-bit ECC,4-bit and 8-bit ECC for NAND flash. 
       (Recommend: 1bit ECC for SLC,4bit and 8bit ECC for MLC NAND Flash) 

同时支持SLC和MLC的Nandflash:1bit ECC用于SLC Nandflash, 4bit和8bit ECC用于MLC Nandflash
 6.  SFR I/F: Support Byte/half word/word access to Data and ECC Data register,and Word access to other  registers 
 7.  SteppingStone I/F: Support Byte/half word/word access. 
 8.  The Steppingstone 8-KB internal SRAM  buffer can be used for another purpose  . 


其他的这里就不废话了,大家看回文档吧。

其中要注意的地方:

Both 4bit and 8bit ECC modules can be used for only 512 bytes ECC parity code generation.  

4bit和8bit的ECC模块同时能够用于产生每读写512字节数据对应的ECC校验值。


 4 bit and 8bit ECC modules generate the parity codes for each 512 byte. However,1 bit ECC modules generate 
 parity code per byte lane separately. 


 4bit ECC modules generate max 7byte parity codes and 8  bit ECC modules generate 13byte parity codes at each 
 512/24 bytes. 

在每读写512或24字节的数据时,4bit的ECC模块产生最多7个字节的ECC校验码,而8bit的ECC模块产生最多13字节的校验码


下面直接来看8bit ECC的编解码:

8.8.5 8-BIT ECC PROGRAMMING GUIDE (ENCODING) 
  1.  To use 8-bit ECC in software mode,set the Ms gLength to 0(512-byte message length) and set the ECCType 
 to “01”(enable 8-bit ECC). ECC module generates ECC parit y code for 512-byte write data. In order to start 
 the ECC module,you have to write ‘1’ on the Init MECC (NFCONT[5]) bit after cleaning the MainEcclock 
 (NFCONT[7]) bit to ‘0’ (Unlock). MainEcclock (NFCONT[7]) bit controls whether ECC Parity code is 
 generated or not. 
 Note. In 8bit ECC,MainEcclock should be cleared before initiating InitMECC. 
 2.  Whenever data is written,the 8bit ECC module generates ECC parity code internally. 
 3.  After you finish writing 512-byte  data (not include spare area data),the parity codes are automatically updated 
 to NF8MECC0,NFMECC1,NF8MECC2,NF8MECC3 regi ster. You have to check encoding done at NFSTAT 
 register. And set the MainEcclock bit to ‘1’(lock).   If you use 512-byte page size NAND flash memory,you 
 can program these values directly to spare area.  However,if you use NAND flash memory more than 512-
 byte page,you can’t program immediately. In this case,you have to copy these par ity codes to other memory 
 like DRAM. After writing all main data,you c an write the copied ECC values to spare area. 
 The parity codes have self-correctable information include parity code itself. 
 4.  To generate spare area ECC parity code,set the MsgLength to 1(24-byte message length),and set the 
 ECCType to “01”(enable 8bit ECC). 8bit ECC module generates the ECC parity code for 24-byte data. In 
 order to initiating the module,you have to write ‘1 ’ on the InitMECC (NFCONT[5]) bit after clearing the
MainEcclock (NFCONT[7]) bit to ‘0’(Unlock).  
 MainEcclock (NFCONT[7]) bit controls whether ECC Parity code is generated or not. 

 Note. In 8bit ECC,MainEcclock should be cleared before initiating InitMECC. 
 5.  Whenever data is written,the 8bit ECC module generates ECC parity code internally. 
 6.  When you finish writing 24-byte Meta or extra data,the parity codes are automatically updated to 
 NF8MECC0,NF8MECC3 register. you have to check encoding done at NFSTAT 
 register. And set the MainEcclock bit to ‘1’(lock) .  You can program these parity codes to spare area. The 
 parity codes have self-correctable information include parity code itself. 

部分译文:(仅供参考)

8bit ECC编码:
1、要用8bit的ECC,需要设置MsgLength 为0(512-byte message length) 和设置ECCTypet为 “01”(enable 8bit ECC)。8bit ECC模块会在读取512字节主数据之后产生对应的ECC校验码。要8bit的ECC模块开始工作,你必须在设置InitMECC (NFCONT[5])为1之前把MainEcclock (NFCONT[7]) 清0进行解锁。
MainEcclock (NFCONT[7]) 位控制着是否要产生对应的ECC校验码。
注意:在8bit ECC中,MainEcclock必须先清0,然后在对InitMECC置1
2、数据一旦写完,MLC的ECC模块就会产生对应的ECC校验码。
3、当你完成了512字节的主数据的写操作(不包括备用区数据),对应的ECC校验码将会自动的更新到NFM8ECC0,NFM8ECC1,NFM8ECC2,NFM8ECC3寄存器中。你必须在NFSTAT寄存器中检测编码是否完成 在这里应该是NFSTAT[7],不知道为什么文档中的NFSTAT寄存器中的7bit为保留位,而三星的MLC bsp中却有用到这个位,这个情况大家可以推敲下。同时,设置MainEcclock 为1加锁。如果你用的是512字节页大小的Nandflash存储,你可以直接把这些产生的ECC校验码写到备用区中。如果你使用的Nandflash存储超过了512字节的页大小,你不能够直接把产生的ECC校验码写到备用区中。在这种情况,你必须把每写512字节主数据产生的ECC校验码拷贝到其他存储器中,如DRAM。当写完所有的主数据(即一页大小的主数据),你可以把拷贝到其他存储器的ECC校验码写到备用区中。这个校验码带有自身矫正的信息和校验码值。
剩下的ECC读写基本雷同,这里就不翻译了。


8.8.6 8-BIT ECC PROGRAMMING GUIDE (DECODING) 
 1.  To use 8bit ECC in software mode,set the MsgLength to 0(512-byte message length) and set the ECCType
 to “01”(enable 8bit ECC). 8bit ECC module generates E CC parity code for 512-byte read data. In order to 
 initiating 8bit ECC module,you have to write ‘1’ on the InitMECC (NFCONT[5]) bit after clearing the 
 MainEcclock (NFCONT[7]) bit to ‘0’(Unlock).  
 MainEcclock (NFCONT[7]) bit controls whether ECC Parity code is generated or not. 
 Note. In 8bit ECC,MainEcclock should be cleared before InitMECC 
 2.  Whenever data is read,the MLC ECC m odule generates ECC parity code internally. 
 3.  After you complete reading 512-byte data (not including spare area data),you must set the MainEcclock 
 (NFCONT[7]) bit to ‘1’(Lock) after reading parity  codes. 8bit ECC module needs parity codes to detect 
 whether error bits exists or not. So you have to read the ECC parity code of 512-byte main data right after 
 reading the 512-byte data. Once the ECC parity code is  read,8bit ECC engine starts searching any error 
 internally. 8bit ECC error searching engine needs mini mum 372 cycles to find any error. And set the 
 MainEcclock bit to ‘1’(lock). ECCDecDone(NFSTAT[6]) can be used to check whether ECC decoding is 
 completed or not.  
 4.  When ECCDecDone (NFSTAT[6]) is set (‘1’),NF8ECCERR0 indicates whether error bit exists or not. If any 
 error exists,you can fix it by referencing NF8ECCERR0/1/2 and NFMLC8BITPT0/1 register. 
 5.  If you have more main data to read,continue doing from step 1. 
 6.  For Meta data error check,set the MsgLength to 1(24-byte message length) and set the ECCType to 
 “01”(enable 8bit ECC). ECC module generates the ECC parity  code for 24-byte data. In order to initiating the
 8bit ECC module,you have to write ‘1’ on the InitMECC (NFCONT[5]) bit after clearing the MainEcclock 
 (NFCONT[7]) bit to ‘0’(Unlock).  
 MainEcclock (NFCONT[7]) bit controls whether ECC Parity code is generated or not. 
 Note. In 8bit ECC,MainEcclock should be cleared before InitMECC 
 7.  Whenever data is read,the 8bit ECC module generates ECC parity code internally. 

8.  After you complete reading 24-byte,you must set the MainEcclock (NFCONT[7]) bit to ‘1’(Lock) after read 
 ing the parity code for 24-byte data. MLC ECC module needs parity codes to detect w hether error bits exists 
 or not. So you have to read ECC parity codes right after reading 24-byte data. Once ECC parity code is read, 
 8bit ECC engine starts searching any error internally. 8bit ECC error searching engine needs minimum 372 
 cycles to find any error. And set the MainEcclock  bit to ‘1’(lock). ECCDecDone(NFSTAT[6]) can be used to 
 check whether ECC decoding is completed or not.    
 9.  When ECCDecDone (NFSTAT[6]) is set (‘1’),NF8ECCERR0 indicates whether error bit exist or not. If any 

error exists,you can fix it by referencing NF8ECCERR0/1/2 and NF8MLCBITPT register. 

部分译文:(仅供参考)

8bit ECC译码:
1、要用8bit的ECC,需要设置MsgLength 为0(512-byte message length) 和设置ECCTypet为 “01”(enable 8bit ECC)。8bit ECC模块会在读取512字节主数据之后产生对应的ECC校验码。要8bit的ECC模块开始工作,你必须在设置InitMECC (NFCONT[5])为1之前把MainEcclock (NFCONT[7]) 清0进行解锁。
MainEcclock (NFCONT[7]) 位控制着是否要产生对应的ECC校验码。
注意:在8bit ECC中,MainEcclock必须先清0,然后在对InitMECC置1
2、数据一旦被读取,MLC的ECC模块就会产生对应的ECC校验码。
3、在完成读取512字节的主数据后(不包括备用区数据),读取对应的主数据区的校验码,然后必须设置MainEcclock(NFCONT[7])位为1,锁住ECC的产生。8bit 的ECC模块需要这个校验码来确定是否有错误位的存在。所以你必须在读取完512字节的主数据之后,把对应的主数据区的ECC校验码读取出来。一旦主数据区对应的ECC校验码被读,8bit的ECC引擎就会开始查找错误。8bit的ECC错误查找引擎需要最少372个周期去查找存在的错误。同时设置MainEcclock位为1,加锁。ECCDecDone(NFSTAT[6]) 可以用于检测ECC译码是否完成。
4、当ECCDecDone (NFSTAT[6])设置为1,NF8ECCERR0会指出是否有错误位的存在。如果有错误存在,你可以用NF8ECCERR0/1/2和NFMLC8BITPT0/1去修正相应的错误
5、如果你有更多的主数据要读取,则从第一步开始重复操作。

PS: 原文中有些寄存器是写错的,大家在看的时候要注意。

吐槽一下,三星这个文档实在是简陋的可以,而且错误的地方还很多,想不BS一下都不成。


在这里有个地方要注意的是:

在写数据到Nandflash的时候,每写512字节就会产生一次ECC,我们这里用的是4K页,大于512字节,所以必须把产生的ECC校验值保存起来,等到一页(4k)写完,再把这些ECC写入到备用区中。

而在读取数据的时候,却是每读取512字节的主数据,就会产生一次ECC,这时就要进行ECC校验、矫正了。和写的时候不大一样,需要注意这一点。


寄存器部分:


红色框住是主要使用的寄存器和8bit ECC所用到的寄存器。









主要用到的寄存器就到这了,下一篇将开始代码部分。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐