[U-Boot] [PATCH v3] MIPS: fix endianess handling
Daniel Schwierzeck
daniel.schwierzeck at googlemail.com
Sun Dec 11 17:53:11 CET 2011
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.schwierzeck at googlemail.com>
---
Changes for v3:
- rebased against current master
Changes for v2:
- moved CONFIG_SYS_LITTLE_ENDIAN from boards.cfg to configs/pb1x00.h
- fixed typo in comment
- updated patch summary
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 ff72e47..afcfc8f 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 a0a2bba..cbeba0c 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -348,7 +348,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
pb1000 mips mips32 pb1x00 - au1x00 pb1x00:PB1000
incaip mips mips32 incaip - incaip
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
More information about the U-Boot
mailing list