[U-Boot-Users] Little Endian Flash

The attached patch fixes CFI flash writes for little endian systems.
Ed Okerson

In message Pine.LNX.4.44.0403032205330.14523-200000@dallas.texasconnect.net you wrote:
The attached patch fixes CFI flash writes for little endian systems.
Did you test this on 32 or 64 bit systems?
case FLASH_CFI_32BIT: + #if defined(__LITTLE_ENDIAN) + l = c; + l <<= 24; + cword->l = (cword->l >> 8) | l; + #else cword->l = (cword->l << 8) | c; + #endif break; case FLASH_CFI_64BIT: + #if defined(__LITTLE_ENDIAN) + ll = c; + ll <<= 56; + cword->ll = (cword->ll >> 8) | ll; + #else cword->ll = (cword->ll << 8) | c; + #endif
I don't think that this correctly swaps 32 or 64 bit data.
Best regards,
Wolfgang Denk

Wolfgang,
The intent is not to swap data. This function shifts data in one byte at a time. Without the patch the data is shifted in on the wrong end of the buffer for little endian systems.
Ed Okerson
On Thu, 4 Mar 2004, Wolfgang Denk wrote:
In message Pine.LNX.4.44.0403032205330.14523-200000@dallas.texasconnect.net you wrote:
The attached patch fixes CFI flash writes for little endian systems.
Did you test this on 32 or 64 bit systems?
case FLASH_CFI_32BIT:
- #if defined(__LITTLE_ENDIAN)
l = c;
l <<= 24;
cword->l = (cword->l >> 8) | l;
- #else cword->l = (cword->l << 8) | c;
- #endif break; case FLASH_CFI_64BIT:
- #if defined(__LITTLE_ENDIAN)
ll = c;
ll <<= 56;
cword->ll = (cword->ll >> 8) | ll;
- #else cword->ll = (cword->ll << 8) | c;
- #endif
I don't think that this correctly swaps 32 or 64 bit data.
Best regards,
Wolfgang Denk
-- Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de "An organization dries up if you don't challenge it with growth." - Mark Shepherd, former President and CEO of Texas Instruments

In message Pine.LNX.4.44.0403040847360.14523-100000@dallas.texasconnect.net you wrote:
The intent is not to swap data. This function shifts data in one byte at a time. Without the patch the data is shifted in on the wrong end of the buffer for little endian systems.
I see. Thanks, I'll check in the patch now.
Best regards,
Wolfgang Denk
participants (2)
-
Ed Okerson
-
Wolfgang Denk