NAND Bad block Management

Source: Internet
Author: User
how NAND is managed

NAND Flash Management: Samsung Flash For example, a piece of NAND flash for a device, 1 (device) = xxxx (Blocks), 1 (Block) = xxxx (Pages), 1 (P Age) =528 (Bytes) = block Size (512Bytes) + OOB block Size (16Bytes, in addition to OOB sixth Byte, usually holds at least the first 3 bytes of the OOB NAND Flash hardware ECC code).

About the OOB area, it's every page. Page size is 512 bytes of NAND per page allocated 16 bytes of OOB, and if NAND is physically 2K page, each page is assigned an OOB of 64 bytes. The following figure:

In the case of Hynix, the figure in black is the actual detected NAND, which is a 2G bit (256M) of NAND. Pgsize is 2K bytes, pgspblk indicates that each block contains 64 pages, then each block occupies a byte count of 64x2k=128k bytes, the NAND pack 2048 blocks, then you can calculate the number of bytes that NAND occupies is 2048x128k= 256M, in accordance with the actual. It is important to note that the sprsize is the OOB size and is exactly 64 bytes used by 2K pages.

1. Why is there a bad block
Because the NAND flash process does not guarantee that the NAND memory array remains reliable in its lifetime, it produces bad blocks during NAND production and during use. The property of the bad block is that when the block is programmed/erased, it causes the error of the page program and block erase operation, corresponding to the corresponding bit of the status register.

2. Classification of bad blocks
In general, the bad block can be divided into two major categories: (1) The inherent bad block: This is the production process of the bad block, the general chip factory will be in the first page of each bad block spare area of the 6th byte marked as not equal to 0xFF value. (2) Use bad block: This is in the use of NAND flash, if block erase or page program error, you can simply use this block as a bad block to deal with, this time need to mark up the bad block. In order to be consistent with the inherent bad block information, the 6th byte of the spare area of the first page of the newly discovered bad block is marked as a value other than 0xFF.

3. Bad block Management
According to these narratives, it is possible to understand that NAND flash has already reflected bad block information in the spare area, so if you have to check the first page of spare area 6th byte 0xFF before erasing a block, If it proves that this is a good block, it can be erased, and if it is non-0xff, then it cannot be erased, so as not to erase the bad block mark. Of course, such processing may make a mistake--"false kill pseudo-bad block", because during the operation of the chip may be due to voltage instability and other accidental factors will cause the NAND operation error. However, for the reliability of data and simplification of software design, it is still necessary to comply with this standard.

It can be managed with the Bbt:bad block table, which is the bad chunk. There are differences in how bad blocks are managed for NAND. For example, the special use of NAND storage, will put BBT to Block0, because the NO. 0 block must be a good block. However, if the NAND itself is used to boot, then the NO. 0 block will be stored in the program, can not be put BBT. Some put BBT to the last piece, of course, this piece resolutely cannot be bad block. The size of the BBT is related to the size of the NAND, the larger the NAND, the greater the BBT needed.

It is important to note that OOB is the data for each page, which has ECC (not only), but BBT is a flash; the bad block identification for each block is the sixth byte of the first page spare area of the block.
4. Bad block correction

Ecc:nand Flash error usually does not cause the entire block or page can not read or all errors, but the entire page (such as 512Bytes) only one or a few bit error. A more specialized check--ECC is generally used. ECC can correct single-bit errors and detect double-bit errors, and the calculation is fast, but for more than 1 bits of error can not be corrected, more than 2 bits of error is not guaranteed to detect.
ECC typically generates 3 bytes of ECC checksum data per 256 bytes of raw data, which consists of 24 bits divided into two parts: a 6-bit column check and a 16-bit row check, and an extra two bit 1. (512 creating two sets of ECC, 6 bytes total)
When writing data to the page of NAND flash, we generate an ECC checksum per 256 bytes, called the original ECC checksum, saved to pageOOB(out-of-band) Data area. Its location is eccpos[]. Verification, according to the above ECC generation principle is not difficult to infer: will read from the OOB area of the original ECC checksum new ECC checksum and the bitwise XOR, if the result is 0, it means that there is no error (or the ECC can not detect errors), if 3 bytes xor The result of 11 bits is 1, Indicates that there is a bit error and can be corrected; if there are only 1 bits of 1 in the 3 byte XOR result, there is an error in the OOB area, and all other cases indicate uncorrectable errors.
5. Supplement
(1) You need to make a special note of the bad blocks that were found by page program errors. If an error occurs while programming a page of a block, mark the block as a bad block, and first copy the contents of the other good polygons in the block into another empty block, and then mark the block as a bad block. Of course, this may make a "wrong kill" mistake, a remedy, is after the block backup, and then erase the bad block again, if the block erase error, it proves that this chunk is a real bad block, then do not hesitate to hit it a "poke" it.
(2) One might ask why you should use the sixth byte of the spare area on the first page of each block as a bad block marker. This is the default convention for NAND flash manufacturers, and you can see that samsung,toshiba,stmicroelectronics is using this byte as the bad block tag.

(3) For what good block with 0xFF to mark. Because the NAND flash erase is to change the bits of the corresponding block to 1, the write operation can only change the chip each bit (bit) from 1 to 0, and not from 0 to 1. 0XFF This value is the identity erase success, is a good block.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.