Debugging of the k9f1g08 2 k page NAND Flash Driver -- reproduced from: shuiii

Source: Internet
Author: User

K9f1208

Secotr size = 512 byte, block_pre_sector = 32 sector, block size = 512*32 = 16 K, device = 4096 block = 64 m

K9f1g08

Secotr size = 2 K, block_pre_sector = 64 sector, block size = 2*64 = 128 K, device = 1024 block = 128 m

The above is my previous understanding of the nandflash structure, which ignores a very important part, that is, the area where NAND is used to save other information. This information includes the block quality mark, the Logical Address of the block, and the ECC checksum of the data on the page ....

This part of data is saved through the structure sectorinfo

Typedef struct _ sectorinfo
{
DWORD dwreserved1; // reserved-used by Fal
Byte boemreserved; // for use by OEM
Byte bbadblock; // indicates if block is bad
Word wreserved2; // reserved-used by Fal

} Sectorinfo, * psectorinfo;

When reading and writing nand

Bool fmd_readsector (sector_addr startsectoraddr, lpbyte extends ctorbuff, extends ctorinfo extends ctorinfobuff, DWORD dwnumsectors );
Bool fmd_writesector (sector_addr startsectoraddr, lpbyte extends ctorbuff, extends ctorinfo extends ctorinfobuff, DWORD dwnumsectors );

The psectorinfobuff parameter reads the corresponding sector status. If the psectorinfobuff parameter is null, the sector data is read and written. If the value of ctctorbuff is null, the read/write sector status is displayed.

Differences in address Loops
When reading data. The 16-bit low column address is 0, and the offset in the page is 0,
Nf_addr (0); // column (A [7:0]) = 0
Nf_addr (0); // A [11: 8]
Nf_addr (blockpage) & 0xff); // A [19: 12]
Nf_addr (blockpage> 8) & 0xff); // A [27:20]

When reading status, the 16-bit low column address is 2048, And the offset in the page is 2048
Nf_addr (2048 + 0) & 0xff); // 2060 = 0x080c
Nf_addr (2048 + 0)> 8) & 0xff );
Nf_addr (blockpage) & 0xff); // A [19: 12]
Nf_addr (blockpage> 8) & 0xff); // A [27:20]

Because the data stored by the NAND device has a certain error rate, ECC verification is required to ensure data correctness. Traditional file systems are generally directly connected to hardware drivers. However, for NAND devices, an FTL (Flash Translation Layer) needs to be added to convert Logical Block addresses to physical addresses, bad Block labeling, ECC verification.
Targetlibs = $ (_ commonoakroot)/lib/$ (_ cpuindpath)/FAL. lib/

The fmd_init driver of the NAND driver. After Initialization is complete, some basic information about the NAND is obtained through fmd_getinfo.
FAL then calls fmd_readsector to create a ing table from the physical page to the logical page. Finally, based on the registry configuration, you will also decide whether to reformat the NAND and whether to automatically mount the NAND partition to the storage manager.

[HKEY_LOCAL_MACHINE/system/storagemanager/profiles/flashdrv]
"Defaultfilesystem" = "fatfs"
"Partitiondriver" = "mspart. dll"
"Automount" = DWORD: 1
"Autopart" = DWORD: 1
"AutoFormat" = DWORD: 1

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.