AnsweredAssumed Answered

u-boot bf533 nand flash read write problem

Question asked by mohsen158 on Jul 14, 2012
Latest reply on Jul 21, 2012 by mohsen158

Hello,

 

I wanted to use nand flash with u-boot and bf533. each time i erase nand flash using "nand erase clean" command, writing to nand flash through "nand write 0 0 800" command (1page from 0 of ram to 0 of nand) is fine just for 1 time. next writes to the same address causes dumb data to be stored. It can be shown after reading the same address and using "md" command.

 

I have written a simple command too: (mytest)

 

 

int do_mytest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])

{

        u_char rd0[2048];

        u_char rd1[2048];

        int ind;

        ulong off = 0x800;

        ulong len = 0x800;

 

        for(ind=0;ind<2048;ind++){

                rd0[ind]=0xFF;

                rd1[ind]=0xFF;

        }

 

        for(ind=64;ind<79;ind++){

                rd0[ind] = (u_char)ind;

        }

 

        rd0[244] = 0x37;

        rd0[144] = 0x9A;

        rd0[170] = 0x12;

 

        printf("%d\n",nand_write(&nand_info[0], off, &len, rd0));

 

        printf("%d\n",nand_read(&nand_info[0], off, &len, rd1));

 

        for(ind=0;ind<256;ind++){

                if(ind%16==0) puts("\n");

                else if (ind%4==0) puts(" ");

                printf("%2x", rd1[ind]);

        }

        puts("\n");

 

        return 0;

}

 

U_BOOT_CMD(

        mytest,         5,              1,      do_mytest,

        "short des",

        "long des"

);

 

 

 

and a simple test:

 

 

first:

 

nand erase clean

 

then I have written some bytes to ram:

 

00000000: 11111111 22222222 33333333 44444444    ....""""3333DDDD

00000010: 55555555 66666666 77777777 88888888    UUUUffffwwww....

00000020: ffffffff ffffffff ffffffff ffffffff    ................

00000030: ffffffff ffffffff ffffffff ffffffff    ................

00000040: 88888888 77777777 66666666 55555555    ....wwwwffffUUUU

00000050: 44444444 33333333 22222222 11111111    DDDD3333""""....

00000060: ffffffff ffffffff ffffffff ffffffff    ................

00000070: ffffffff ffffffff ffffffff ffffffff    ................

00000080: ffffffff ffffffff ffffffff ffffffff    ................

00000090: ffffffff ffffffff ffffffff ffffffff    ................

000000a0: ffffffff ffffffff ffffffff ffffffff    ................

000000b0: ffffffff ffffffff ffffffff ffffffff    ................

000000c0: ffffffff ffffffff ffffffff ffffffff    ................

000000d0: ffffffff ffffffff ffffffff ffffffff    ................

000000e0: ffffffff ffffffff ffffffff ffffffff    ................

000000f0: ffffffff ffffffff ffffffff ffffffff    ................

 

 

then:

 

nand write 0 800 800

 

mytest

 

output:

 

11111111 22222222 33333333 44444444

55555555 66666666 77777777 88888888

ffffffff ffffffff ffffffff ffffffff

ffffffff ffffffff ffffffff ffffffff

0 0 0 0 44454647 40404242 44454455

44444444 33333333 22222222 11111111

ffffffff ffffffff ffffffff ffffffff

ffffffff ffffffff ffffffff ffffffff

ffffffff ffffffff ffffffff ffffffff

9affffff ffffffff ffffffff ffffffff

ffffffff ffffffff ffff12ff ffffffff

ffffffff ffffffff ffffffff ffffffff

ffffffff ffffffff ffffffff ffffffff

ffffffff ffffffff ffffffff ffffffff

ffffffff ffffffff ffffffff ffffffff

ffffffff 37ffffff ffffffff ffffffff

 

 

it didn't write my bytes just modified someones(64 to 79)! why?

 

the returned value of read function is -74. and it says: nand_read_ecc: Failed ECC read, page 0x00000001

 

i have found that the last byte of ecc is calculated and written right but when it reads it something else is read. i mean the last ecc (for last 256 byte) is calculated and writtetn 0xFF but is read 0x0F? it isn't caused by hardware failure cause i have tested for some other pages on nand device too. and the problem remains.

 

 

am i reading and writing the nand flash in the right way?

Outcomes