[U-Boot-Users] CFI conformant flash: REDUX

In a recent post I described a problem getting the common CFI flash driver in u-boot-1.2.0 to work with a pair of Spansion S29JL064H memory devices connected on parallel. After plodding through the CFI flash driver source code and conducting some experiments, the root cause of the problem was found to be an Endian problem. The flash on this particular board is wired little Endian. The processor on the board, an MPC8270, is big Endian.
The CFI flash driver source, drivers/cfi_flash.c, supports little ENDIAN when a preprocessor macro, __LITTLE_ENDIAN, is defined. As quick an dirty hack I uncommented the CFLAGS line in the drivers Makefile to enable debugging and added '-D__LITTLE_ENDIAN' to the CFLAGS list. This hack actually worked:
[from flinfo] Bank # 1: CFI conformant FLASH (32 x 16) Size: 16 MB in 142 Sectors AMD Standard command set, Manufacturer ID: 0x01, Device ID: 0x7E0201 Erase timeout: 8192 ms, write timeout: 1 ms
The driver makefile hack far is too encompassing, which leads to a question:
"Where is the right place to define this preprocessor macro definition?"
The board configuration header file is the obvious place. However, defining __LITTLE_ENDIAN in a the board configuration header file for a board with a big ENDIAN processor causes all sorts of michief. Changing the name of the __LITTLE_ENDIAN macro in drivers/cfi_flash.c to something less generic would also be a bad idea.
The following might be a workable approach. I have validated that it works on this particular board.
* in the board configuration header file
#define CFG_FLASH_LITTLE_ENDIAN
* in drivers/cfi_flash.c
--- u-boot-1.2.0/drivers/cfi_flash.c.orig 2007-10-26 14:36:00.060179333 -0400 +++ u-boot-1.2.0/drivers/cfi_flash.c 2007-10-26 15:18:01.485629019 -0400 @@ -56,6 +56,10 @@ * */
+#ifdef CFG_FLASH_LITTLE_ENDIAN +#define __LITTLE_ENDIAN +#endif + #ifndef CFG_FLASH_BANKS_LIST #define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE } #endif
Thoughts?
-Joseph
-- joseph_sacco [at] comcast [dot] net
participants (1)
-
joseph_saccoï¼ comcast.net