2008-04-10 14:40:38     unknown spi-flash bug

Document created by Aaronwu Employee on Sep 17, 2013
Version 1Show Document
  • View in full screen mode

2008-04-10 14:40:38     unknown spi-flash bug

Ivan Koryakovskiy (RUSSIAN FEDERATION)

Message: 54042    I have something weird when I write data to spi flash m25p80. In spi_flash.c i added m25p80 device.

 

read operation is fine (I have my own simple program which makes read/write operations).

but when i write data to flash and read it back i always get the first to bytes of a page (that has 256 bytes) wrong and the same, no matter what i wrote:

 

00800000: 05 00 33 dc 7b 56 bb

...

00800100: 05 00 31 cc 14 52 47

...

00800200: 05 00 00 00 00 00 00

 

I changed a little bit the source of spi_flash.c:

 

    /* Shoot out a single write buffer */

    write_buffer_size = min(count, flash.write_length);

    for (i = 0; i < write_buffer_size; ++i)

        {

            printf("%02x ", *(buffer + i));

            if ((i+1)%16 == 0 && i != 0) printf("\n");

            spi_write_read_byte(buffer[i]);

        }

 

and i got the real buffer data:

00800000: 21 17 33 dc 7b 56 bb

...

00800100: 33 15 31 cc 14 52 47

...

00800200: 00 00 00 00 00 00 00

 

I also tried to low spi baud but it didn't help.

 

has anybody an idea of what might be wrong?

QuoteReplyEditDelete

 

 

2008-04-10 15:23:28     Re: unknown spi-flash bug

Mike Frysinger (UNITED STATES)

Message: 54043    the spi flash driver has been rewritten from the ground up for 2008R1.  you should use that driver rather than any older one.

QuoteReplyEditDelete

 

 

2008-04-10 17:28:02     Re: unknown spi-flash bug

Ivan Koryakovskiy (RUSSIAN FEDERATION)

Message: 54051    i am using the latest. path to it is /u-boot/u-boot-1.1.6/board/bf537-stamp/spi_flsh.c

according to the log i've posted, i am not sure it's a problem with driver. it's something really strange - buffer has correct values, but they are written not correctly by hardware...

QuoteReplyEditDelete

 

 

2008-04-10 17:54:38     Re: unknown spi-flash bug

Mike Frysinger (UNITED STATES)

Message: 54052    oh, i seem to recall now why m25p80 was left out.  it doesnt have a JEDEC compatible ID which means it cannot be dynamically detected.

 

try this patch:

@@ -51,6 +51,7 @@ static struct flash_info flash_st_serial_flash[] = {

        { "m25p10", 0x2011, 32 * 1024, 4 },

        { "m25p20", 0x2012, 64 * 1024, 4 },

        { "m25p40", 0x2013, 64 * 1024, 8 },

+       { "m25p80", 0x20FF, 64 * 1024, 16 },

        { "m25p16", 0x2015, 64 * 1024, 32 },

        { "m25p32", 0x2016, 64 * 1024, 64 },

        { "m25p64", 0x2017, 64 * 1024, 128 },

@@ -313,6 +314,11 @@ static int spi_detect_part(void)

        if (called_init)

                return 0;

 

+#if 1

+       flash.manufacturer_id = JED_MANU_ST;

+       flash.device_id1 = 0x20;

+       flash.device_id2 = 0xFF;

+#else

        SPI_ON();

 

        /* Send the request for the part identification */

@@ -332,6 +338,7 @@ static int spi_detect_part(void)

        flash.device_id2 = spi_write_read_byte(0);

 

        SPI_OFF();

+#endif

 

        dev_id = (flash.device_id1 << 8) | flash.device_id2;

QuoteReplyEditDelete

Attachments

    Outcomes