Make endianess of target CPU configurable. Use the new config
option for dbau1550_el and pb1000 boards.

Adapt linking of standalone applications to pass through
endianess options to LD.

Build tested with:
 - ELDK 4 mips_4KC- and mips4KCle
 - Sourcery CodeBench Lite 2011.03-93

With this patch all 26 MIPS boards can be compiled now in one step by
running "MAKEALL -a mips".

Signed-off-by: Daniel Schwierzeck <daniel.schwierz...@googlemail.com>
---
Changes for v2:
 - moved CONFIG_SYS_LITTLE_ENDIAN from boards.cfg to configs/pb1x00.h
 - fixed typo in comment
 - updated patch summary

Note:
qemu_mips and tb0229 boards are still broken.

Build result with Sourcery CodeBench Lite 2011.03-93:

~/devel/u-boot$ 
CROSS_COMPILE=/opt/codesourcery/mips-2011.03/bin/mips-linux-gnu- BUILD_NCPUS=2 
./MAKEALL -a mips
Configuring for dbau1000 - Board: dbau1x00, Options: DBAU1000
   text    data     bss     dec     hex filename
 120604    4390   16068  141062   22706 ./u-boot
Configuring for dbau1100 - Board: dbau1x00, Options: DBAU1100
   text    data     bss     dec     hex filename
 120604    4390   16068  141062   22706 ./u-boot
Configuring for dbau1500 - Board: dbau1x00, Options: DBAU1500
   text    data     bss     dec     hex filename
 120604    4390   16068  141062   22706 ./u-boot
Configuring for dbau1550 - Board: dbau1x00, Options: DBAU1550
   text    data     bss     dec     hex filename
 119148    4454   18732  142334   22bfe ./u-boot
Configuring for dbau1550_el - Board: dbau1x00, Options: 
DBAU1550,SYS_LITTLE_ENDIAN
   text    data     bss     dec     hex filename
 120316    4454   18732  143502   2308e ./u-boot
Configuring for gth2 board...
   text    data     bss     dec     hex filename
 113668    4390   13752  131810   202e2 ./u-boot
Configuring for incaip board...
   text    data     bss     dec     hex filename
 147500    5066   15676  168242   29132 ./u-boot
Configuring for incaip_100MHz - Board: incaip, Options: CPU_CLOCK_RATE=100000000
   text    data     bss     dec     hex filename
 147500    5066   15676  168242   29132 ./u-boot
Configuring for incaip_133MHz - Board: incaip, Options: CPU_CLOCK_RATE=133000000
   text    data     bss     dec     hex filename
 147500    5066   15676  168242   29132 ./u-boot
Configuring for incaip_150MHz - Board: incaip, Options: CPU_CLOCK_RATE=150000000
   text    data     bss     dec     hex filename
 147500    5066   15676  168242   29132 ./u-boot
Configuring for pb1000 - Board: pb1x00, Options: PB1000
   text    data     bss     dec     hex filename
 110084    5090   15896  131070   1fffe ./u-boot
Configuring for qemu_mips board...
net/libnet.o: In function `eth_halt':
(.text.eth_halt+0x0): multiple definition of `eth_halt'
drivers/net/libnet.o:/home/schwierd/devel/u-boot/drivers/net/ne2000_base.c:721: 
first defined here
net/libnet.o: In function `eth_rx':
(.text.eth_rx+0x0): multiple definition of `eth_rx'
drivers/net/libnet.o:/home/schwierd/devel/u-boot/drivers/net/ne2000_base.c:729: 
first defined here
net/libnet.o: In function `eth_init':
(.text.eth_init+0x0): multiple definition of `eth_init'
drivers/net/libnet.o:/home/schwierd/devel/u-boot/drivers/net/ne2000_base.c:668: 
first defined here
net/libnet.o: In function `eth_send':
(.text.eth_send+0x0): multiple definition of `eth_send'
drivers/net/libnet.o:/home/schwierd/devel/u-boot/drivers/net/ne2000_base.c:734: 
first defined here
make: *** [u-boot] Error 1
/opt/codesourcery/mips-2011.03/bin/mips-linux-gnu-size: './u-boot': No such file
Configuring for tb0229 board...
flash.c:27:24: fatal error: asm/ppc4xx.h: No such file or directory
compilation terminated.
make[1]: *** No rule to make target `.depend', needed by `_depend'.  Stop.
make: *** [depend] Error 2
/opt/codesourcery/mips-2011.03/bin/mips-linux-gnu-size: './u-boot': No such file
Configuring for vct_premium - Board: vct, Options: VCT_PREMIUM
   text    data     bss     dec     hex filename
 197880   12100  272852  482832   75e10 ./u-boot
Configuring for vct_premium_small - Board: vct, Options: 
VCT_PREMIUM,VCT_SMALL_IMAGE
board.c: In function 'board_init_r':
board.c:266:8: warning: unused variable 's'
   text    data     bss     dec     hex filename
  88104    3640   14372  106116   19e84 ./u-boot
Configuring for vct_premium_onenand - Board: vct, Options: 
VCT_PREMIUM,VCT_ONENAND
   text    data     bss     dec     hex filename
 292552   14564  274068  581184   8de40 ./u-boot
Configuring for vct_premium_onenand_small - Board: vct, Options: 
VCT_PREMIUM,VCT_ONENAND,VCT_SMALL_IMAGE
board.c: In function 'board_init_r':
board.c:266:8: warning: unused variable 's'
   text    data     bss     dec     hex filename
 181884    6056   15604  203544   31b18 ./u-boot
Configuring for vct_platinum - Board: vct, Options: VCT_PLATINUM
   text    data     bss     dec     hex filename
 197880   12100  272852  482832   75e10 ./u-boot
Configuring for vct_platinum_small - Board: vct, Options: 
VCT_PLATINUM,VCT_SMALL_IMAGE
board.c: In function 'board_init_r':
board.c:266:8: warning: unused variable 's'
   text    data     bss     dec     hex filename
  88104    3640   14372  106116   19e84 ./u-boot
Configuring for vct_platinum_onenand - Board: vct, Options: 
VCT_PLATINUM,VCT_ONENAND
   text    data     bss     dec     hex filename
 292552   14564  274068  581184   8de40 ./u-boot
Configuring for vct_platinum_onenand_small - Board: vct, Options: 
VCT_PLATINUM,VCT_ONENAND,VCT_SMALL_IMAGE
board.c: In function 'board_init_r':
board.c:266:8: warning: unused variable 's'
   text    data     bss     dec     hex filename
 181884    6056   15604  203544   31b18 ./u-boot
Configuring for vct_platinumavc - Board: vct, Options: VCT_PLATINUMAVC
board.c: In function 'board_init_r':
board.c:266:8: warning: unused variable 's'
   text    data     bss     dec     hex filename
 118196    4752   15576  138524   21d1c ./u-boot
Configuring for vct_platinumavc_small - Board: vct, Options: 
VCT_PLATINUMAVC,VCT_SMALL_IMAGE
board.c: In function 'board_init_r':
board.c:266:8: warning: unused variable 's'
   text    data     bss     dec     hex filename
  87608    3640   14372  105620   19c94 ./u-boot
Configuring for vct_platinumavc_onenand - Board: vct, Options: 
VCT_PLATINUMAVC,VCT_ONENAND
board.c: In function 'board_init_r':
board.c:266:8: warning: unused variable 's'
   text    data     bss     dec     hex filename
 213024    7212   16820  237056   39e00 ./u-boot
Configuring for vct_platinumavc_onenand_small - Board: vct, Options: 
VCT_PLATINUMAVC,VCT_ONENAND,VCT_SMALL_IMAGE
board.c: In function 'board_init_r':
board.c:266:8: warning: unused variable 's'
   text    data     bss     dec     hex filename
 181380    6056   15604  203040   31920 ./u-boot
Configuring for qi_lb60 board...
cpu.c: In function '_machine_restart':
cpu.c:65:2: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
cpu.c:65:2: warning: large integer implicitly truncated to unsigned type
board.c: In function 'board_init_r':
board.c:266:8: warning: unused variable 's'
timer.c: In function 'reset_timer_masked':
timer.c:37:2: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
timer.c: In function 'get_timer_masked':
timer.c:43:2: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
timer.c: In function 'timer_init':
timer.c:86:2: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
timer.c:88:2: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
timer.c:89:2: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
timer.c:90:2: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
qi_lb60.c: In function 'cpm_init':
qi_lb60.c:72:2: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
qi_lb60.c:84:2: warning: dereferencing type-punned pointer will break 
strict-aliasing rules
   text    data     bss     dec     hex filename
 123064    8304    2528  133896   20b08 ./u-boot

--------------------- SUMMARY ----------------------------
Boards compiled: 26
Boards with warnings or errors: 11 ( qemu_mips tb0229 vct_premium_small 
vct_premium_onenand_small vct_platinum_small vct_platinum_onenand_small 
vct_platinumavc vct_platinumavc_small vct_platinumavc_onenand 
vct_platinumavc_onenand_small qi_lb60 )
----------------------------------------------------------

 README                         |    6 ++++++
 arch/mips/cpu/mips32/config.mk |   21 +++++++++++++++------
 boards.cfg                     |    2 +-
 examples/standalone/Makefile   |    6 +++++-
 include/configs/pb1x00.h       |    2 ++
 5 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/README b/README
index 3ddec77..0e09842 100644
--- a/README
+++ b/README
@@ -374,6 +374,12 @@ The following options need to be configured:
                Defines the string to utilize when trying to match PCIe device
                tree nodes for the given platform.
 
+- Generic CPU options:
+               CONFIG_SYS_BIG_ENDIAN, CONFIG_SYS_LITTLE_ENDIAN
+
+               Defines the endianess of the CPU. Implementation of those
+               values is arch specific.
+
 - Intel Monahans options:
                CONFIG_SYS_MONAHANS_RUN_MODE_OSC_RATIO
 
diff --git a/arch/mips/cpu/mips32/config.mk b/arch/mips/cpu/mips32/config.mk
index 4d1b273..a1cd590 100644
--- a/arch/mips/cpu/mips32/config.mk
+++ b/arch/mips/cpu/mips32/config.mk
@@ -27,14 +27,23 @@
 # Note: Toolchains with binutils prior to v2.16
 # are no longer supported by U-Boot MIPS tree!
 #
-MIPSFLAGS = -march=mips32r2
+MIPSFLAGS := -march=mips32r2
 
+# Handle special prefix in ELDK 4.0 toolchain
 ifneq (,$(findstring 4KCle,$(CROSS_COMPILE)))
-ENDIANNESS = -EL
-else
-ENDIANNESS = -EB
+ENDIANNESS := -EL
 endif
 
-MIPSFLAGS += $(ENDIANNESS)
+ifdef CONFIG_SYS_LITTLE_ENDIAN
+ENDIANNESS := -EL
+endif
+
+ifdef CONFIG_SYS_BIG_ENDIAN
+ENDIANNESS := -EB
+endif
+
+# Default to EB if no endianess is configured
+ENDIANNESS ?= -EB
 
-PLATFORM_CPPFLAGS += $(MIPSFLAGS)
+PLATFORM_CPPFLAGS += $(MIPSFLAGS) $(ENDIANNESS)
+PLATFORM_LDFLAGS += $(ENDIANNESS)
diff --git a/boards.cfg b/boards.cfg
index b678547..e99fde6 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -323,7 +323,7 @@ dbau1000                     mips        mips32      
dbau1x00            -
 dbau1100                     mips        mips32      dbau1x00            -     
         au1x00      dbau1x00:DBAU1100
 dbau1500                     mips        mips32      dbau1x00            -     
         au1x00      dbau1x00:DBAU1500
 dbau1550                     mips        mips32      dbau1x00            -     
         au1x00      dbau1x00:DBAU1550
-dbau1550_el                  mips        mips32      dbau1x00            -     
         au1x00      dbau1x00:DBAU1550
+dbau1550_el                  mips        mips32      dbau1x00            -     
         au1x00      dbau1x00:DBAU1550,SYS_LITTLE_ENDIAN
 gth2                         mips        mips32      -                   -     
         au1x00
 incaip                       mips        mips32      incaip              -     
         incaip
 incaip_100MHz                mips        mips32      incaip              -     
         incaip      incaip:CPU_CLOCK_RATE=100000000
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index e23865b..8c9e4cf 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -88,6 +88,10 @@ endif
 CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder)
 CFLAGS += $(CFLAGS_NTR)
 
+# Pass through endianness settings in LDFLAGS to LD
+LDFLAGS_ENDIAN += $(filter -EB,$(LDFLAGS))
+LDFLAGS_ENDIAN += $(filter -EL,$(LDFLAGS))
+
 all:   $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
 
 #########################################################################
@@ -96,7 +100,7 @@ $(LIB):      $(obj).depend $(LIBOBJS)
 
 $(ELF):
 $(obj)%:       $(obj)%.o $(LIB)
-               $(LD) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
+               $(LD) $(LDFLAGS_ENDIAN) -g -Ttext 
$(CONFIG_STANDALONE_LOAD_ADDR) \
                        -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
                        -L$(gcclibdir) -lgcc
 
diff --git a/include/configs/pb1x00.h b/include/configs/pb1x00.h
index eea8ed3..d056884 100644
--- a/include/configs/pb1x00.h
+++ b/include/configs/pb1x00.h
@@ -46,6 +46,8 @@
 #endif
 #endif
 
+#define CONFIG_SYS_LITTLE_ENDIAN
+
 #define CONFIG_ETHADDR         DE:AD:BE:EF:01:01    /* Ethernet address */
 
 #define CONFIG_BOOTDELAY       2       /* autoboot after 2 seconds     */
-- 
1.7.8

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to