[U-Boot-Users] [PATCH] Fix SPI read/write length issue

When the functions "eeprom_read" and "eeprom_write" works for the SPI flash, the data length is limited to I2C_RXTX_LEN. See the following piece of code. ----------------------------- #if !defined(CFG_I2C_FRAM) maxlen = 0x100 - blk_off; if (maxlen > I2C_RXTX_LEN) maxlen = I2C_RXTX_LEN;
if (len > maxlen) len = maxlen; #endif -----------------------------
The following patch fixes this issue.
From 2451cc87059acc456597a28f802ab3acb2d61ad4 Mon Sep 17 00:00:00 2001
From: Aubrey Li aubrey.adi@gmail.com Date: Thu, 22 Mar 2007 17:26:27 +0800 Subject: [PATCH] Fix spi read/write length issue
Signed-off-by: Aubrey Li aubrey.adi@gmail.com --- common/cmd_eeprom.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c index d15a412..71d9792 100644 --- a/common/cmd_eeprom.c +++ b/common/cmd_eeprom.c @@ -177,10 +177,14 @@ int eeprom_read (unsigned dev_addr, unsi maxlen = 0x100 - blk_off; if (maxlen > I2C_RXTX_LEN) maxlen = I2C_RXTX_LEN; + +#ifndef CONFIG_SPI if (len > maxlen) len = maxlen; #endif
+#endif + #ifdef CONFIG_SPI spi_read (addr, alen, buffer, len); #else @@ -273,10 +277,13 @@ int eeprom_write (unsigned dev_addr, uns if (maxlen > I2C_RXTX_LEN) maxlen = I2C_RXTX_LEN;
+#ifndef CONFIG_SPI if (len > maxlen) len = maxlen; #endif
+#endif + #ifdef CONFIG_SPI spi_write (addr, alen, buffer, len); #else

In message 27d85ee10703220240i7f783984u6dcf6ff0da79a25f@mail.gmail.com you wrote:
When the functions "eeprom_read" and "eeprom_write" works for the SPI flash, the data length is limited to I2C_RXTX_LEN. See the following piece of code.
Umm... what do you mean with SPI flash?
The "eeprom*" commands are intended to access EEPROM devices; for me, EEPROM and flash memory are two different things. Maybe you can explain what you are talking about?
The following patch fixes this issue.
Please also explain what "the issue" is? What exactly is not working as intended?
Best regards,
Wolfgang Denk

On 3/23/07, Wolfgang Denk wd@denx.de wrote:
In message 27d85ee10703220240i7f783984u6dcf6ff0da79a25f@mail.gmail.com you wrote:
When the functions "eeprom_read" and "eeprom_write" works for the SPI flash, the data length is limited to I2C_RXTX_LEN. See the following piece of code.
Umm... what do you mean with SPI flash?
The "eeprom*" commands are intended to access EEPROM devices; for me, EEPROM and flash memory are two different things. Maybe you can explain what you are talking about?
The part number of the chip is M25P64, which is a serial flash memory with SPI bus interface, since this flash and parallel NOR flash can work at the same time on our board, I think using "eeprom*" commands is correct for this kind of flash.
The following patch fixes this issue.
Please also explain what "the issue" is? What exactly is not working as intended?
If I want to write kernel image to the SPI flash, I do the following steppes: 1) tftpboot 0x1000000 uImage
2) eeprom write 0x1000000 0x100000 $(filesize)
Here I encountered the problem, the length passed to the spi_write() function is the kernel image size, far bigger than the macro I2C_RXTX_LEN. So eeprom write doesn't work properly as intended. The patch can fix it. IMHO, when we do the spi operation, we shouldn't limit the data length to a I2C macro.
Best Regards, -Aubrey

On 3/22/07, Aubrey Li aubrey.adi@gmail.com wrote:
When the functions "eeprom_read" and "eeprom_write" works for the SPI flash, the data length is limited to I2C_RXTX_LEN. See the following piece of code.
#if !defined(CFG_I2C_FRAM) maxlen = 0x100 - blk_off; if (maxlen > I2C_RXTX_LEN) maxlen = I2C_RXTX_LEN;
if (len > maxlen) len = maxlen;
#endif
The following patch fixes this issue.
From 2451cc87059acc456597a28f802ab3acb2d61ad4 Mon Sep 17 00:00:00 2001 From: Aubrey Li aubrey.adi@gmail.com Date: Thu, 22 Mar 2007 17:26:27 +0800 Subject: [PATCH] Fix spi read/write length issue
Signed-off-by: Aubrey Li aubrey.adi@gmail.com
common/cmd_eeprom.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c index d15a412..71d9792 100644 --- a/common/cmd_eeprom.c +++ b/common/cmd_eeprom.c @@ -177,10 +177,14 @@ int eeprom_read (unsigned dev_addr, unsi maxlen = 0x100 - blk_off; if (maxlen > I2C_RXTX_LEN) maxlen = I2C_RXTX_LEN;
+#ifndef CONFIG_SPI if (len > maxlen) len = maxlen; #endif
+#endif
#ifdef CONFIG_SPI spi_read (addr, alen, buffer, len); #else @@ -273,10 +277,13 @@ int eeprom_write (unsigned dev_addr, uns if (maxlen > I2C_RXTX_LEN) maxlen = I2C_RXTX_LEN;
+#ifndef CONFIG_SPI if (len > maxlen) len = maxlen; #endif
+#endif
#ifdef CONFIG_SPI spi_write (addr, alen, buffer, len);
#else
1.4.4
Best Regards, -Aubrey
Just want to know the status of this patch, thanks!
Best Regards, -Aubrey
participants (2)
-
Aubrey Li
-
Wolfgang Denk