U-boot-2014.10 port 20th days ---- add nand flash command support (2), u-boot-2014.10nand

Source: Internet
Author: User

U-boot-2014.10 port 20th days ---- add nand flash command support (2), u-boot-2014.10nand

After the previous day's transplantation, we found that:

Flash: 2 MiB
NAND: 0 MiB

It indicates that the Nand flash has not been transplanted successfully. The board_nand_init function is found in the drivers/mtd/nand/s3c2440_nand.c file:

nand->select_chip = NULL
If the chip function is set to NULL, we add the s3c2440_nand_select function to 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: /* deselect */nand-> nfcont | = (1 <1); break; case 0:/* select */nand-> nfcont & = ~ (1 <1); break; default: BUG ();} return ;}

Change select_chip in the board_nand_init function:

nand->select_chip = s3c2440_nand_select;
Re-compile and run:

Flash: 2 MiBNAND:  64 MiB
The size of the tq2440 nand flash is 64 MB, indicating that nandflash has been successfully detected.
Perform a read/write test as follows:

Before the test, erase the nand flash file again:

[TQ2440 #] nand erase 0 4000000

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

[TQ2440 #] tftp 31000000 test
View the content at 0x3000000 address:

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

Write the content at 0x3000000 address to the 0 address of nand flash:

[TQ2440 #] nand write 31000000 0 ff NAND write: device 0 offset 0x0, size 0xff 255 bytes written: OK[TQ2440 #] 
It indicates that the operation is successful.

Then read it to the 0x3000000 address and perform the following read operations:

[TQ2440 #] nand read 31000000 0 ffNAND read: device 0 offset 0x0, size 0xff 255 bytes read: OK
It indicates that reading is OK, and whether the content read and written before and after is the same:

[TQ2440 #] md 3100000031000000: 34333231 38373635 0a0a3039 00000000    1234567890......
It indicates that the Nand flash port is OK.
For the nand flash on the tq2440 Development Board, the relationship between pages, blocks and devices, and oob:


The size of a page is 512 bytes, and the size of oob is 16 bytes. You can run the nand dump command to view the page.

First, erase a block. Because nand flash can only write 0 but cannot write 1, the erasure operation is to set the bytes in both the page and oob area to 1, as shown below:

[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
OOB:
Ff
Ff
The green part is the page size, 512 bytes, the red part is the oob area, 16 bytes. The bytes in the first page and the oob area are both ff.

The 10 bytes after the starting position of 0x3100 0000 in SDRAM are 0 ~ The ASCII value of 9, which is written to the first page of Nand flash.

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

Write 16 bytes:

[TQ2440 #] nand write 31000000 0 10

[TQ2440 #] nand dump 0
Page 00000000 dump:
31 32 33 34 35 36 37 38 39 30 0a 0a 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
OOB:
Aa a5 AB ff
Ff

We can see that the first page has saved 0 ~ The ASCII value of 9. You do not need to worry about 0a0a.

Continue tomorrow.












Related Article

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.