[U-Boot] [PATCH] arm: support Thumb-1 with CONFIG_SYS_THUMB_BUILD

Albert ARIBAUD albert.u.boot at aribaud.net
Sun Feb 1 03:55:36 CET 2015


When building a THumb-1-only target with CONFIG_SYS_THUMB_BUILD,
some files fail to build, most of the time because they include
mcr instructions, which only exist for Thumb-2.

Thos patch introduces a Kconfig option CONFIG_THUMB2 and uses
it to select between Thumb-2 and ARM mode for the aforementioned
files.

This code has been build-tested and run-tested on ED Mini V2,
both with U-Boot and SPL.

Signed-off-by: Albert ARIBAUD <albert.u.boot at aribaud.net>
---
 arch/arm/Kconfig                        |  4 ++++
 arch/arm/cpu/arm926ejs/Makefile         | 11 +++++++++++
 arch/arm/cpu/arm926ejs/orion5x/Makefile | 10 ++++++++++
 arch/arm/lib/Makefile                   | 11 +++++++++++
 examples/standalone/Makefile            | 10 ++++++++++
 include/configs/edminiv2.h              |  2 ++
 6 files changed, 48 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5eb1d03..264af8b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -10,6 +10,9 @@ config ARM64
 config HAS_VBAR
         bool
 
+config HAS_THUMB2
+        bool
+
 config CPU_ARM720T
         bool
 
@@ -32,6 +35,7 @@ config CPU_ARM1176
 config CPU_V7
         bool
         select HAS_VBAR
+        select HAS_THUMB2
 
 config CPU_PXA
         bool
diff --git a/arch/arm/cpu/arm926ejs/Makefile b/arch/arm/cpu/arm926ejs/Makefile
index adcea9f..721b478 100644
--- a/arch/arm/cpu/arm926ejs/Makefile
+++ b/arch/arm/cpu/arm926ejs/Makefile
@@ -28,3 +28,14 @@ obj-$(CONFIG_ORION5X) += orion5x/
 obj-$(CONFIG_PANTHEON) += pantheon/
 obj-$(if $(filter spear,$(SOC)),y) += spear/
 obj-$(CONFIG_ARCH_VERSATILE) += versatile/
+
+# some files can only build in ARM or THUMB2, not THUMB1
+
+ifdef CONFIG_SYS_THUMB_BUILD
+ifndef CONFIG_HAS_THUMB2
+
+CFLAGS_cpu.o := -marm
+CFLAGS_cache.o := -marm
+
+endif
+endif
diff --git a/arch/arm/cpu/arm926ejs/orion5x/Makefile b/arch/arm/cpu/arm926ejs/orion5x/Makefile
index 546ebcb..33dcad4 100644
--- a/arch/arm/cpu/arm926ejs/orion5x/Makefile
+++ b/arch/arm/cpu/arm926ejs/orion5x/Makefile
@@ -16,3 +16,13 @@ obj-y	+= timer.o
 ifndef CONFIG_SKIP_LOWLEVEL_INIT
 obj-y	+= lowlevel_init.o
 endif
+
+# some files can only build in ARM or THUMB2, not THUMB1
+
+ifdef CONFIG_SYS_THUMB_BUILD
+ifndef CONFIG_HAS_THUMB2
+
+CFLAGS_cpu.o := -marm
+
+endif
+endif
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index d74e4b8..4916f30 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -54,3 +54,14 @@ obj-$(CONFIG_DEBUG_LL)	+= debug.o
 ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
 extra-y	+= eabi_compat.o
 endif
+
+# some files can only build in ARM or THUMB2, not THUMB1
+
+ifdef CONFIG_SYS_THUMB_BUILD
+ifndef CONFIG_HAS_THUMB2
+
+CFLAGS_cache.o := -marm
+CFLAGS_cache-cp15.o := -marm
+
+endif
+endif
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index 0863a8c..5a6ae00 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -73,3 +73,13 @@ $(obj)/%.srec: $(obj)/% FORCE
 $(obj)/%.bin: OBJCOPYFLAGS := -O binary
 $(obj)/%.bin: $(obj)/% FORCE
 	$(call if_changed,objcopy)
+
+# some files can only build in ARM or THUMB2, not THUMB1
+
+ifdef CONFIG_SYS_THUMB_BUILD
+ifndef CONFIG_HAS_THUMB2
+
+CFLAGS_stubs.o := -marm
+
+endif
+endif
diff --git a/include/configs/edminiv2.h b/include/configs/edminiv2.h
index 70a698a..f07b0d9 100644
--- a/include/configs/edminiv2.h
+++ b/include/configs/edminiv2.h
@@ -12,6 +12,8 @@
 #ifndef _CONFIG_EDMINIV2_H
 #define _CONFIG_EDMINIV2_H
 
+#define CONFIG_SYS_THUMB_BUILD
+
 /*
  * Version number information
  */
-- 
2.1.0



More information about the U-Boot mailing list