Analysis and improvement of lightweight NAND bad block management method

Source: Internet
Author: User
Tags file system xmlns

NAND and its bad blocks

NAND Flash is a high-density low-cost storage, it has been widely used in a variety of embedded systems, USB storage devices, SD cards, mobile phones, cameras and solid-state drives are used in various devices are NAND chips. Its internal structure is organized according to block/page, and a NAND chip contains several blocks, and the interior of the block is composed of several pages. NAND chip factory may contain a number of bad blocks, in the use of the process may also produce new bad blocks, when a block is marked as a bad block, should not be written to the data, so as to avoid data loss. Because of the limited number of NAND erase, and will be used in the process of generating new bad blocks, the general need for additional software or hardware to match it to use.

The classification of NAND bad block management methods

At present, NAND bad block management methods can be divided into the following categories:

Bad block management based on FTL chip

It uses an additional FTL (Flash translation Layer) chip to manage NAND, shielding bad block information from the outside, USB disk, SD card, MMC card and SSD drive all use this management method. This simplifies the NAND operation, but also the bad block of information is not visible to the outside, if the system appears to be a problem related to the block, positioning and debugging becomes difficult, in addition, the FTL chip also requires additional hardware costs.

Bad block management based on NAND file system

JFFS2, YAFFS2, flashfx these file systems specifically for NAND can manage bad blocks.

NAND Management Middleware

Some middleware (middleware) is dedicated to NAND management, such as UBI.

Lightweight NAND bad block management

NAND-managed hardware or software modules not only provide bad block management, but also support the load averaging of NAND erase operations. Lightweight bad block management focuses only on bad blocks, does not provide average support for the scratch load, and does not depend on any third party libraries. Therefore, lightweight bad block management reduces the complexity of the system and eliminates the time to load the file system or initialize the middleware, which is widely used in embedded systems.

Figure 1 shows the content layout of NAND internals in several typical embedded systems. If you need to write a variety of data to NAND frequently, it is best to use NAND file system or NAND management middleware to manage the areas that need to be written. Areas that rarely need to be updated, such as bootloader, VPD, and Kernel, require lightweight, bad-block management without load averaging. In many embedded systems, the amount of data that needs to be written to NAND is small, and the frequency is low, such as routers, printers, and PLC, which can be used only for lightweight, bad-block management.

Fig. 1. Nand Memory Map of a typical embedded system

Uboot Lightweight bad block management method

NAND bad block management is based on the Bad Block table (BBT), which identifies all the bad blocks in the system. Therefore, the difference between different management methods can be found in the following several questions to find the answer.

How do I initialize and read a bad block table?

How do I mark and update a bad block table when new bad blocks are generated?

How do I save a bad block table? Is there an outage protection mechanism when saving?

When writing data to NAND, if the current block is a bad block, how can I find a good replaceable block?

Uboot is the most widely used bootloader, which provides two kinds of lightweight bad block management methods, which can be called basic and improved. By following the table, we can see the difference between the two.

Table 1. Comparison of two kinds of bad block management methods for Uboot

Basic type of improved
Initialize, read BBT Each time the system initializes, scans the entire NAND, reads all blocks the factory bad block mark, establishes the BBT, occupies the more start-up time. When the system initializes for the first time, the entire listing 1 is scanned. BBM The first letter NAND establish BBT. After each initialization, scan the BBT area, and if the signature of the current block and the signature of the Bad block table (a particular string) are found to match, the data for the current block is read as BBT.
Update BBT When the erase operation produces a new bad block, update the BBT in memory and change the bad block's factory bad block Mark from 0xFF to 0x00.
The bad block is still operational after the erase error-Change the factory bad block mark, there is a security risk. Also, it is not possible to tell which ones are manufactured and which are bad blocks that are produced during use.
When the erase operation produces a new bad block, the BBT in memory is updated, and the updated BBT is immediately written to the NAND or other NVRAM.
Save BBT Do not save Keep a copy in NAND or other NVRAM, no power off protection mechanism.
Bad block substitution method If the current block is a bad block, write the data to the next block. If the current block is a bad block, write the data to the next block.

Although some improvements have been made to Uboot's improved bad block management approach, it still has three major drawbacks.

A bad block occurs, the data order is written to the next good block. If there are more than one software module in NAND, each module will need to reserve a larger space as a good block of spare, which would waste more NAND space. In general, each module reserves a good block number for the NAND chip to allow the maximum number of bad blocks, which vary depending on the chip, the typical value is 20 or 80. Assuming that NAND is a large page type with a total of N modules, the total amount of space required to reserve is n*80*128kb.

When reading the BBT, only the signature is checked and no BBT data is validated.

There is no power-off protection mechanism. If power is lost while saving the BBT, BBT will lose.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/storage/

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.