* [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7
@ 2011-03-14 13:27 Aneesh V
2011-03-14 13:27 ` [U-Boot] [RFC PATCH 2/2] OMAP4: enable Thumb2 support for OMAP4 Aneesh V
2011-03-14 16:11 ` [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7 Loïc Minier
0 siblings, 2 replies; 9+ messages in thread
From: Aneesh V @ 2011-03-14 13:27 UTC (permalink / raw)
To: u-boot
Signed-off-by: Aneesh V <aneesh@ti.com>
---
README | 9 +++++++++
arch/arm/cpu/armv7/config.mk | 5 +++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/README b/README
index f1547a4..ff3a345 100644
--- a/README
+++ b/README
@@ -370,6 +370,15 @@ The following options need to be configured:
2. The core frequency as calculated above is multiplied
by this value.
+- ARM Options:
+ CONFIG_SYS_THUMB_BUILD
+
+ Use this flag to build U-Boot using the Thumb instruction
+ set for ARM architectures. Thumb instruction set provides
+ better code density. For ARM architectures that support
+ Thumb2 this flag will result in Thumb2 code generated by
+ GCC.
+
- Linux Kernel Interface:
CONFIG_CLOCKS_IN_MHZ
diff --git a/arch/arm/cpu/armv7/config.mk b/arch/arm/cpu/armv7/config.mk
index 49ac9c7..b7bebad 100644
--- a/arch/arm/cpu/armv7/config.mk
+++ b/arch/arm/cpu/armv7/config.mk
@@ -31,3 +31,8 @@ PLATFORM_CPPFLAGS += -march=armv5
# =========================================================================
PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,\
$(call cc-option,-malignment-traps,))
+
+ifeq ($(CONFIG_SYS_THUMB_BUILD),y)
+# Enable Thumb mode build if compiler supports it
+PLATFORM_CPPFLAGS += $(call cc-option,-mthumb -mthumb-interwork)
+endif
--
1.7.0.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [RFC PATCH 2/2] OMAP4: enable Thumb2 support for OMAP4
2011-03-14 13:27 [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7 Aneesh V
@ 2011-03-14 13:27 ` Aneesh V
2011-03-14 16:11 ` [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7 Loïc Minier
1 sibling, 0 replies; 9+ messages in thread
From: Aneesh V @ 2011-03-14 13:27 UTC (permalink / raw)
To: u-boot
Enable -march=armv7-a and Thumb build for OMAP4. This results in
Thumb2 code generated for OMAP4.
The newly added compiler switches are put under cc-option so
that it doesn't break old compilers.
Signed-off-by: Aneesh V <aneesh@ti.com>
---
arch/arm/cpu/armv7/omap4/config.mk | 25 +++++++++++++++++++++++++
include/configs/omap4_sdp4430.h | 1 +
2 files changed, 26 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/cpu/armv7/omap4/config.mk
diff --git a/arch/arm/cpu/armv7/omap4/config.mk b/arch/arm/cpu/armv7/omap4/config.mk
new file mode 100644
index 0000000..a715ba3
--- /dev/null
+++ b/arch/arm/cpu/armv7/omap4/config.mk
@@ -0,0 +1,25 @@
+#
+# Copyright 2011 Linaro Limited
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# Aneesh V <aneesh.v@linaro.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+# Enable armv7 if the compiler supports it
+PLATFORM_CPPFLAGS += $(call cc-option,-march=armv7-a)
diff --git a/include/configs/omap4_sdp4430.h b/include/configs/omap4_sdp4430.h
index 48a3774..74f686b 100644
--- a/include/configs/omap4_sdp4430.h
+++ b/include/configs/omap4_sdp4430.h
@@ -266,4 +266,5 @@
#define CONFIG_SYS_SPL_BSS_START_ADDR 0x80000000
#define CONFIG_SYS_SPL_BSS_MAX_SIZE 0x80000 /* 512 KB */
+#define CONFIG_SYS_THUMB_BUILD
#endif /* __CONFIG_H */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7
2011-03-14 13:27 [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7 Aneesh V
2011-03-14 13:27 ` [U-Boot] [RFC PATCH 2/2] OMAP4: enable Thumb2 support for OMAP4 Aneesh V
@ 2011-03-14 16:11 ` Loïc Minier
2011-03-15 4:01 ` Aneesh V
1 sibling, 1 reply; 9+ messages in thread
From: Loïc Minier @ 2011-03-14 16:11 UTC (permalink / raw)
To: u-boot
On Mon, Mar 14, 2011, Aneesh V wrote:
> +- ARM Options:
> + CONFIG_SYS_THUMB_BUILD
> +
> + Use this flag to build U-Boot using the Thumb instruction
> + set for ARM architectures. Thumb instruction set provides
> + better code density. For ARM architectures that support
> + Thumb2 this flag will result in Thumb2 code generated by
> + GCC.
> +
> - Linux Kernel Interface:
> CONFIG_CLOCKS_IN_MHZ
>
The above README changes suggest that "Thumb-1" would also be possible
but you patch an armv7 file:
> --- a/arch/arm/cpu/armv7/config.mk
> +++ b/arch/arm/cpu/armv7/config.mk
so I suspect only armv7 CPUs would be affected? Consider patching
arch/arm/config.mk instead which is where -marm is currently set:
# Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
PLATFORM_CPPFLAGS += $(call cc-option,-marm,)
In fact, I would find it less confusing if the flags were -mthumb or
-marm and never -marm -mthumb, so you probably want to patch the code
setting -marm above to be in your "else" clause.
> @@ -31,3 +31,8 @@ PLATFORM_CPPFLAGS += -march=armv5
This suggests that u-boot is actually built in ARMv5 mode, which means
we're missing out actual Thumb-2 instructions (v6+).
Perhaps arch/arm/cpu/armv7/config.mk should also $(call
cc-option,-march=armv7). (I've never used -march=armv7 but it seems to
exist and is probably more correct than -march=armv7-a).
> # =========================================================================
> PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,\
> $(call cc-option,-malignment-traps,))
> +
> +ifeq ($(CONFIG_SYS_THUMB_BUILD),y)
> +# Enable Thumb mode build if compiler supports it
> +PLATFORM_CPPFLAGS += $(call cc-option,-mthumb -mthumb-interwork)
> +endif
> --
> 1.7.0.4
>
--
Lo?c Minier
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7
2011-03-14 16:11 ` [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7 Loïc Minier
@ 2011-03-15 4:01 ` Aneesh V
2011-03-15 11:54 ` Loïc Minier
0 siblings, 1 reply; 9+ messages in thread
From: Aneesh V @ 2011-03-15 4:01 UTC (permalink / raw)
To: u-boot
Loic,
On Monday 14 March 2011 09:41 PM, Lo?c Minier wrote:
> On Mon, Mar 14, 2011, Aneesh V wrote:
>> +- ARM Options:
>> + CONFIG_SYS_THUMB_BUILD
>> +
>> + Use this flag to build U-Boot using the Thumb instruction
>> + set for ARM architectures. Thumb instruction set provides
>> + better code density. For ARM architectures that support
>> + Thumb2 this flag will result in Thumb2 code generated by
>> + GCC.
>> +
>> - Linux Kernel Interface:
>> CONFIG_CLOCKS_IN_MHZ
>>
>
> The above README changes suggest that "Thumb-1" would also be possible
> but you patch an armv7 file:
>
>> --- a/arch/arm/cpu/armv7/config.mk
>> +++ b/arch/arm/cpu/armv7/config.mk
>
> so I suspect only armv7 CPUs would be affected? Consider patching
> arch/arm/config.mk instead which is where -marm is currently set:
> # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
> PLATFORM_CPPFLAGS += $(call cc-option,-marm,)
> In fact, I would find it less confusing if the flags were -mthumb or
> -marm and never -marm -mthumb, so you probably want to patch the code
> setting -marm above to be in your "else" clause.
I will do that. Thank you.
>
>> @@ -31,3 +31,8 @@ PLATFORM_CPPFLAGS += -march=armv5
>
> This suggests that u-boot is actually built in ARMv5 mode, which means
> we're missing out actual Thumb-2 instructions (v6+).
>
> Perhaps arch/arm/cpu/armv7/config.mk should also $(call
> cc-option,-march=armv7). (I've never used -march=armv7 but it seems to
> exist and is probably more correct than -march=armv7-a).
>
Please note that I am enabling armv7-a in the second patch in omap4
config.mk file. The reason I didn't do this here was some ARMv7 SoCs do
not want to use -march=armv7-a even if the compiler supports it. Tegra2
is an example. Please see the below from Tegra2 config.mk:
# Use ARMv4 for Tegra2 - initial code runs on the AVP, which is an ARM7TDI.
PLATFORM_CPPFLAGS += -march=armv4
This being the case I would have had to define another CONFIG flag if I
had to add -march=armv7-a in arch/arm/cpu/armv7/config.mk. I thought it
un-necessary and instead put it in the SoC specific file. So, Tegra2
can continue to use -march=armv4 and will get Thumb-1 if they enable
CONFIG_SYS_THUMB_BUILD. Or do you think we should define something like
CONFIG_SYS_MARCH_ARMV7
I will try -march=armv7, but I vaguely remember it had some issues.
>> # =========================================================================
>> PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,\
>> $(call cc-option,-malignment-traps,))
>> +
>> +ifeq ($(CONFIG_SYS_THUMB_BUILD),y)
>> +# Enable Thumb mode build if compiler supports it
>> +PLATFORM_CPPFLAGS += $(call cc-option,-mthumb -mthumb-interwork)
>> +endif
>> --
>> 1.7.0.4
>>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7
2011-03-15 4:01 ` Aneesh V
@ 2011-03-15 11:54 ` Loïc Minier
2011-03-16 8:39 ` Aneesh V
0 siblings, 1 reply; 9+ messages in thread
From: Loïc Minier @ 2011-03-15 11:54 UTC (permalink / raw)
To: u-boot
On Tue, Mar 15, 2011, Aneesh V wrote:
> Please note that I am enabling armv7-a in the second patch in omap4
> config.mk file. The reason I didn't do this here was some ARMv7 SoCs do
> not want to use -march=armv7-a even if the compiler supports it. Tegra2
> is an example. Please see the below from Tegra2 config.mk:
>
> # Use ARMv4 for Tegra2 - initial code runs on the AVP, which is an ARM7TDI.
> PLATFORM_CPPFLAGS += -march=armv4
Good point, I wonder whether it would make sense to have
arch/arm/cpu/armv7/config.mk default to -march=armv7 and Tegra2 to
override this with -march=armv4. Maybe this code doesn't belong under
armv7 though; or perhaps -march=armv4 should only be set when building
a subset of the files rather than by default.
> This being the case I would have had to define another CONFIG flag if I
> had to add -march=armv7-a in arch/arm/cpu/armv7/config.mk. I thought it
> un-necessary and instead put it in the SoC specific file. So, Tegra2
> can continue to use -march=armv4 and will get Thumb-1 if they enable
> CONFIG_SYS_THUMB_BUILD. Or do you think we should define something like
> CONFIG_SYS_MARCH_ARMV7
Up to you, but I would expect that code udner arch/arm/cpu/armv7/ would
build with -march=armv7 (maybe not -a though), with specific overrides
where that's not the case; it would feel a bit odd to me to have this
as a "config" option.
--
Lo?c Minier
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7
2011-03-15 11:54 ` Loïc Minier
@ 2011-03-16 8:39 ` Aneesh V
2011-03-16 17:25 ` Albert ARIBAUD
0 siblings, 1 reply; 9+ messages in thread
From: Aneesh V @ 2011-03-16 8:39 UTC (permalink / raw)
To: u-boot
On Tuesday 15 March 2011 05:24 PM, Lo?c Minier wrote:
> On Tue, Mar 15, 2011, Aneesh V wrote:
>> Please note that I am enabling armv7-a in the second patch in omap4
>> config.mk file. The reason I didn't do this here was some ARMv7 SoCs do
>> not want to use -march=armv7-a even if the compiler supports it. Tegra2
>> is an example. Please see the below from Tegra2 config.mk:
>>
>> # Use ARMv4 for Tegra2 - initial code runs on the AVP, which is an ARM7TDI.
>> PLATFORM_CPPFLAGS += -march=armv4
>
> Good point, I wonder whether it would make sense to have
> arch/arm/cpu/armv7/config.mk default to -march=armv7 and Tegra2 to
Sounds reasonable. I will do that.
> override this with -march=armv4. Maybe this code doesn't belong under
> armv7 though; or perhaps -march=armv4 should only be set when building
> a subset of the files rather than by default.
I don't understand it either. Maybe, the early boot code runs on one
processor and the rest run on another processor all in the same SoC.
>> This being the case I would have had to define another CONFIG flag if I
>> had to add -march=armv7-a in arch/arm/cpu/armv7/config.mk. I thought it
>> un-necessary and instead put it in the SoC specific file. So, Tegra2
>> can continue to use -march=armv4 and will get Thumb-1 if they enable
>> CONFIG_SYS_THUMB_BUILD. Or do you think we should define something like
>> CONFIG_SYS_MARCH_ARMV7
>
> Up to you, but I would expect that code udner arch/arm/cpu/armv7/ would
> build with -march=armv7 (maybe not -a though), with specific overrides
I tried -march=armv7 yesterday. I am getting several errors from the
assembly files. Particularly, it doesn't support high registers, spsr
etc. Looks like it defaults to the armv7-m variant(just my guess)
> where that's not the case; it would feel a bit odd to me to have this
> as a "config" option.
Yes, me too didn't like having a CONFIG option for this. But that
doesn't seem to be needed either as it can be over-ridden in the SoC
directory.
Albert,
Your thoughts on this?
best regards,
Aneesh
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7
2011-03-16 8:39 ` Aneesh V
@ 2011-03-16 17:25 ` Albert ARIBAUD
2011-03-17 7:30 ` Aneesh V
0 siblings, 1 reply; 9+ messages in thread
From: Albert ARIBAUD @ 2011-03-16 17:25 UTC (permalink / raw)
To: u-boot
Le 16/03/2011 09:39, Aneesh V a ?crit :
> On Tuesday 15 March 2011 05:24 PM, Lo?c Minier wrote:
>> On Tue, Mar 15, 2011, Aneesh V wrote:
>>> Please note that I am enabling armv7-a in the second patch in omap4
>>> config.mk file. The reason I didn't do this here was some ARMv7 SoCs do
>>> not want to use -march=armv7-a even if the compiler supports it. Tegra2
>>> is an example. Please see the below from Tegra2 config.mk:
>>>
>>> # Use ARMv4 for Tegra2 - initial code runs on the AVP, which is an
>>> ARM7TDI.
>>> PLATFORM_CPPFLAGS += -march=armv4
>>
>> Good point, I wonder whether it would make sense to have
>> arch/arm/cpu/armv7/config.mk default to -march=armv7 and Tegra2 to
>
> Sounds reasonable. I will do that.
>
>> override this with -march=armv4. Maybe this code doesn't belong under
>> armv7 though; or perhaps -march=armv4 should only be set when building
>> a subset of the files rather than by default.
>
> I don't understand it either. Maybe, the early boot code runs on one
> processor and the rest run on another processor all in the same SoC.
>
>>> This being the case I would have had to define another CONFIG flag if I
>>> had to add -march=armv7-a in arch/arm/cpu/armv7/config.mk. I thought it
>>> un-necessary and instead put it in the SoC specific file. So, Tegra2
>>> can continue to use -march=armv4 and will get Thumb-1 if they enable
>>> CONFIG_SYS_THUMB_BUILD. Or do you think we should define something like
>>> CONFIG_SYS_MARCH_ARMV7
>>
>> Up to you, but I would expect that code udner arch/arm/cpu/armv7/ would
>> build with -march=armv7 (maybe not -a though), with specific overrides
>
> I tried -march=armv7 yesterday. I am getting several errors from the
> assembly files. Particularly, it doesn't support high registers, spsr
> etc. Looks like it defaults to the armv7-m variant(just my guess)
>
>> where that's not the case; it would feel a bit odd to me to have this
>> as a "config" option.
>
> Yes, me too didn't like having a CONFIG option for this. But that
> doesn't seem to be needed either as it can be over-ridden in the SoC
> directory.
>
> Albert,
> Your thoughts on this?
Some toolchains in current use (notably the one provided with ELDK 4.2,
and possibly others) do not support -march=armv7[-a]. Do we really need
armv7 instructions?
> best regards,
> Aneesh
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7
2011-03-16 17:25 ` Albert ARIBAUD
@ 2011-03-17 7:30 ` Aneesh V
2011-03-24 14:45 ` Albert ARIBAUD
0 siblings, 1 reply; 9+ messages in thread
From: Aneesh V @ 2011-03-17 7:30 UTC (permalink / raw)
To: u-boot
Albert,
On Wednesday 16 March 2011 10:55 PM, Albert ARIBAUD wrote:
> Le 16/03/2011 09:39, Aneesh V a ?crit :
[snip ..]
>
> Some toolchains in current use (notably the one provided with ELDK 4.2,
> and possibly others) do not support -march=armv7[-a]. Do we really need
> armv7 instructions?
'cc-option' will make sure that build won't break for old compilers. We
can do something like this:
PLATFORM_CPPFLAGS += $(call cc-option,-march=armv7-a, -march=armv5)
We are not planning to use armv7-a instructions in the code. In fact,
recently I removed even an armv5 instruction from armv7 generic code in
the interest of not breaking Tegra2.
However, keeping -march=armv7-a (armv6 and above) helps in having
Thumb2, which I believe is a good compromise between code density and
performance.
So, OMAP4 U-Boot when built with ELDK will give you Thumb1 code where
as when it is built with newer compilers it will give you Thumb2 code.
As long we don't use non-compliant assembly instructions, both should
build and work fine.
br,
Aneesh
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7
2011-03-17 7:30 ` Aneesh V
@ 2011-03-24 14:45 ` Albert ARIBAUD
0 siblings, 0 replies; 9+ messages in thread
From: Albert ARIBAUD @ 2011-03-24 14:45 UTC (permalink / raw)
To: u-boot
Le 17/03/2011 08:30, Aneesh V a ?crit :
> Albert,
>
> On Wednesday 16 March 2011 10:55 PM, Albert ARIBAUD wrote:
>> Le 16/03/2011 09:39, Aneesh V a ?crit :
> [snip ..]
>>
>> Some toolchains in current use (notably the one provided with ELDK 4.2,
>> and possibly others) do not support -march=armv7[-a]. Do we really need
>> armv7 instructions?
>
> 'cc-option' will make sure that build won't break for old compilers. We
> can do something like this:
>
> PLATFORM_CPPFLAGS += $(call cc-option,-march=armv7-a, -march=armv5)
>
> We are not planning to use armv7-a instructions in the code. In fact,
> recently I removed even an armv5 instruction from armv7 generic code in
> the interest of not breaking Tegra2.
>
> However, keeping -march=armv7-a (armv6 and above) helps in having
> Thumb2, which I believe is a good compromise between code density and
> performance.
>
> So, OMAP4 U-Boot when built with ELDK will give you Thumb1 code where
> as when it is built with newer compilers it will give you Thumb2 code.
> As long we don't use non-compliant assembly instructions, both should
> build and work fine.
>
> br,
> Aneesh
Understood. As for the question about config options (assuming I got it
right) I'd rather have the SoC define which -march it wants, and only
have a CONFIG for saying if we want thumb or not.
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-03-24 14:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-14 13:27 [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7 Aneesh V
2011-03-14 13:27 ` [U-Boot] [RFC PATCH 2/2] OMAP4: enable Thumb2 support for OMAP4 Aneesh V
2011-03-14 16:11 ` [U-Boot] [RFC PATCH 1/2] armv7: enable Thumb build for armv7 Loïc Minier
2011-03-15 4:01 ` Aneesh V
2011-03-15 11:54 ` Loïc Minier
2011-03-16 8:39 ` Aneesh V
2011-03-16 17:25 ` Albert ARIBAUD
2011-03-17 7:30 ` Aneesh V
2011-03-24 14:45 ` Albert ARIBAUD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox