How to Find NAND Parameters

Using the Datasheet

If you are writing a driver or do not have a working Linux kernel for the board, then you should use the datasheet to find the parameters for your NAND flash. This section describes where to find the relevant information for building JFFS2 or UBI images using the datasheet for your device.

Flash Vendor

The flash vendor is typically on the chip, although it can be difficult to discern at times.

  • Samsung - "SAMSUNG" written on the chip itself.
  • Micron - "M" with an oval surrounding it
  • ST Micro - "ST" logo (Black letters, white background)
  • Numonyx - Stylized "N"

Flash Model

Like the vendor, it is easiest to look at the board's BOM. It is also typically on the chip, although it may include additional numbers and letters that indicate a particular subset of the model, making it somewhat difficult to find the datasheet.

Size or Density

The datasheet for the given part is the best place to find the size of the NAND flash chip. It is typically called the chip's density, and will be expressed in either MibiBytes (1*2^20 bytes), or even as MBits (MiB * 8). We are unaware of any manufacturer that expresses them in powers of 10 (like hard drive manufacturers).

Some datasheets may correspond to multiple densities of the same family of devices. In those cases, there is typically a section of the datasheet that will explain how to read the model number to determine the density of the chip.

The density, as well as other size parameters, are typically expressed in terms of the size of the data and the out-of-band (OOB) region that accompany each page. The OOB size can be ignored when passing parameters to JFFS2 or UBI.

Physical Erase Block Size

The physical erase block size (or PEB) is the size of each erasable block of NAND. This value can be found in the datasheet under the feature summary section. It will be expressed in bytes or words.

Logical Erase Block Size

The logical erase block size (LEB) is an UBIFS-only term, and is not entirely straightforward to figure out. UBIFS prepends a header to every block of a certain size, and aligns it with the page. It is related to physical eraseblock size, minimum input/output unit size, and sub-page size. The easiest way to find it is to attach the device to UBI and see the output, as described below.

Some typical values:

  • NAND flash with 512 byte NAND page and 256 byte sub-page: LEB size is PEB size minus 512;
  • NAND flash with 2048 byte NAND page and 512 byte sub-page: LEB size is PEB size minus 2048;
  • NAND flash with 2048 byte NAND page and no sub-page: LEB size is PEB size minus 4096.

See: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_find_lebsz

Page Size or Minimum I/O Size

Each device is divided into some number of pages. The page is the minimum block of data that can be read or programmed at a time. This corresponds to the minimum I/O size of the UBI subsystem.

This information can be found in the device's datasheet as well. It will generally be found in the feature summary section at the beginning of the document, and will typically be called "Page Size". It is expressed in either Bytes or Words, depending on the bus width. Both JFFS2 and UBI want this value in terms of bytes.

This value is typically 512 bytes for low density chips (~64 MB), 2048 bytes for medium density, and 4096 bytes for very high density chips. You should always consult the datasheet for the exact value.

Sometimes sub paging is available on the flash hardware, but the driver software doesn't support subpaging. The error "bad VID header offset 512, expected 2048" is thrown when the driver can not find the VID header on boot: Subpaging can be disabled by setting subpage size equal to page size. Then the VID and EC headers will each be allocated their own page for each erase block.

Sub-page Size or Number of Partial Program Cycles

Sub-page size is a purely UBI construct, but it is related to a physical aspect of the device.

From linux-mtd:

Sub-page size is relevant only for some NAND flashes which allow several (usually 2 or 4) writes to the same NAND page. For example, many SLC NAND flashes have this. UBI utilizes this feature if it is available to waste less flash space. Typically, sub-page size is 256 in case of 512 bytes NAND page and 512 in case of 2048 bytes NAND pages. MLC NAND flashes typically have no sub-pages. SLC OneNAND chips with 2048 bytes NAND page size support 512 byte sub-pages.

Sub-page size can be derived by dividing Page Size by Number of Partial Program Cycles, or Nop. However, the sub-page support in the mtd subsystem isn't well tested, and it's much safer to use ubiattach or dmesg to find the value. See the section Using UBI below.

NOTE: Some Samsung datasheets give two values for Nop, one for the main array and one for the spare. Use the value for the Main array. The spare array refers to the OOB area, which is not used by JFFS2 or UBI.

Bus Width

Bus width describes the number of data lines used to connect the flash chip to the NAND controller, which is usually part of the SOC.

The chip's bus width can be found in the datasheet. Like density, a single datasheet may be used for chips of varying bus-widths, so you may need to find the section that describes how to decode the model number in order to determine the value. It is going to be either 8 or 16 bits.

You can also tell the bus width by looking at the schematic, although this is prone to error.

Using UBI

When a device is attached to UBI, the kernel will print a summary of the parameters of the chip. It can be found using either dmesg or ubiattach.

NOTE: You should use ubiformat to format the partition before doing this.

# ubiattach /dev/ubi_ctrl -m 0                                                  
UBI: attaching mtd0 to ubi1                                                     
UBI: physical eraseblock size:   131072 bytes (128 KiB)                         
UBI: logical eraseblock size:    129024 bytes                                   
UBI: smallest flash I/O unit:    2048                                           
UBI: sub-page size:              512                                            
UBI: VID header offset:          512 (aligned 512)                              
UBI: data offset:                2048                                           
UBI error: ubi_read_volume_table: the layout volume was not found               
ubiattach: error!: cannot attach mtd0                                           
           error 22 (Invalid argument)

The -m flag refers to the mtd partition, so the above example is the geometry of /dev/mtd0.

Using the Kernel

The kernel messages will provide some information about the NAND device. You can execute the dmesg command to see the results of the NAND driver's initialization:

NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
AT91 NAND: 8-bit, Software ECC
Scanning device for bad blocks
Bad eraseblock 1020 at 0x07f80000
Bad eraseblock 1280 at 0x0a000000
Creating 2 MTD partitions on "atmel_nand":
0x00000000-0x00040000 : "Partition 1"                                           
0x00040000-0x10000000 : "Partition 2" 

Based on this, you can determine the partition scheme of the device, bad eraseblocks, bus width, and vendor.

The proc subsystem in the Linux kernel will give you some information about the NAND flash, but typically not enough to get everything up and running.

The file /proc/mtd contains the basic information about all MTDs on your board:

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "Partition 1" 
mtd1: 0ffc0000 00020000 "Partition 2" 

Size corresponds to the density (in bytes), and erasesize corresponds to the Physical Erase Block size (in Bytes).

Common NAND Parameters

Board Flash Vendor Flash Model Size Physical Erase Block Size Logical Erase Block Size 1 Page Size (Min I/O Size) Sub-page size 1 Bus width (Bits) Datasheet Notes
AM3517 EVM Micron MT29F4G16ABCHC 512 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 16 MT29F4G16ABCHC -
AMCC 440EPx Samsung K9F5608U0B-PCB0 32 MiB 16384 Bytes (16 KiB) 15872 Bytes 512 Bytes 256 Bytes 8 K9F5608U0B.pdf -
at91sam9260-ek Samsung K9F2G08U0M-PCB0 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 Contact Vendor -
at91sam9261-ek (Rev C) Micron MT29F2G16AABWP 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 16 MT29F2G08AABWP This part is obsolete
at91sam9261-ek (Rev D) Samsung K9F2G08U0A-PCB0 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 Contact Vendor -
at91sam9263-ek Micron MT29F2G08AAC 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 MT29F2G08AACWP -
at91sam9rl-ek Micron MT29F2G08AAC 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 MT29F2G08AACWP -
at91cap9a-dk Micron MT29F2G08AAC 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 MT29F2G08AACWP -
at91sam9g10-ek Micron MT29F2G08AAC 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 MT29F2G08AACWP -
at91sam9g20-ek Samsung K9F2G08U0A-PCB0 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 Contact Vendor -
at91sam9g45-ek Micron MT29F2G08AAC 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 MT29F2G08AACWP -
ConnectCore Wi-MX51 Samsung K9F4G08U0B-PIB0 512 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 Contact Vendor -
DVEVM6446 Samsung K9F1208FR0B 64 MiB 16384 Bytes (16 KiB) 15360 Bytes 512 Bytes 512 Bytes 8 Contact Vendor -
i.MX27 LiteKit ST MICRO / Numonyx NAND512W3A2BN6E 64 MiB 16384 Bytes (16 KiB) 15360 Bytes 512 Bytes 512 Bytes 8 NAND512W3A2BN6E -
i.MX31 LiteKit ST MICRO / Numonyx NAND512W3A2CN6E 64 MiB 16384 Bytes (16 KiB) 15360 Bytes 512 Bytes 512 Bytes 8 NAND512W3A2CN6E -
i.MX25 PDK Samsung K9LAG08U0M-PCB0 2 GiB 262144 Bytes (256 KiB) 258048 Bytes 2048 Bytes 2048 Bytes 8 Contact Vendor -
i.MX27 ADS Samsung K9K1G08U0B-J1B0 128 MiB 16384 Bytes (16 KiB) 15360 Bytes 512 Bytes 512 Bytes 8 Contact Vendor -
i.MX31 ADS Samsung K9K1G08U0B-J1B0 128 MiB 16384 Bytes (16 KiB) 15360 Bytes 512 Bytes 512 Bytes 8 Contact Vendor -
i.MX31 PDK Samsung K9F2G08R0A-JIB0 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 Contact Vendor -
KIXRP435 Samsung K9F1208U0B-PCB0 64 MiB 16384 Bytes (16 KiB) 15872 Bytes 512 Bytes 256 Bytes 8 Contact Vendor -
MPC5121ADS HYNIX HY27US08121A-TPCB 2 x 512 MiB 131072 Bytes (128 KiB) 129024 Bytes 512 Bytes 512 Bytes 8 HY27US08121A-TPCB -
MPC8313E-RDB Samsung K9F5608U0D-PCB0 32 MiB 16384 Bytes (16 KiB) 15360 Bytes 512 Bytes 512 Bytes 8 Contact Vendor -
MPC8572DS Samsung K9F5608U0D-PCB0 4 x 1024 MiB 131072 Bytes (128 KiB) 129024 Bytes 512 Bytes 512 Bytes 8 Contact Vendor -
MPC8313E-RDB Samsung K9F5608U0D-PCB0 32 MiB 16384 Bytes (16 KiB) 15360 Bytes 512 Bytes 512 Bytes 8 Contact Vendor -
OMAP 3530 Zoom Micron MT29C2G24MAKLAJG-6 IT 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 16 MT29C2G24MAKLAJG-6 IT -
OMAP 3530 Torpedo Hynix H8KCS0SJ0AER-46M 256 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 16 Contact Vendor -
OMAPL138 EVM Micron MT29F4G08AACWC 512 MiB 131072 Bytes (128 KiB) 129024 Bytes 2048 Bytes 512 Bytes 8 MT29F4G08AACWC -
P1020-RDB Samsung K9F5608U0B-PCB0 32 MiB 16384 Bytes (16 KiB) 15872 Bytes 512 Bytes 256 Bytes 8 K9F5608U0B.pdf -
Numonyx NAND128W3A2BN6E 16 MiB 16384 Bytes (16 KiB) 15360 Bytes 512 Bytes 512 Bytes 8 NAND128W3A2BN6E -

1 This value corresponds to using Software ECC on these chips. It will be different when using Hardware ECC.