NAND

 

Introduction

NAND flash is a non-volatile, solid state storage technology. Non-volatile means that it retains the information written to it after a device has been powered off. Solid state means that there are no mechanical or moving parts, giving it a high resistance to shocks, pressure and temperature. NAND flash is one of the most common methods of providing large amounts of permanent storage space for embedded devices.

180px-Nand-flash

A USB memory stick using NAND flash

NAND flash is organised into pages typically 512 to 2048 bytes in size. These pages are further organised into blocks. Typical block sizes are 32 to 64 pages. While reads and writes can be performed on a page basis, it is only possible to erase whole blocks at a time. In order to write new values to a page, the entire block must first be erased, and then the new data written. NAND flash blocks have a limited number of erase/write cycles for which blocks a guaranteed for, typically around 10,000 to 1,000,000 cycles are guaranteed. NAND flash file systems, such as YAFFS and JFFS, are designed to minimise the number of erases and writes to prolong the lifetime of the blocks. Each block on a NAND flash devices contains some extra bytes called the out-of-band (OOB) data. This information can be used to store data such as the following:

  • Block status - Good or bad.
  • Error correct codes (ECC).
  • File system information.

NAND flash comes in two main variants: Single-Level Cell (SLC) and Multi-Level Cell (MLC). SLC NAND is more expensive and has lower storage density, but has a faster write speed and much larger number of erase cycles than MLC NAND. SLC NAND has a lifetime of around 100,000 erase/write cycles, whereas MLC NAND typically has around 10,000.

NAND Flash is used anywhere where solid state storage is important, such as in cellphones, portable music players, USB memory disks, SD cards and many other embedded devices which require non-volatile storage.

Advantages

  • Cheap. 1GB NAND flash chips typically sell for under $10 US.
  • Small. A 4GB SD card measures only 32 by 24 by 2.1 mm.
  • Highly resistant to shocks, pressure and temperature.

Disadvantages

  • Limited number of write cycles means that special file systems are required to prolong the lifetime.
  • Smaller capacity than a hard drive. NAND flash would not yet make an ideal replacement for a laptop hard drive for example, although some manufacturers are now starting to go down this route. http://www.samsung.com/eu/Products/Semiconductor/products/ssd.asp

NAND vs NOR flash

The major difference between NOR and NAND flash is that NOR flash allows random access reads, whereas NAND flash is only supports block access. This means that NOR flash does not need to be shadowed in RAM to allow it to be executed from. For this reason NOR flash is often used for providing rewritable bootable storage on embedded devices. NAND flash has far superior write and erase times making it a much better solution than NOR flash for secondary storage.

The following is a quick comparison of NOR and NAND flash:

  • NOR flash has a slightly higher read speed than NAND flash.
  • NAND flash has a much higher write speed than NOR flash.
  • NAND flash has a much higher erase speed than NOR flash. NOR flash can take several seconds to erase, whereas NAND flash has an erase time of only a few milliseconds.
  • NOR flash allows random access byte reading, NAND flash only supports block access.
  • NAND flash typically has a larger number of write/erase cycles than NOR flash.
  • NOR flash supports execute in place (XIP). NAND flash must first be shadowed in RAM before being executable.

File systems

Because NAND flash has a limited number of erase/write cycles, using a standard file system, such as ext3 or NTFS, can cause some blocks to deteriorate quickly. A number of specialised flash file systems have been designed to support solid state storage. Most of these file systems use a technique called "wear levelling" (see: http://en.wikipedia.org/wiki/Wear_levelling), which prolongs the life of the blocks of a flash device by distributing the erase/write operations evenly across the blocks. File systems designed for use on standard hard drives often erase/write to some blocks, such as the block containing the root directory, far more often than other blocks. Some of these are described below:

YAFFS

YAFFS, Yet Another Flash File System (http://www.yaffs.net/), is a file system designed for use on NAND flash. It has wear-leveling, a small RAM footprint, quick boot time, and error correction handling. The newer YAFFS2 file system is able to address blocks of sizes greater than 512 bytes, and can be used for multi-gigabyte flash file systems. YAFFS can be used with Linux, Windows CE and some real-time operating systems. Although YAFFS is not part of the mainline Linux kernel, it is trivial to add. Bluewater Systems use YAFFS as our predominant flash file system. Our Linux kernel includes full support for YAFFS2.

JFFS

JFFS, the Journalling Flash File System (http://sourceware.org/jffs2/), is a file system originally designed for NOR flash, and then expanded to allow for the use of NAND flash. It uses a log-based design and supports wear levelling. Three compression algorithms are directly supported: zlib, rubin and rtime. JFFS2 is included in the mainline Linux kernel and is also available for the real-time embedded operating system eCos. The main disadvantages of JFFS are slow mount times, especially on larger flash devices and difficulties in reporting the amount of available space on a device due to the way in which the compression works.

LogFS

LogFS (http://www.logfs.org/logfs/) is a relatively new flash file system designed to replaced JFFS2 in the Linux kernel. It aims to improve the mount times and memory consumption of JFFS2. LogFS is a log-based, journalling file system, with wear levelling support. It has been designed with scalability in mind. LogFS is still in development, and is not yet recommended for storing critical data. The author of LogFS has recently submitted patches for inclusion in the mainline Linux kernel.

Bluewater Systems Experience

Bluewater Systems has used NAND flash in numerous projects requiring solid state storage, including:

  • The DDS XM-100 digital storage unit uses stackable NAND flash modules. Each module supports up to 16GB of NAND flash and can be addressed using an 8, 16 or 32 bit bus. The NAND stack on the DDS XM-100 is controlled by the FPGA on the Snapper 255. The stackable NAND flash modules have been designed to be easily reused on future embedded designs.

Pipi-flash

NAND Flash on Snapper/Rig 200

The Snapper modules have an xD card socket which supports NAND flash based xD cards of up to 512Mb. This typically provides enough solid state storage space for an operating system, root file system and any custom application software need for an embedded system. For embedded systems with larger solid state storage requirements the xD card can be replaced with a larger NAND flash chip, or additional NAND flash can be placed on the Snapper carrier board. Rig 200 provides SD and compact flash sockets which allow for additional NAND flash storage space to be added.

 

rs1

rs_2

rs_3

rs_4