[U-Boot-Users] Big endian-ness - Config option?

G'Day,
Feel free to harsh me if I've got this wrong. (I'm writing this so I don't get harshed when I submit my patch).
I've just borrowed the code from the sixnet board for talking to 28F320C3 flash chips (advanced boot sector, yada, yada) which was written by Wolfgang at some point. Its dropped in very nicely and works very well (once I'd worked out what i was doing).
I've had two problems. The first has been that that the code uses the get_timer(x) function, which is not implemented properly on ARM. (It just returns the value of the OS counter, ignoring the value passed to it. I had to replace the get_timer stuff with get_timer_masked and reset_timer_masked. I could try fixing the arm implementation of get_timer, but figured you guys wouldn't want me touching that bit of code since other bits and pieces now depend on it. Is there some way of doing this nicely?
The second was that one part of the code munges some bytes into a word to get them ready for writing. This is broken with respect to endian-ness, and breaks on my XScale running in little-endian mode. Is it possible (or appropriate?) to add a CFG_LITTLE_ENDIAN (or something similar)? Is there a better way of switching between the two? It would be nice if this code could be re-used without these sorts of problems.
Cheers,
Dave.
- David Snowdon PhD Student National ICT Australia (NICTA) Phone: 9385 7355 Email: daves@cse.unsw.edu.au

In message 637EA992-FC18-11D8-9008-000393C7979E@student.unsw.edu.au you wrote:
I've had two problems. The first has been that that the code uses the get_timer(x) function, which is not implemented properly on ARM. (It
Indeed, it seems to be broken.
just returns the value of the OS counter, ignoring the value passed to it. I had to replace the get_timer stuff with get_timer_masked and reset_timer_masked. I could try fixing the arm implementation of get_timer, but figured you guys wouldn't want me touching that bit of code since other bits and pieces now depend on it. Is there some way of doing this nicely?
There should be no software depending on the broken behaviour. If there was any, it must be fixed, too.
The second was that one part of the code munges some bytes into a word to get them ready for writing. This is broken with respect to endian-ness, and breaks on my XScale running in little-endian mode. Is it possible (or appropriate?) to add a CFG_LITTLE_ENDIAN (or something similar)? Is there a better way of switching between the two? It would be nice if this code could be re-used without these sorts of problems.
If you use code from a board directory, no such endianess support is needed, as the board will normally not change endianness (at least I don't know of any of the supported boards which can be configured both for BE or LE).
Endianess is considered an issue only in case you're using a generic driver (like drivers/cfi_flash.*); but AFAIK the cfi_flash code already deals properly with the target byteorder.
Best regards,
Wolfgang Denk

On Wed, 2004-09-01 at 15:26, Wolfgang Denk wrote:
If you use code from a board directory, no such endianess support is needed, as the board will normally not change endianness (at least I don't know of any of the supported boards which can be configured both for BE or LE).
</lurk-mode>
Hi
My port to the AMD Dbau1550 board (I think I may have time to clean it up and submit patches in a couple of weeks) was done for little endian mode. The other Dbau1xx0 boards were all supported in big endian mode (mips works both ways, and these boards when running Yamon can be switched between them with a dip switch scanned at power-on).
To get around this (for linker scripts and such) I patched mkconfig to take an optional "$6", for putting "ENDIANESS = " to config.mk.
Since the patch is trivial, I'm including it below.
regards / Leif
---
--- u-boot-1.1.1/mkconfig Thu Jun 26 00:26:29 2003 +++ patch/mkconfig Thu Jun 17 17:51:53 2004 @@ -19,7 +19,7 @@ while [ $# -gt 0 ] ; do done
[ $# -lt 4 ] && exit 1 -[ $# -gt 5 ] && exit 1 +[ $# -gt 6 ] && exit 1
echo "Configuring for $1 board..."
@@ -46,6 +46,8 @@ echo "CPU = $3" >> config.mk echo "BOARD = $4" >> config.mk
[ "$5" ] && echo "VENDOR = $5" >> config.mk + +[ "$6" ] && echo "ENDIANESS = $6" >> config.mk
# # Create board specific header file

Dear Leif,
in message 1094050217.25543.24.camel@fortress you wrote:
To get around this (for linker scripts and such) I patched mkconfig to take an optional "$6", for putting "ENDIANESS = " to config.mk.
Since the patch is trivial, I'm including it below.
Since there is no code in U-Boot that uses this feature I reject this patch. Please (re-) submit it as soon as there is actually any code that needs it.
Best regards,
Wolfgang Denk
participants (3)
-
David Snowdon
-
Leif Lindholm
-
Wolfgang Denk