您的位置:首页 > 其它

nand flash控制器

2015-06-11 17:23 295 查看
PIN CONFIGURATION

OM[1:0] = 00: Enable NAND flash memory boot

NCON: NAND flash memory selection(Normal / Advance)

0: Normal NAND flash(256Words/512Bytes page size, 3/4 address cycle)

1: Advance NAND flash(1KWords/2KBytes page size, 4/5 address cycle)

GPG13: NAND flash memory page capacitance selection

0: Page=256Words(NCON = 0) or Page=1KWords(NCON = 1)

1: Page=512Bytes(NCON = 0) or Page=2KBytes(NCON = 1)

GPG14: NAND flash memory address cycle selection

0: 3 address cycle(NCON = 0) or 4 address cycle(NCON = 1)

1: 4 address cycle(NCON = 0) or 5 address cycle(NCON = 1)

GPG15: NAND flash memory bus width selection

0: 8-bit bus width

1: 16-bit bus width

OM[1:0]:使能nand flash存储器 

NCON :nand flash 存储器选择位  

0:正常模式:256字/512字节页,3/4 地址周期

1:先进模式:1K字/2K字节页,4/5 地址周期

GPG13:nand flash 存储器页面容量选择位

0:页 = 256字(NCON = 0)或者页 = 1K字(NCON = 1)

1:页 = 512字节(NCON = 0)或者页 = 2K字节(NCON = 1)

GPG14:nand flash 存储器地址周期选择位

0:3地址周期(NCON = 0)或者 4地址周期(NCON = 1)

1:4地址周期(NCON = 0)或者 4地址周期(NCON = 1)

GPG15:nand flash 存储器总线宽度选择位

0:8bit 总线宽度

1:16bit 总线宽度

NOTE

The configuration pin – NCON, GPG[15:13] – will be fetched during reset.

In normal status, these pins must be set as input so that the pin status is not to be changed, when enters

Sleep mode by software or unexpected cause.

这些配置引脚 —— NCON ,GPG[15:13]  在重启时将被获取

在正常状态中,这些引脚必须被设置成输入以便当在由软件设置进入睡眠模式或意外的原因发生时,这些引脚不被改变

Nand flash启动 

在s3c2410的datasheet的述(OVERVIEW)中,讲到需要注意的几点:

一、nandflash是没有办法直接映射到cpu内存空间的。nandflash要通到控制方式(在这里是nandflash controller)与cpu交换数

据。

二、既然没有办法映射到内存空间,就没有办法从nandflash直接启动。(原因:系统启动或复位时cpu中没有任何代码,系统会从

内存空间0x00000000开始取指令到cpu运行,而nandflash没有办法通过0x00000000这个地址访问,至少在启动时不能)。

三、办法是人想出来的。s3c2440a,包括s3c2410,采用stepping stone方式实现了从nandflash启动。stepping stone(垫脚时),

就是s3c2440a中内置的一段4KB的SRAM.当系统启动时,nandflash controller通过硬件方式把nandflash中前4KB中的内容拷贝到

stepping stone中。

我当看到这里就想,既然可以通过硬件方式拷贝。做到同样方式拷贝到SDRAM中不就行了?为什么还要有nandflash的驱动呢?

其实是这样的:硬件拷贝只是单纯的拷贝。没有办法做ECC校验。这样肯定是不行的,大家也知道。nandflash的正常工作是要

ecc校验来保证的。

那么这里就不需要ECC校验了吗?

不需要,因为在后面了解到。nandflash它的第一个块是采用特殊工艺制作的。它的工艺保证了它的第一个块是不会出现位反转的。

(当然也不是绝对,但是在很大程度上)。所以回到主题上来,我们是可以直接把前4KB拷贝到SRAM中的,但没有办法通过这种方式

做后面的工作。

前4KB的代码己经进入sram,我们的板子都有一个跳线开关,那个开关就是为了控制启动方式选择的。一边是选择norflash.另一面是

选择nandflash.如果我们是选择nandflash,系统会通过自带的硬件方式把sram映射到内存空间的0x00000000处。然后cpu会自动从

0x00000000处的指令,开始运行。

注意:所有的上述过程都是硬件自动完成的。当中除了在硬件设计上需要注意的一些情况外,复位时无需人工干预。

四、这段4KB的代码是用来做什么的呢?

书中暗表,这4KB是有他们特殊的使命的。它们要把bootloader的后面部分全部通过软件方式拷贝到SDRAM中去,也就是内存中去。

能起到这个作用的代码在很常见的u-boot开源代码中是没有的。最起码到1.3.4的版本还没有。大家要用的话需要做移植。

而移植时要考虑的方方面面则留待下回分解。

说到最后,再讲一个数据手册里的最后的features段的内容:

FEATURES

1. Auto boot: The boot code is transferred into 4-kbytes Steppingstone during reset. After the transfer, the boot

code will be executed on the Steppingstone.

2. NAND Flash memory I/F: Support 256Words, 512Bytes, 1KWords and 2KBytes Page.

3. Software mode: User can directly access NAND flash memory, for example this feature can be used in

read/erase/program NAND flash memory.

4. Interface: 8 / 16-bit NAND flash memory interface bus.

5. Hardware ECC generation, detection and indication (Software correction).

6. SFR I/F: Support Little Endian Mode, Byte/half word/word access to Data and ECC Data register, and Word

access to other registers

7. SteppingStone I/F: Support Little/Big Endian, Byte/half word/word access.

8. The Steppingstone 4-KB internal SRAM buffer can be used for another purpose after NAND flash booting.

特点:

一、自动引导

引导时,引导代码会被传送给4KB的垫脚石(stepping stone)中。传送后引导代码会自动在stepping stone中运行。

需要注意的就是这个传送过程是通过nandflash controller来做到的。这是一个硬件完成的过程,无需你的任何操作。而且

stepping stone是一个段sram.通过nandflash启动时它会被自动(这里自动与上面是一个意思,无需你任何操作,或代码)映射到

0x00000000并执行。上面都讲了。这里只是重申一下罢了。

二、nandflash存储器接口

支持256words,512bytes,1Kwords,2Kbytes 每页。

一般来说,我们板子上多数是512bytes的那种。

三、软件模式

用户可以直接访问nandflash存储内容。比如说我们可以比它进行读、写、擦除的操作。

注意,这里说的是软件方式,不是硬件自动的了哦。想读写什么的还有点麻烦呢。稍后章节介绍。

四、接口:8/16位nandflash接口总线。

五、硬件ecc产生,检测和指正(后者指软件改正)不懂的看稍后章节。

六、特殊功能寄存器(SFR)接口

支持小端模式字节/半字/字访问数据和ECC数据寄存器。支持字访问其它寄存器。

这里的意思是说:对数据寄存器和ECC数据寄存器可以每次访问一个字节/一个半字/一个字,即8/16/32位都可以。但其它寄存器

一次只可以访问一个字。即32位方式访问。

七、stepping stone 接口

支持小端/大端,字节/半字/字访问。

八、垫脚石(stepping stone)

啊!上面忘记讲了。这个sram再引导过程结束后是可以用作其它用途的。

嘿嘿,回头又看数据手册,原来它也要讲这条。我上面只是想插一条,下面再讲本条数据手册的内容呢。巧合!无巧不成书啊!

这些都是有了一知半解后再回头看数据手册,根据自己理解做了些解释,自以为很详细了。但是我也知道,如果初次接触的话,

还是看不懂。我会继续讲解其它内容,然后来这里做链接,希望对大家有所帮助。

ECC PROGRAMMING GUIDE

1. In software mode, ECC module generates ECC parity code for all read / write data. So you have to reset ECC

value by writing the InitECC(NFCONT[4]) bit as ‘1’ and have to clear theMainECCLock(NFCONT[5]) bit to

‘0’(Unlock) before read or write data.

MainECCLock(NFCONT[5]) and SpareECCLock(NFCONT[6]) control whether ECC Parity code is generated

or not.

2. Whenever data is read or written, the ECC module generates ECC parity code on register NFMECC0/1.

3. After you completely read or write one page (not include spare area data), Set the MainECCLock bit to

‘1’(Lock). ECC Parity code is locked and the value of the ECC status register will not be changed.

4. To generate spare area ECC parity code, Clear as ‘0’(Unlock) SpareECCLock(NFCONT[6]) bit.

5. Whenever data is read or written, the spare area ECC module generates ECC parity code on register

NFSECC.

6. After you completely read or write spare area, Set the SpareECCLock bit to ‘1’(Lock). ECC Parity code is

locked and the value of the ECC status register will not be changed.

7. Once completed you can use these values to record to the spare area or check the bit error.

ECC编程指南

1.在软件模式,ECC模块为所有的读数据或写数据产生ECC校验代码。所以必须在读数据或写数据之前通过往InitECC(NFCONT[4])位

写‘1’和清除theMainECClock(NFCONT[5])位为‘0’重设ECC值。

MainECCLock(NFCONT[5])和SpareECCLock(NFCONT[6])控制ECC检验代码是否产生。

2.无论数据是写还是读时,ECC模块在寄存器 NFMECC0/1 产生ECC校验代码。

3.在你完成读或写页后(不包括备用区数据),需设置MainECCLock(NFCONT[5])位为‘1’(锁状态)。ECC校验代码是被锁住的,同时

ECC状态寄存器的值不会改变。

4.为了产生备用区校验代码,清除SpareECCLock(NFCONT[6])位为‘0’(解锁状态)。

5.无论数据是写还是读时,ECC模块在寄存器 NFSECC 产生ECC校验代码。

6.在你完成读或写备用区后,需设置SpareECCLock(NFCONT[6])位为‘1’(锁状态)。ECC校验代码是被锁住的,同时ECC状态寄存器的

值不会改变。

7.一旦完成你可以使用这些值来记录备用区域或检查错误。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nand flash