SLC1 NAND flash driver

The driver is designed to support one or multiple SLC (Single-Level Cell) NAND flashes which require 1-bit ECC. It can also be used to access ATMEL's DataFlash chips. To use it in your system, you will have to provide basic I/O functions for accessing your flash device.

Performance and resource usage

The emFile NAND driver has been carefully designed to make effective use of RAM. The amount of RAM required by the driver depends on the runtime configuration and the connected device. In a typical embedded system which uses a 2 GBit NAND flash, the driver requires less than 6 KBytes of RAM.

The NAND Flash has a very high read and write performance. For example, on an ARM7 running at 48 MHz, the driver reaches a transfer speed of 3.8 MBytes/sec for writing and 5.9 MBytes/sec for reading. This makes the driver to one of the fastest implementations on the market!

Supported hardware

Tested and compatible NAND flashes

In general, the driver supports almost all Single-Level Cell NAND flashes (SLC). This includes NAND flashes with page sizes of 512+16 and 2048+64 bytes.
The table below shows the NAND flashes that have been tested or are compatible with a tested device:

Manufacturer Device Page size [Bytes] Size [Bits]
Hynix HY27xS08281A
HY27xS08561M
HY27xS08121M
HY27xA081G1M
512+16
512+16
512+16
512+16
16Mx8
32Mx8
64Mx8
128Mx8
Samsung K9F6408Q0xx
K9F6408U0xx
K9F2808Q0xx
K9F2808U0xx
K9F5608Q0xx
K9F5608D0xx
K9F5608U0xx
K9F1208Q0xx
K9F1208D0xx
K9F1208U0xx
K9F1208R0xx
K9K1G08R0B
K9K1G08B0B
K9K1G08U0B
K9K1G08U0M
K9T1GJ8U0M
512+16
512+16
512+16
512+16
512+16
512+16
512+16
512+16
512+16
512+16
512+16
512+16
512+16
512+16
512+16
512+16
8Mx8
8Mx8
16Mx8
16Mx8
32Mx8
32Mx8
32Mx8
64Mx8
64Mx8
64Mx8
64Mx8
128Mx8
128Mx8
128Mx8
128Mx8
128Mx8
ST-Microelectronics NAND128R3A
NAND128W3A
NAND256R3A
NAND256W3A
NAND512R3A
NAND512W3A
NAND01GR3A
NAND01GW3A
512+16
512+16
512+16
512+16
512+16
512+16
512+16
512+16
16Mx8
16Mx8
32Mx8
32Mx8
64Mx8
64Mx8
128Mx8
128Mx8
Toshiba TC5816BFT
TC58V32AFT
TC58V64BFTx
TC58256AFT
TC582562AXB
TC58512FTx
TH58100FT
512+16
512+16
512+16
512+16
512+16
512+16
512+16
2Mx8
4Mx8
8Mx8
32Mx8
32Mx8
64Mx8
256Mx8
Hynix HY27UF082G2M
HY27UF084G2M
HY27UG084G2M
HY27UG084GDM
2048+64
2048+64
2048+64
2048+64
256Mx8
512Mx8
512Mx8
512Mx8
Micron MT29F2G08AAB 
MT29F2G08ABD
MT29F4G08AAA
MT29F4G08BAB 
MT29F2G16AAD
2048+64
2048+64
2048+64
2048+64
2048+64
256Mx8
256Mx8
512Mx8
512Mx8
128Mx16
Samsung K9F1G08x0A
K9F2G08U0M
K9K2G08R0A
K9K2G08U0M
K9F4G08U0M
K9F8G08U0M

2048+64
2048+64
2048+64
2048+64
2048+64
2048+64
256Mx8
256Mx8
256Mx8
256Mx8
512Mx8
1024Mx8
ST-Microelectronics NAND01GR3B
NAND01GW3B
NAND02GR3B
NAND02GW3B
NAND04GW3
2048+64
2048+64
2048+64
2048+64
2048+64
128Mx8
128Mx8
256Mx8
256Mx8
512Mx8

Support for devices not in this list
Most other NAND flash devices are compatible with one of the supported devices. Thus the driver can be used with these devices or may only need a little modification, which can be easily done. Get in touch with us, if you have questions about support for devices not in this list.

 

Tested and compatible DataFlash chips

The NAND flash driver fully supports the ATMEL /DataFlash Cards series up to 32MBit. Currently the following devices are supported:

Manufacturer Device
ATMEL AT45BR3214B
AT45DB011B
AT45DB021B
AT45DB041B
AT45DB081B
AT45DB161B
AT45DB321C
AT45DB642
AT45DCB002
AT45DCB004

Theory of operation

NAND flash devices are divided into physical blocks and physical pages. One physical block is the smallest erasable unit; one physical page is the smallest writable unit. Small block NAND flashes contain of multiple pages. One block contain typically 16 / 32 / 64 pages per block. Every page has a size of 528 bytes (512 data bytes + 16 spare bytes). Large block NAND Flash devices contain blocks made up of 64 pages, each page containing 2112 bytes (2048 data bytes + 64 spare bytes). The driver uses the spare bytes for the following reasons:

  1. To check if the data Status byte and block status are valid. If they are valid the driver uses this sector. When the driver detects a bad sector, the whole block is marked as invalid and its content is copied to a non-defective block.
  2. To store/read an ECC (Error Correction Code) for data reliability. When reading a sector, the driver also reads the ECC stored in the spare area of the sector, calculates the ECC based on the read data and compares the ECCs. If the ECCs are not identical, the driver tries to recover the data, based on the read ECC. When writing to a page the ECC is calculated based on the data the driver has to write to the page. The calculated ECC is then stored in the spare area.

Error correction code (ECC)

The emFile NAND driver is highly speed optimized and offers a better error detection and correction than a standard memory controller ECC. The ECC is capable of single bit error correction and 2-bit random detection. When a block for which the ECC is computed has 2 or more bit errors, the data cannot be corrected. Standard memory controllers compute an ECC for the complete blocksize (512 / 2048 bytes). The emFile NAND driver computes the ECC for data chunks of 256 bytes (e.g. a page with 2048 bytes is divided into 8 parts of 256 bytes), so the probability to detect and also correct data errors is much higher. This enhancement is realized with a very good performance. The ECC computation of the emFile NAND driver is highly optimized, so that a performance of 18 Mbytes/second can be achieved with a ARM SAM7 running at 48 MHz.

We suggest the use of the the emFile NAND driver without the usage of a memory controller, because the performance of the driver is very high and the error correction is much better if it is controlled from driver side.

Software structure

The NAND Flash driver is split up into different layers, which are shown in the illustration below.

It is possible to use the NAND driver with custom hardware. If port pins or simple memory controller are used to access the flash memory, only the hardware layer needs to be ported, normally no changes to the physical layer are required. If the NAND driver should be used with special memory controller (e.g. special FPGA implementations), the physical layer needs to be adapted. In this case, the hardware layer is not required, because the memory controller manages the hardware access.

Fail-safe operation

The emFile NAND driver is fail-safe. That means that the driver makes only atomic actions and takes the responsibility that the data managed by the file system is always valid. In case of a power loss or a power reset during a write operation, it is always assured that only valid data is stored in the flash. If the power loss interrupts the write operation, the old data will be kept and the block not corrupted.

Wear leveling

Wear leveling is supported by the driver. Wear leveling makes sure that the number of erase cycles remains approximately equal for each sector. Maximum erase count difference is set to 5. This value specifies a maximum difference of erase counts for different physical sectors before the wear leveling uses the sector with the lowest erase count.