[U-Boot] [PATCH] [mips] add $(ENDIANNESS) option when link hello_world example

Xiangfu Liu
2010-07-26T15:06:02Z

Hi Shinya

thanks for the links and patch.
comment inline :)

On 07/21/2010 10:08 PM, Shinya Kuribayashi wrote:
> Little endian build is one of the outstanding issues for MIPS ports[1].
>
> There are several technical issues, 1) lack of powerful configration
> infrastructure (it's drastically improved these days, so not a problem
> any more), 2) *LDFLAGS things are not propageted throughout the build
> system properly, especially through examples/standalone (it seems this
> issue is also addressed via distributed STANDALONE_LOAD_ADDR). Or in
> some cases, 3) you might want to generate u-boot image with different
> endiannness from toolchain's default (native build vs. non-native).
> And finally 4) ELDK toolchains vs. non-ELDK tools issues. As for #4,
> you'll see troublesome -dumpspecs outputs from ELDK toolchain[2].
>
> [1] http://search.gmane.org/?query=mips+little+endian&group=gmane.comp.boot-loaders.u-boot
> [2] http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/31998
>
> Anyway, to move discussion forward we need to sort out what's the most
> priority, what's next, what's nice to have, and what's not.

what about split this patch to two:
one is all *.lds files,
the other one is for the argument,

>
> +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
> +

I have one question here. if we decete the board cpu by CONFIG_CPU_LITTLE_ENDIAN.
why we need check the toolchina again. what about just like this? :

+PLATFORM_CPPFLAGS += -$(UNDEF_ALL)
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+PLATFORM_CPPFLAGS += -EL $(PREDEF_LE))
+PLATFORM_LDFLAGS += -EL
+else
+PLATFORM_CPPFLAGS += -EB $(PREDEF_BE))
+PLATFORM_LDFLAGS += -EB
+endif
+

the original U-Boot is detect -EL/-EB by toolchain name. maybe the
CONFIG_CPU_LITTLE_ENDIAN option is better.

this will not broken the ELDK compile.

Hi Shinya
I will try to make those two patch tomorrow. test, then send again.
what do you think. do you have any advice to me? :)

> +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/board/dbau1x00/u-boot.lds b/board/dbau1x00/u-boot.lds
> index 9a6cd1b..3c4fbe3 100644
> --- a/board/dbau1x00/u-boot.lds
> +++ b/board/dbau1x00/u-boot.lds
> @@ -24,7 +24,7 @@
> /*
> OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips")
> */
> -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips")
> +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
> OUTPUT_ARCH(mips)
> ENTRY(_start)
> SECTIONS
> diff --git a/board/gth2/u-boot.lds b/board/gth2/u-boot.lds
> index e6eee9b..aeb0fcc 100644
> --- a/board/gth2/u-boot.lds
> +++ b/board/gth2/u-boot.lds
> @@ -24,7 +24,7 @@
> /*
> OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips")
> */
> -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips")
> +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
> OUTPUT_ARCH(mips)
> ENTRY(_start)
> SECTIONS
> diff --git a/board/incaip/u-boot.lds b/board/incaip/u-boot.lds
> index 9a6cd1b..3c4fbe3 100644
> --- a/board/incaip/u-boot.lds
> +++ b/board/incaip/u-boot.lds
> @@ -24,7 +24,7 @@
> /*
> OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips")
> */
> -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips")
> +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
> OUTPUT_ARCH(mips)
> ENTRY(_start)
> SECTIONS
> diff --git a/board/pb1x00/u-boot.lds b/board/pb1x00/u-boot.lds
> index 9a6cd1b..3c4fbe3 100644
> --- a/board/pb1x00/u-boot.lds
> +++ b/board/pb1x00/u-boot.lds
> @@ -24,7 +24,7 @@
> /*
> OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips")
> */
> -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips")
> +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
> OUTPUT_ARCH(mips)
> ENTRY(_start)
> SECTIONS
> diff --git a/board/purple/u-boot.lds b/board/purple/u-boot.lds
> index 1881e65..542601a 100644
> --- a/board/purple/u-boot.lds
> +++ b/board/purple/u-boot.lds
> @@ -24,7 +24,7 @@
> /*
> OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips")
> */
> -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips")
> +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
> OUTPUT_ARCH(mips)
> ENTRY(_start)
> SECTIONS
> diff --git a/board/qemu-mips/u-boot.lds b/board/qemu-mips/u-boot.lds
> index ad058ca..bd16786 100644
> --- a/board/qemu-mips/u-boot.lds
> +++ b/board/qemu-mips/u-boot.lds
> @@ -24,7 +24,7 @@
> /*
> OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips")
> */
> -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips")
> +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
> OUTPUT_ARCH(mips)
> ENTRY(_start)
> SECTIONS
> diff --git a/examples/standalone/mips.lds b/examples/standalone/mips.lds
> index 717b201..63a1c92 100644
> --- a/examples/standalone/mips.lds
> +++ b/examples/standalone/mips.lds
> @@ -24,7 +24,7 @@
> /*
> OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips")
> */
> -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips")
> +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips")
> OUTPUT_ARCH(mips)
> SECTIONS
> {
> 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 */

--
Best Regards
Xiangfu Liu