FAL and NAND access (Bad block management, logical sector access)

Source: Internet
Author: User

The FAL mainly includes mappingtable, sectormgr, and compactor modules. Mappingtable is a ing table. After being loaded, the NAND driver scans the NAND and creates a ing table in the memory to convert the Logical Address to the actual physical address. Sectormgr is a sector management module and Compactor is a garbage collection module. Address re ing should be the main function of FAL.

According to the habits of thinking, first understand why? The following two features determine the reason for Fal design.

1. The common nand, one block is 32 sector, or 256 sector. In flash, the write/erase unit is block, while in filesys, the read/write unit is sector. FTL conversion is required.

2. the access to the disk sector by the file system is unbalanced. In some regions, the Access frequency is extremely high, while Flash is a device with limited service life. Therefore, wear leveling is required ), make sure that the write and erase operations are evenly distributed to each block as much as possible.

After reading the FAL code, I will summarize several ideas based on my thoughts on how to design them:

1. if you need to modify the saved data, you need to first change the block where the erase data is located, and then the data updated by writer. This process is relatively slow, so this is not a common practice. Instead, the modified block data is first written to a new block, and then the original block is marked as the dirty block. Note that the mark operation is actually a direct write (without erase) operation. One statement: SLC supports such behavior, but MLC does not. I'm afraid I need to modify the FAL for the MLC device. The above process is designed as a transaction processing process, that is, to record the processing stage and status, and confirm that the processing is complete. -- This is necessary to avoid unexpected power loss and serious consequences.

2. Address ing is the core part of the design. The FAL design concept is as follows: Create a table during initialization to depict the ing between logicla and physical. The cost of this method is that the full scan is required every time the server is started. The scanning time is related to the size. A better way is to save the table to a fixed address. You only need to read the table at startup and change the space time. However, we also need mechanisms to ensure that bad blocks are everywhere and power loss occurs at any time ). What does FAL scan do? FAL reads 16 bytes of the spare region of each valid sector. The first four bytes are the slice address, the next byte is the OEM status, and the next byte is the bad block identifier, the next two bytes are in the FAL state for transaction processing.

3. The first point describes how to modify the data processing method. What about the dirty blocks? FAL has a thread in the background to erase and recycle these dirty blocks. Re-mark as free for use. This is the so-called garbage collection mechanism.

4. A basic premise is that the read operation will not lead to bad blocks. FAL does not handle this either. (In this case, when will the system generate Bad blocks? Voltage instability? Cosmic rays? Alien Attack ?) If this premise is true, it is safe and reliable for Bootloader to read the wince image and load and start it (a heart disease)

5. Disable bootloader. Bootloader can identify some blocks as reserved blocks, so that FAL will kindly skip these blocks. Otherwise, the consequences will be very serious and FAL will be angry. Didn't you often find that your bootloader has disappeared inexplicably? Haha. In addition, it is inappropriate for Bootloader to directly access the file system zone with a physical address. How can I access bootloader without FAL? For example, read a BMP file from the file system as the logo and display it at startup. For example, set a configuration file in wince to instruct bootloader to perform other actions during next boot. One silly way is that bootloader scans the entire slice every time it reads a slice and finds the actual address of this slice. This is the most silly way in the world. I think it's slow and I don't want to do it again after I get it. The clever way is to create a ing table.

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.