public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: xiangfu at openmobilefree.net <xiangfu@openmobilefree.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] change the way of build little endian board
Date: Mon,  9 Aug 2010 23:13:44 +0800	[thread overview]
Message-ID: <4c601b39.092d730a.41d1.66e6@mx.google.com> (raw)
In-Reply-To: <1281366824-18811-2-git-send-email-y>

add CONFIG_CPU_LITTLE_ENDIAN to little endian board config.
use -dumpmachine to check if the cross compile.

Signed-off-by: Xiangfu Liu <xiangfu@openmobilefree.net>
Acked-by: Shinya Kuribayashi <skuribay@pobox.com>

---
 Makefile                 |    1 +
 arch/mips/config.mk      |   27 +++++++++++++++++++++++++--
 arch/mips/cpu/config.mk  |    8 --------
 include/configs/pb1x00.h |    2 ++
 4 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 451ccdd..47b5622 100644
--- a/Makefile
+++ b/Makefile
@@ -2306,6 +2306,7 @@ dbau1550_config		:	unconfig
 dbau1550_el_config	:	unconfig
 	@mkdir -p $(obj)include
 	@echo "#define CONFIG_DBAU1550 1" >$(obj)include/config.h
+	@echo "#define CONFIG_CPU_LITTLE_ENDIAN" >>$(obj)include/config.h
 	@$(MKCONFIG) -a dbau1x00 mips mips dbau1x00
 
 gth2_config		:	unconfig
diff --git a/arch/mips/config.mk b/arch/mips/config.mk
index aa06761..f5d9ac5 100644
--- a/arch/mips/config.mk
+++ b/arch/mips/config.mk
@@ -23,8 +23,6 @@
 
 CROSS_COMPILE ?= mips_4KC-
 
-STANDALONE_LOAD_ADDR = 0x80200000 -T mips.lds
-
 PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
 
 #
@@ -50,3 +48,28 @@ PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
 PLATFORM_CPPFLAGS		+= -G 0 -mabicalls -fpic
 PLATFORM_CPPFLAGS		+= -msoft-float
 PLATFORM_LDFLAGS		+= -G 0 -static -n -nostdlib
+
+#
+# We explicitly add the endianness specifier if needed, this allows
+# to compile kernels with a toolchain for the other endianness. We
+# carefully avoid to add it redundantly because gcc 3.3/3.4 complains
+# when fed the toolchain default!
+#
+# Certain gcc versions upto gcc 4.1.1 (probably 4.2-subversion as of
+# 2006-10-10 don't properly change the predefined symbols if -EB / -EL
+# are used, so we kludge that here.  A bug has been filed at
+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29413.
+#
+UNDEF_ALL += -UMIPSEB -U_MIPSEB -U__MIPSEB -U__MIPSEB__
+UNDEF_ALL += -UMIPSEL -U_MIPSEL -U__MIPSEL -U__MIPSEL__
+PREDEF_BE += -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__
+PREDEF_LE += -DMIPSEL -D_MIPSEL -D__MIPSEL -D__MIPSEL__
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+PLATFORM_CPPFLAGS	+= $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL $(UNDEF_ALL) $(PREDEF_LE))
+PLATFORM_LDFLAGS	+= -EL
+else
+PLATFORM_CPPFLAGS	+= $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB $(UNDEF_ALL) $(PREDEF_BE))
+PLATFORM_LDFLAGS	+= -EB
+endif
+
+STANDALONE_LOAD_ADDR = 0x80200000 -T mips.lds $(PLATFORM_LDFLAGS)
diff --git a/arch/mips/cpu/config.mk b/arch/mips/cpu/config.mk
index a173c54..098d6c7 100644
--- a/arch/mips/cpu/config.mk
+++ b/arch/mips/cpu/config.mk
@@ -28,12 +28,4 @@ else \
 	echo "-march=4kc -mtune=4kc"; \
 fi)
 
-ifneq (,$(findstring 4KCle,$(CROSS_COMPILE)))
-ENDIANNESS = -EL
-else
-ENDIANNESS = -EB
-endif
-
-MIPSFLAGS += $(ENDIANNESS)
-
 PLATFORM_CPPFLAGS += $(MIPSFLAGS)
diff --git a/include/configs/pb1x00.h b/include/configs/pb1x00.h
index 5ad745e..49ca07c 100644
--- a/include/configs/pb1x00.h
+++ b/include/configs/pb1x00.h
@@ -28,6 +28,8 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
+#define CONFIG_CPU_LITTLE_ENDIAN
+
 #define CONFIG_MIPS32		1  /* MIPS32 CPU core	*/
 #define CONFIG_PB1X00		1
 #define CONFIG_SOC_AU1X00	1  /* alchemy series cpu */
-- 
1.7.0.4

  parent reply	other threads:[~2010-08-09 15:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1281366824-18811-1-git-send-email-y>
2010-08-09 15:13 ` [U-Boot] [PATCH 1/2] update the MIPS u-boot.lds xiangfu at openmobilefree.net
     [not found] ` <1281366824-18811-2-git-send-email-y>
2010-08-09 15:13   ` xiangfu at openmobilefree.net [this message]
2010-08-09 17:10     ` [U-Boot] [PATCH 2/2] change the way of build little endian board Mike Frysinger
2010-08-10  1:30       ` Xiangfu Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c601b39.092d730a.41d1.66e6@mx.google.com \
    --to=xiangfu@openmobilefree.net \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox