Through the above section, for NAND flash, each page, corresponding to an idle area (OOB), this region is based on the hardware characteristics of NAND flash, the data is error-prone when reading and writing, in order to ensure the correctness of the data, it produced such a detection and error correction area, used to place the data checksum. OOB Read and write operations, generally with the operation of the page to complete, that is, in the read and write pages, the corresponding OOB is generated, then what is the use of OOB?
1). Mark if there is a bad block
2). Store ECC Checksum
3). Store some file system-related information, for the RAMFS/JFFS2 file system image file does not have OOB content, you need to base the OOB tag over the bad block, then write a page of data, and then calculate the page data ECC checksum, and then write it to the OOB area For the yaffs file system, because it contains data for the OOB area (it has a bad block tag, ECC check code, and other information), it first needs to check the bad block, if it is, then skips, writes the data, and writes the OOB data at last.
1. ECC Calibration
ECC (Error Checking and Correction) is an algorithm for error detection and correction of NAND flash. Due to the timing of the operation and the stability of the circuit and other reasons, there are often some bit error, that is, the original bit, originally 0 and became 1, or originally 1 and became 0. From the point of view, the problem does not seem particularly serious, but if it happens that one of the important files has changed, then the problem is large, it may cause the file can not be run at this time, if the file is a program that affects the system, then directly will cause problems in the system, so for NAND There is a mechanism for flash. It corrects 1 bit errors and detects 2 bit errors, cannot be corrected for errors above 1bit, and is not guaranteed to detect errors above 2bit. What is the error correction algorithm for ECC?
1) When writing data to NAND flash, an ECC checksum is generated per 256 bytes, which generates an ECC checksum to the corresponding page's OOB data area.
2) When reading NAND flash data, every 256 bytes will generate an ECC checksum, then for this data will calculate a ECC checksum, and then read from the OOB stored ECC checksum computed ECC checksum to compare,
2. Bad block handling
For NAND Flash, the more serious is the bad block, that is, one block contains one or more bits is bad, and now there are two categories of bad blocks
1) When the factory has a bad block: Before the factory, will do the corresponding mark, marked as a bad block, the general chip manufacturers will each bad block the first page of the spare Erea of the 6th byte marked as not equal to 0xFF.
2) using the bad block generated in the process, you need to treat this block as a bad block, in order to be consistent with the inherent bad block information, you also need to be the first page of the newly discovered bad block spare Eare of the 6th byte marked as a non-0xff value.
For the above processing, if we need to erase a block, we must first check the first page of the spare Eare 6byte is 0xFF, if it is proved to be a good block, can be erased; if not, prove that this is a bad block, then cannot erase, for this method , there will inevitably be some error operations, so NAND Flash specifically designed a BBT (bad block table) for the management. Each NAND bad block management method is not the same, some will put BBT to block0, because Block0 must be good block, but block0 is generally used as boot, then also will cause can not put BBT, also some will BBT put to the last partition.
As can be seen from the above, OOB is the data on every page, there is ECC, and BBT is a flash will have, for each block of the bad block recognition is the first spare erea of the sixth byte.
OOB management for Nand Flash