NAND partition and NAND erase simple solution

Source: Internet
Author: User
My NAND flash 32m,kernel 2.6.18, Rootfs is EMB Linux, Cramfs.

The NAND flash partition is as follows:
static struct Mtd_partition nand_partitions[] = {
/* Bootloader (UBL, U-boot, BBT) in sectors:0-14 */
{
. Name = "Bootloader",
. Offset = 0,
. Size = * Nand_block_size,//32x16 = 512k
. Mask_flags = mtd_writeable,/* Force Read-only */
},
/* bootloader params in the next sector 15 */
{
. Name = "params",
. offset = Mtdpart_ofs_append,
. Size = Nand_block_size *,//96x16 = 1536k = 1.5M
. Mask_flags = mtd_writeable,/* Force Read-only */
},
/* Kernel in SECTORS:16 */
{
. Name = "Kernel",
. offset = Mtdpart_ofs_append,
. Size = sz_2m,//2m
. mask_flags = 0
},
/* ROOTFS */
{
. Name = "FileSystem1",
. offset = Mtdpart_ofs_append,
. Size = sz_16m + sz_8m,//24m
. mask_flags = 0
},
/*parameter*/
{
. Name = "Filesystem2",
. offset = Mtdpart_ofs_append,
. Size = Mtdpart_siz_full,//4m,/mnt/nand, save Log,sysenv,
. mask_flags = 0
}
};

After the system starts
# cat/proc/partitions
Major Minor #blocks name

0 mtdblock0
1 1536 Mtdblock1
2 2048 Mtdblock2
3 24576 Mtdblock3
4 4096 Mtdblock4
254 0 Sbulla
#
# CAT/PROC/MTD
Dev:size erasesize Name
mtd0:00080000 00004000 "Bootloader"
mtd1:00180000 00004000 "params"
mtd2:00200000 00004000 "Kernel"
mtd3:01800000 00004000 "FileSystem1"
mtd4:00400000 00004000 "FILESYSTEM2"
#

loadb 20000000(1)
Nand erase 0x100000 0x200000(2)
NAND write 0x20000000 0x100000 0x200000-//(3)
NAND read 0x20000000 0x100000 0x200000-//(4)

TFTP 0x80200000 (memory address) uimage
Process from server to memory from inside to NAND flash
Why, because the nandflash of the erase read and write not independent in case the side of the wipe good can network broken that is troublesome oh through the memory transfer good idea ah speed at least fast OH

(1) Download from the serial port to the 0x20000000 at SDRAM
(2) starting from 1M to erase NAND flash, erase the 2M size of space (3) in the SDRAM in the beginning of the 0x20000000, burning to the NAND flash 0x100000 at the beginning of the 2M space (4) will NAND 2M space content at the beginning of the 0x100000 of Flash, copied to 0x20000000 where the Nand Flash chip works at the beginning of the SDRAM
------------------------------------
Nand Flash chip models are Samsung K9F1208U0B, with data storage capacity of 64MB and block-page storage management. 8 x I/O
The pin acts as a multiplexed port for data, addresses, and commands.

Chip internal storage layout and storage operation features:
A piece of NAND flash is a device, and its data storage tiers are:
1 (Device) = 4096 (Blocks)
1 (Block)-= (pages/rows) page is the same meaning as the line.
1 (Page) = 528 (Bytes) = data block Size (512Bytes) + OOB block Size (16Bytes)
On each page, the last 16 bytes (also called OOB) are used to set the state after the NAND Flash command has finished executing, and the remaining 512 bytes
It is divided into the first half and the second part. You can navigate through the NAND Flash command 00h/01h/50h the first half, the second half, and the OOB respectively.
The Nand flash built-in pointers point to their first address.

Storage Operation Features:
1. The minimum unit of the erase operation is the block.
2. Nand Flash chip each bit (bit) can only change from 1 to 0, and not from 0 to 1, so before you write to it, be sure to erase the corresponding block (erase that is, the corresponding block of bits all become 1).
3. The sixth byte (or 517 bytes) Flag 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 OOB sixth byte, usually at least the first 3 bytes of the OOB storage NAND flash hardware ECC code

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.