Internal chip memory layout and storage operation features

Due to the fact that nand, bbt, and ecc in Nand have a great influence on the success rate of programming when bare board or yaffs2 fs is written in the case of uboot, we do not understand the following meanings:

Internal memory layout and memory operation features of the chip:

A piece of Nandflash is a device whose data storage is hierarchical:

1 (Device) =4096 (Blocks)

1 (Block) -= 32 (Pages/Rows) Pages and lines are the same meaning, the name is not the same

1(Page) = 528 (Bytes) = Block Size (512Bytes) + OOB Block Size (16Bytes)

In each page, the last 16 bytes (also called OOB) are used to set the state after the NandFlash command is executed. The remaining 512 bytes are divided into the first half and the second half. You can use the NandFlash command 00h/01h/50h to locate the first half, the second half, and the OOB.

Nand Flash's built-in pointers point to their respective first addresses.

Storage operation features:

1. The smallest unit of erase operation is the block.

2. Each bit of the NandFlash chip can only be changed from 1 to 0, and cannot be changed from 0 to 1. Therefore, the corresponding block must be erased before writing it. (Erasing is the corresponding block.) All bits become 1).

3. The sixth byte (ie, 517 bytes) of the OOB section is a bad block. If it is not a bad block, the value is FF, otherwise it is a bad block.

4. In addition to the sixth byte of OOB, the first 3 bytes of OOB are usually stored in the Nand Flash hardware ECC code.

BBT: bad blocktable, bad block table. There are differences in how bad blocks are managed by nands. For example, if you use nand for storage, you will put bbt on block0, because 0th block must be a good block. However, if nand itself is used for boot, the 0th block will store the program, not the bbt.

Some put bbt on the last piece. Of course, this piece cannot be a bad piece.

Some bbts use 2 bits to indicate the status of 1 block, so 1 byte can represent 4 blocks.

The size of bbt is related to the size of nand. The bigger nand is, the bigger the bbt is.

So specific code specific analysis.

ECC:

When the NANDFlash fails, it usually does not cause the entire Block or Page to be unreadable or all errors, but only one or more bits in the entire Page (for example, 512Bytes) error. A more specialized checksum, ECC, is generally used. The ECC can correct single-bit errors and detect double-bit errors, and the calculation speed is fast, but errors of more than 1 bit cannot be corrected, and errors of more than 2 bits are not guaranteed to be detected.

ECC generally generates 3 bytes of ECC check data for every 256 bytes of original data. The three bytes have a total of 24 bits divided into two parts: a 6-bit column check and a 16-bit check, and the extra two bits are set.

When writing data to the NANDFlash page, we generate an ECC checksum for every 256 bytes, called the original ECC checksum, and store it in the OOB (out-of-band) data area of ​​PAGE. Its position is eccpos[].

During the verification, it is not difficult to infer from the above ECC generation principle that the original ECC check and the new ECC checksum read from the OOB area are bitwise XORed, and if the result is 0, there is no error (or There was an error that ECC could not detect); if there are 11 bits in the 3 byte XOR result, then there is 1 bit, which means there is a bit error, and it can be corrected; if there is only 1 bit in the 3 byte XOR result A bit of 1 indicates an error in the OOB area; other conditions indicate that an uncorrectable error has occurred.

Powerwall Solar Battery

Enershare's commitment to future-ready energy solutions for smart home innovations, Enershare's Energy Storage Systems create a flexible energy maintenance system for homeowners who want to take more control of their home energy use, it is intended to be used for home battery energy storage and stores electricity for solar self-consumption, load shifting, backup power, and off-the-grid use. you can use it anytime you want-at night or during an outage.

Solar Battery Bank,Solar Energy Storage,Solar House Battery,Solar Battery Storage,Lithium Battery Off Grid,Solar Battery Backup 48v,home battery

Shenzhen Enershare Technology Co.,Ltd , https://www.enersharepower.com

Posted on