u-boot-2014.10 20th Day----Add NAND Flash command Support (ii)

Source: Internet
Author: User

Following the previous day's transplant, it was discovered after running:

Flash:2 MiB
nand:0 MiB

Note that NAND flash was not successfully ported and found in the Board_nand_init function in file drivers/mtd/nand/s3c2440_nand.c:

Nand->select_chip = NULL
Select the chip function is null, we add the S3c2440_nand_select function above the Board_nand_init function, the code is as follows:

static void S3c2440_nand_select (struct mtd_info *mtd, int chipnr) {    struct S3c2440_nand *nand = S3c2440_get_base_nand ();    Switch (CHIPNR) {        case-1:/* uncheck *            /Nand->nfcont |= (1<<1);            break;        Case 0:/* selected *            /Nand->nfcont &= ~ (1 << 1);            break;        Default:            BUG ();    }    return;}

Then change the select_chip in the Board_nand_init function to:

Nand->select_chip = S3c2440_nand_select;
Recompile run:

Flash:2 Mibnand:  MiB
The size of the tq2440 NAND Flash is 64M, indicating that Nandflash was successfully detected.
Read-write tests are performed below:

Erase the NAND flash once before testing:

[TQ2440 #] NAND erase 0 4000000

Download the test file from the server and place it at the 0x31000000 address.

[TQ2440 #] TFTP 31000000 test
See what's at the 0x31000000 address:

[TQ2440 #] MD 31000000               31000000:34333231 38373635 0a0a3039 00000000    1234567890......31000010:00000000 00000000 00000000 00000000 ....... .....    

Write the contents of the 0x31000000 address at the 0 address of the NAND flash:

The explanation is successful.

Then read it to the 0x31000000 address at the bottom of the read operation:

[TQ2440 #] NAND read 31000000 0 ffnand read:device 0 offset 0x0, size 0xFF 255 bytes Read:ok
Note that reading is OK, compared to read and write content is the same:

[TQ2440 #] MD 3100000031000000:34333231 38373635 0a0a3039 00000000 1234567890 ...
Describes NAND flash migration OK.
For the NAND flash on the tq2440 Development Board, the relationship between the page, the block and the device, and the OOB area:


You can see that a page size of 512bytes,oob is 16 bytes and can be viewed using the NAND dump command.

First erase a block, because NAND flash can only 0 can not write 1, so the erase operation is the page and the Oob area of the bytes are set to 1, as follows

[TQ2440 #] NAND erase 0 FF
[TQ2440 #] NAND dump 0
Page 00000000 Dump:
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
OOB:
FF FF FF FF FF FF FF
FF FF FF FF FF FF FF
The green part is a page size, 512bytes, the red part is the OOB area, 16bytes. The first page after erasing and the bytes for the OOB area are ff.

In SDRAM, the 10 bytes after the 0x3100 0000 start position are 0~9 ASCII values, which we write to the first page of NAND flash.

[TQ2440 #] MD 31000000
31000000: 34333231 38373635 0a0a3039 00000000 1234567890 ...
31,000,010:00000000 00000000 00000000 00000000 ..........

Write 16 bytes:

[TQ2440 #] NAND write 31000000 0 10

[TQ2440 #] NAND dump 0
Page 00000000 Dump:
---- 0a 0a00 00 00 00
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
OOB:
AA A5 AB FF FF FF FF FF
FF FF FF FF FF FF FF

You can see that the first page has saved the ASCII value of the 0~9, and write more 0a0a without a tube.

Continue tomorrow.












u-boot-2014.10 20th Day----Add NAND Flash command Support (ii)

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.