NAND

NAND data

NAND 数据

Please, find here the table describing different characteristics of various NAND flashes.

请在此处找到描述各种NAND闪存的不同特性的表格。(http://www.linux-mtd.infradead.org/nand-data/nanddata.html

NAND vs. NOR

Beside the different silicon cell design, the most important difference between NAND and NOR Flash is the bus interface. NOR Flash is connected to a address / data bus direct like other memory devices as SRAM etc. NAND Flash uses a multiplexed I/O Interface with some additional control pins. NAND flash is a sequential access device appropriate for mass storage applications, while NOR flash is a random access device appropriate for code storage application. NOR Flash can be used for code storage and code execution. Code stored on NAND Flash can't be executed from there. It must be loaded into RAM memory and executed from there.

除了不同的硅单元设计外,NAND和NOR Flash最重要的区别是总线接口。与SRAM等其他存储设备一样,NOR Flash直接连接到地址/数据总线。NAND Flash使用带有一些附加控制引脚的多路复用I/O接口。NAND FLASH是一种适用于大量存储应用的顺序存取设备,而NOR FLASH是一种适用于代码存储应用的随机存取设备。NOR Flash可以用于代码的存储和执行。存储在NAND Flash上的代码不可以直接在NAND上执行。它必须被加载到RAM内存并执行。

NOR NAND
InterfaceBusI/O
Cell SizeLargeSmall
Cell CostHighLow
Read TimeFastSlow
Program Time single ByteFastSlow
Program Time multi ByteSlowFast
Erase TimeSlowFast
Power consumptionHighLow, but requires additional RAM
Can execute codeYes

No, but newer chips can execute a small loader out of the first page

不能,但较新的芯片可以从第一页执行小型加载器

Bit twiddlingnearly unrestricted1-3 times, also known as "partial page program restriction"
Bad blocks at ship timeNoAllowed

Some facts about write speed.

一些关于写速度的事实。
NAND is typically faster than NOR for large writes. A typical NOR write is 10uS per word, which results in 1280uS per 512 bytes on a 32-bit bus. A typical NAND write is 50nS per byte + 10uS page seek + 200uS program which results in 236uS per 512 bytes on a 8 bit bus.

对于大范围写入,NAND通常比NOR快。通常,NOR写一个字要花10us,也就是在32位总线上写512字节要花1280us。典型的NAND写入是每字节50nS+10US页面寻道+200uS编程,这导致在8位总线上每512字节236uS。

As NAND Flash is cheaper than NOR Flash and has a very slim interface it was selected as the optimum solution for large nonvolatile storage applications such as solid state file storage, digital audio/voice recorder, digital still camera and portable applications requiring non-volatility.

由于NAND Flash比NOR Flash便宜,并且接口非常简便,因此它被选为大型非易失性存储应用的最佳解决方案,例如固态文件存储、数字音频/录音器、数码相机和需要非易失性的便携式应用。

NAND Types

NAND 类型

There are various types of NAND Flash available. Bare NAND chips, SmartMediaCards, DiskOnChip.

有许多类型的NAND Flash可供选择。裸NAND芯片、SmartMediaCard、DiskOnChip。

SmartMediaCards are bare NAND chips covered by thin plastic. They are very common in digital cameras and MP3 players. The card itself contains nothing smart at all. It gets smart by software.

SmartMediaCards 是覆盖着薄塑料的裸露NAND芯片。它们在数字相机和MP3播放器中很常见。这张卡本身不包含任何智能。它通过软件变得智能起来。

DiskOnChip is NAND Flash with additional glue logic as a drop in replacement for NOR Flash chips. The glue logic provides direct memory access to a small address window, which contains a boot loader stub, which loads the real boot code from the NAND device. The logic contains also control registers for the static NAND chip control lines and a hardware ECC generator.

DiskOnChip是NAND闪存,具有额外的粘合逻辑,作为NOR闪存芯片的替代产品。粘合逻辑提供对一个小地址窗口的直接内存访问,该地址窗口包含一个引导加载程序存根,该存根从NAND设备加载实际的引导代码。该逻辑还包含用于静态NAND芯片控制线的控制寄存器和硬件ECC生成器。

NAND technical view

NAND 技术视图

The memory is arranged as an array of pages. A page consists of 256 / 512 Byte data and 8 / 16 Byte spare (out of band) area. Newer chips have 2048 Bytes data and and 64 Bytes spare area sizes. The spare area is used to store ECC (error correction code), bad block information and filesystem-dependent data. n pages build one block. The read / write access to data is on a per page basis. Erase is done on a per block basis. The commands to read / write / erase the chip is given by writing to the chip with the Command Latch Enable pin high. Address is given by writing with the Address Latch Enable pin high.

存储器被布置为页面阵列。一页有256/512字节数据和8/16字节OOB区。更新的芯片有2048字节数据和64字节OOB。这些OOB被用来存储ECC(错误纠正码),坏块信息和依赖于文件系统的数据。n个页面组成一个块。对数据的读/写访问是按页进行的。擦除则是按块进行的。读取/写入/擦除芯片的命令通过在命令锁存使能引脚为高电平的情况下写入芯片来给出。在地址锁存使能引脚为高电平的情况下写入,即可给出地址。

There are only a few lines necessary to access NAND Flashmemory.

只需几行即可访问NAND闪存。

16 bit buswidth chips are supported.

支持16位宽芯片。

Pin(s) Function
I/O 0-7(15)Data Inputs/Outputs 数据输入/输出
/CEChip Enable 芯片使能脚
CLECommand Latch Enable 命令锁存脚
ALEAddress Latch Enable 地址锁存脚
/RERead Enable 读使能
/WEWrite Enable 写使能
/WPWrite Protect 写保护
/SESpare area Enable 备用区使能
R/BReady / Busy Output 就绪/忙碌输出

As it is necessary to use the spare area, the /SE (Spare area Enable) pin should be tied to GND. /CE, CLE and ALE should be GPIO pins or latched signals. It's possible to use address lines for ALE and CLE, but you have to take care about the timing restrictions of the chip !

由于备用区是必须要用的,所以/SE(备用区使能引脚)应该接到地。/CE、CLE和ALE应为GPIO引脚或锁存信号。ALE和CLE可以使用地址线,但必须注意芯片的时序限制!

/RE and /WE can be tied to the corresponding lines of the CPU. Make sure, that they are logicaly combined with the corresponding chipselect. You can also use two different chipselects for /RE and /WE, but be aware of data hold time constraints of your NAND chip. Data hold time after rising edge of /WE is different to data hold time after rising edge of chipselect lines!

/RE和/WE可以绑定到CPU的对应行。确保它们在逻辑上与相应的芯片选择相结合。您也可以对/RE和/WE使用两种不同的芯片选择,但请注意NAND芯片的数据保持时间限制。/WE上升沿后的数据保持时间与芯片选择线上升沿后的数据保持时间不同!

I/O 0-7(15) are connected to the databus D0-D7(D15). The /WP pin can be used for write protection or connected to VCC to enable writes unconditionally. As NAND flash uses a command driven programming and erasing, an accidental write or erase is not likely to happen. The Ready / Busy output is not necessary for operation, but it can be tied to a GPIO or an interrupt line.

I/O 0-7(15)连接到数据总线D0-D7(D15)。/WP引脚可用于写保护或连接到VCC以无条件使能写入。由于NAND闪存使用命令驱动的编程和擦除,因此不太可能发生意外写入或擦除。就绪/忙碌输出不是操作所必需的,但它可以连接到GPIO或中断线路。

Filesystems supporting NAND

支持NAND的文件系统

One major problem for using NAND Flash is, that you cannot write as often as you want to a page. The consecutive writes to a page, before erasing it again, are restricted to 1-3 writes, depending on the manufacturers specifications. This applies similar to the spare area. This makes it necessary for the filesystem to handle a writebuffer, which contains data, that is less than a page

使用NAND Flash最主要的一个问题就是,你不可以太频繁的写一个页。在再次擦除页面之前,对该页面的连续写入被限制为1-3次写入,具体取决于制造商的规格。这与备用区类似。这使得文件系统有必要处理一个写缓冲区,该缓冲区包含小于一页的数据

At the moment there are only a few filesystems which support NAND:

目前只有一部分文件系统支持NAND:

  • JFFS2 and YAFFS for bare NAND Flash and SmartMediaCards
    适用于裸NAND闪存和SmartMediaCard的JFFS2和YAFFS
  • NTFL for DiskOnChip devices
    适用于DiskOnChip 设备的NTFL
  • TRUEFFS from M-Systems for DiskOnChip devices
    M-Systems为DiskOnChip设备提供的TRUEFFS
  • SmartMedia DOS-FAT as defined by the SSFDC Forum
    由SSFDC论坛定义的SmartMedia DOS-FAT
  • UBIFS for bare NAND flash
    适用于裸NAND flash的UBIFS

JFFS2, NTFL, and UBIFS are Open Source, while TRUEFFS is a proprietary solution. SmartMedia DOS-Fat is a specification from SSFDC forum. It is somewhat open under a non disclosure agreement with Toshiba, who owns all rights on this specifications. NTFL is designed for the usage of DiskOnChip devices. JFFS2 supports raw NAND chips and SmartMediaCards at the moment. A JFFS2 support for DiskOnChip devices, based on the NAND code, is planned. There are some other Open Source projects for NAND filesystem support, but there's no other working solution than JFFS, YAFFS, and UBIFS at the moment of this writing. YAFFS is available from YAFFS-Homepage. YAFFS is faster than JFFS2 and consumes less RAM, JFFS2 provides on the fly file compression and decompression, which is very helpful for small FLASHs. UBIFS provides compression similar to JFFS2, but is usually a better choice for large NAND flash chips (see here for more information on UBIFS, including some notes about how it compares to JFFS2).

JFFS2,NTFL和UBIFS是开源的,TRUEFFS 则是一种专有解决方案。SmartMedia DOS-Fat是来自SSFDC论坛的规范。根据与东芝签订的保密协议,它在某种程度上是开放的,东芝拥有该规格的所有权利。NTFL是为DiskOnChip设备的使用而设计的。JFFS2目前支持原始NAND芯片和SmartMediaCard。基于NAND代码,计划为DiskOnChip设备提供JFFS2支持。还有其他一些开放源码项目支持NAND文件系统,但在撰写本文时,除了JFFS、YAFFS和UBIFS之外,还没有其他可用的解决方案。YAFFS可以从YAFFS-Homepage处下载(https://yaffs.net/。YAFFS的速度比JFFS2更快,而且消耗的RAM更少,JFFS2提供动态文件压缩和解压缩,这对小闪存非常有帮助。UBIFS提供类似于JFFS2的压缩,但对于大型NAND闪存芯片来说通常是更好的选择(有关UBIFS的更多信息,包括关于它与JFFS2的比较的一些说明,请参阅此处http://www.linux-mtd.infradead.org/doc/ubifs.html)。

There is currently no support for the wide spread SmartMedia DOS-FAT filesystem, mainly because it's not a reliable filesystem for industrial usage. It's ok for multimedia applications. The hardware support layer is designed to support an implementation of SmartMedia DOS-FAT. There are some efforts to implement it, but it's in an early stage. There are a couple of SmartMedia Card adaptors for USB, PCMCIA, FireWire ... with Linux drivers available, which support the SmartMedia DOS-FAT.

目前不支持广泛使用的SmartMedia DOS-FAT文件系统,主要是因为它不是工业使用的可靠文件系统。但对于多媒体应用来说是可以的。硬件支持层旨在支持SmartMedia DOS-FAT的实施。有一些努力来实施它,但它还处于早期阶段。有几个用于USB、PCMCIA、FireWire的SmartMedia卡适配器...。提供支持SmartMedia DOS-FAT的Linux驱动程序。

JFFS2, YAFFS, and UBIFS include bad block management, wear leveling, error correction and provide reliable filesystems for industrial use on top of NAND Flash.

JFFS2, YAFFS, 和 UBIFS 都支持坏块处理,磨损均衡,错误纠正,并在NAND flash之上为工业提供可靠的文件系统。

JFFS2 specific information

JFFS2特定信息

JFFS2 Out of Band usage

JFFS2OOB使用

JFFS2 uses the default autoplacement scheme. The only JFFS2 specific usage of the oob area is the storage of the cleanmarker

JFFS2使用默认的自动放置方案。OOB区域的唯一JFFS2特定用途是存储清洁标记。

Nand chips with 256 byte pagesize and 8 byte OOB size

具有256字节大小的页和8字节大小的OOB区的NAND芯片

OffsetContentComment
0x06Clean marker byte 0

This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x85. In the remaining pages this byte is reserved

该字节表示在JFFS2的控制下擦除了一个块。如果页被成功擦除,块的第一页的这个字节会被设置为0x85。剩余的页中该字节保留。

0x07Clean marker byte 1

This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x19. In the remaining pages this byte is reserved

该字节表示在JFFS2的控制下擦除了一个块。如果页被成功擦除,块的第一页的这个字节会被设置为0x19。剩余的页中该字节保留。

Nand chips with 512 byte pagesize and 16 byte OOB size

具有512字节大小的页和16字节大小的OOB区的NAND芯片

OffsetContentComment
0x08Clean marker byte 0This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x85. In the remaining pages this byte is reserved
0x09Clean marker byte 1This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x19. In the remaining pages this byte is reserved
0x0aClean marker byte 2This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x03. In the remaining pages this byte is reserved
0x0bClean marker byte 3This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x20. In the remaining pages this byte is reserved
0x0cClean marker byte 4This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x08. In the remaining pages this byte is reserved
0x0dClean marker byte 5This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x00. In the remaining pages this byte is reserved
0x0eClean marker byte 6This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x00. In the remaining pages this byte is reserved
0x0fClean marker byte 7This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x00. In the remaining pages this byte is reserved

Nand chips with 2048 byte pagesize and 64 byte OOB size

具有2048 字节大小的页和64字节大小的OOB区的NAND芯片

OffsetContentComment
0x10Clean marker byte 0This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x85. In the remaining pages this byte is reserved
0x11Clean marker byte 1This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x19. In the remaining pages this byte is reserved
0x12Clean marker byte 2This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x03. In the remaining pages this byte is reserved
0x13Clean marker byte 3This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x20. In the remaining pages this byte is reserved
0x14Clean marker byte 4This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x08. In the remaining pages this byte is reserved
0x15Clean marker byte 5This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x00. In the remaining pages this byte is reserved
0x16Clean marker byte 6This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x00. In the remaining pages this byte is reserved
0x17Clean marker byte 7This byte indicates that a block was erased under JFFS2 control. If the page was successfully erased this byte in the first page of a block is programmed to 0x00. In the remaining pages this byte is reserved

HOWTO implement NAND support

怎么设置支持NAND

Where can you get the code ?

从哪里获得源码?

NAND support is now present in the upstream kernel code, including JFFS2 and UBIFS. The latest code is also available from GIT and daily snapshots.

NAND支持现在出现在上游内核代码中,包括JFFS2和UBIFS。最新的代码也可以从git和Daily Snapshot获得。(http://www.linux-mtd.infradead.org/source.html

If using JFFS2, there are four layers of software:

如果使用JFFS2,软件有分四层:

  1. JFFS2: filesystem driver(JFFS2:文件系统驱动)
  2. MTD: Memory Technology Devices driver(MTD:存储技术设备驱动)
  3. NAND: generic NAND driver(NAND:通用NAND驱动程序)
  4. Hardware specific driver(特定硬件的驱动程序)

The MTD driver just provides a mount point for JFFS2. The generic NAND driver provides all functions, which are necessary to identify, read, write and erase NAND Flash. The hardware dependent functions are provided by the hardware driver. They provide mainly the hardware access information and functions for the generic NAND driver. The same applies for YAFFS.

MTD驱动程序只为JFFS2提供一个挂载点。通用NAND驱动程序提供识别、读取、写入和擦除NAND闪存所需的所有功能。硬件相关功能由硬件驱动程序提供。它们主要为通用NAND驱动程序提供硬件访问信息和功能。同样的道理也适用于YAFFS。

API Documentation

API 文档

A complete API documentation is available as DocBook template in the Documentation/DocBook directory of the MTD source tree.

在MTD源代码树的Documentation/DocBook目录中,可以以DocBook模板的形式获得完整的API文档。

Read the API documentation online

在线阅读API文档(http://www.linux-mtd.infradead.org/tech/mtdnand/index.html

Supported chips

支持的芯片

Most NAND chips actually available should be supported by the current code. If you have a chip, which is not supported, you can easily add it by extending the chiplist in drivers/mtd/nand/nand_ids.c. The chip name does not longer contain cryptic part numbers, as the device ID is just an information about size, erase block size, pagesize and operating voltage. Add an entry, which contains following information:
{ name, id, pagesize, chipsize, erasesize, options }

目前的代码应该支持大多数实际可用的NAND芯片。如果您有一个不受支持的芯片,您可以通过扩展Drivers/MTD/NAND/NAND_ids.c中的芯片列表轻松地添加它。芯片名称不再包含隐含的零件号,因为设备ID只是有关大小、擦除块大小、页面大小和工作电压的信息。添加一个条目,其中包含以下信息:

{ name, id, pagesize, chipsize, erasesize, options }

refcomment
namestring: "NAND 'size' 'voltage' 'bus-width'"
idchip device code. This code is read during nand_scan. Check datasheet for the code of your chip
pagesizePage size (0,256,512). 0 indicates that the pagesize can be read out from the chip in the extended ID
chipsizeThe total size of the chip in MiB
erasesizethe erasesize of your chip in bytes. 0 for chips with extended ID
optionsOptions. Bitfield to enable chip specific options. See nand.h

Please contact NAND driver maintainer to include it in the public source tree.

请联系NAND驱动程序维护人员,将其包含在公共源码树中。

Manufacturer codes are scanned during nand_scan too. If the code is one of the known codes in the manufacturer ID table, the name of the manufacturer is printed out, else "Unknown" is printed. This happens when your hardware driver is loaded and calls nand_scan. Add codes, which are new and contact NAND driver maintainer to include it

制造商代码也会在NAND_SCAN期间扫描。如果该代码是制造商ID表中的已知代码之一,则打印制造商的名称,否则打印“UNKNOWN”。这在加载硬件驱动程序并调用NAND_SCAN时发生。添加新代码,并联系NAND驱动程序维护人员将其包括在内。

Config settings

配置设置

The following config switches have to be set. JFFS2 on NAND does not work, if one of these settings is missing.

必须设置以下配置开关。如果缺少其中一个设置,NAND上的JFFS2将不起作用。

CONFIG_MTD=y
CONFIG_MTD_CHAR=y
CONFIG_MTD_BLOCK=y
CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_YOURBOARD=y
CONFIG_JFFS2_FS=y
CONFIG_JFFS2_FS_DEBUG=0
CONFIG_JFFS2_FS_NAND=y

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值