How to burn the yaffs file system image into NAND Flash

Source: Internet
Author: User

Unlike normal file systems, the yaffs file system is designed specifically for NAND Flash. You can use mkyaffsimage to generate an image of the file system. However, if you want to burn this image into flash, you need to pay attention to it in some places.

 

In terms of hardware, the design of NAND Flash has taken into account the situation that contains bad blocks. For NAND Flash with 512 bytes per sector, each sector has a 16-byte extra expansion zone, it is usually used to store the validation data of this sector and the information such as the bad block mark (wince uses the 4-byte storage logic sector number), so when we look at the data sheet of NAND flash, it is often found that its capacity is described in the format of "64 m + 2048k", and the subsequent numbers are used to represent the capacity of the extended area.

 

Since the yaffs file system is designed for NAND Flash, it has taken into account the use of the extended area when generating the file system image and includes the extended area data in the sector data, its structure is defined as follows:

 

Bytes 0-511: Data

 

Bytes 512-515: yaffs tag

Bytes 516: Data status

Bytes 517: block status

Bytes 518-519: yaffs tag

Bytes 520-522: ECC for bytes 256-511

Bytes 523-524: yaffs tag

Bytes 525-527: ECC for bytes 0-255

 

It can be seen that yaffs uses an 8-byte (yaffs tag) to store information about the file system, and uses a 4-byte (ECC) to store verification data.AlgorithmUnlike the Hardware Algorithm of the NAND flash controller, the verification may fail for many boot loaders.

 

In addition, the yaffs file system needs to use the first block on the partition to store a struct named yaffs_objectheader. This struct records the files, paths, and related links in the partition. This block cannot be generated when an image is generated. Therefore, you must skip the first available block when writing. For example, if we divide a yaffs partition in the MTD partition and occupy a NAND Flash space of 1000-4095 blocks, we must leave 1,000th blocks blank and the image file should be burned from 1001 blocks.

 

After learning about the features of the yaffs image file, we now know how to burn the yaffs image into nand flash:

1. Load the image file into the memory

2. Locate and skip the first nand flash based on MTD partition information, and start burning from the next disk.

3. Erase the block. If the failed part is erased, the block is marked as bad. continue to the next block.

4. Read 512 bytes from the image file and write them to the NAND Flash sector.

5. Continue to read 16 bytes from the image file and write the data to the NAND Flash extended data zone. (do not write the data to the hardware ECC; otherwise, the yaffs partition cannot be mounted)

6. Repeat Step 4 until the entire data is written.

7. Repeat Step 3 until the entire image file is written

 

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.