First, you need to understand the structure of NAND Flash.
Taking micron mt29f4g08bxb NAND Flash as an example, this flash (for example) uses four sectors (sector) to form one page and 64 pages) one block and 4096 blocks constitute the entire flash memory. Because the capacity of each slice is 512 bytes (bytes ), the overall flash capacity is 4224 M bit (equivalent to M bytes), remove the backup area for storing the ECC data validation 16 m (dotted line), is the size of the film M bytes. Flash of other models also consists of a page consisting of slices, a page consisting of blocks, and a block consisting of the entire storage device, but the number of sectors, pages, and blocks is different.
In the flash production process, due to the defects of the production process, it is easy to generate unusable bad areas in flash. If such a flash is used in a USB flash disk, the so-called "mass production tool" must be used. The USB flash disk mass production tool is actually a tool that combines bad area scanning and flash management systems. The scanning of conventional USB flash drives is based on blocks. Scanning writes data to each block, and then compares the read data with the written data, if the data is incorrect, the block is marked as "bad block ". After scanning, the flash management system is loaded into the flash system. The flash management system uses the bad block table generated by scanning to perform read and write management on the entire flash system. This completes the whole production process, the USB flash drive can be used normally. Therefore, the difference between the size displayed by the USB flash disk and the actual flash capacity comes from the bad block that cannot store information and the occupied block of the flash management system. The larger the number of Bad blocks, the lower the USB flash disk capacity, and the block occupied by the flash management system cannot be avoided, just like the hard disk space occupied by the operating system installed on our computer.
Of course, an ECC error correction capability is also involved here. Assume that the ECC error correction capability defined for this flash is 1 bit, only blocks with more than 1 bit of data are marked as bad blocks. In this case, we need to distinguish between Block Correction and sector correction. Assume that any sector (512 bytes) in any block has an error that exceeds 1 bit, when scanning, the General Master determines that the entire block is a bad area, which will lose the capacity of the entire block by Kbytes. However, when using the sector correction master, the same 1-bit ECC error is corrected, he will directly determine which slice in the block is more than 1 bit error, so as to remove it, the loss is only the capacity of bytes for each truly wrong slice, in this way, the remaining sectors without errors are retained, so that the flash utilization can be greatly improved.