From: Bill Pringlemeir <bpringlemeir@nbsps.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] arm: build arch memset/memcpy in Thumb2 mode
Date: Wed, 03 Dec 2014 10:44:41 -0500 [thread overview]
Message-ID: <87iohsvity.fsf@nbsps.com> (raw)
In-Reply-To: 1416584058-24595-1-git-send-email-stefan@agner.ch
I tested these changes on several compilers and binutils. 4.3.3, 4.6.3,
4.7.2, 4.8.2 and 4.9.2 gcc with binutils 2.19, 2.21-24 in both THUMB and
ARM on the Vybrid. It seem we must have an image <= 224kB which is the
IRAM bank0 size - 0x8000 of u-boot base; u-boot since v2014.04 will not
boot for me as the QSPI seemed to take it over this boundary.
The attached patches are meant to be attached as they aren't meant to be
taken by patchworks, etc but just to show the small changes I made to
minimize the image to less than 224kB.
[build script]
# File sizes similar because of 'mkimage' padding+hdr for 'imx'.
# 2nd size is for the 'thumb2' builds.
set -e
## (Sourcery CodeBench Lite 2012.03-56) 4.6.3
## (Sourcery CodeBench Lite 2012.03-56) 2.21.53.20110905
# 227092 Dec 1 15:20 u-boot.imx
# 173844 Dec 1 15:36 u-boot.imx
export PATH=$PATH:$HOME/x-tools/arm-2012.03/bin
## 4.7.4 20130913 (release) [ARM/embedded-4_7-branch revision 202601]
## GNU assembler (GNU Binutils) 2.23.2
# 222996 Dec 1 15:19 u-boot.imx
# 173844 Dec 1 15:35 u-boot.imx
#export PATH=$PATH:$HOME/x-tools/arm-2013.q3/bin
## (crosstool-NG hg+default-9838aecd6340) 4.8.2
## (GNU Binutils) 2.23.2
# 222996 Dec 1 15:18 u-boot.imx
# 173844 Dec 1 15:34 u-boot.imx
#export PATH=$PATH:$HOME/x-tools/arm-none-eabi/bin
## (Sourcery G++ Lite 2009q1-161) 4.3.3
## (Sourcery G++ Lite 2009q1-161) 2.19.51.20090205
# 218900 Dec 1 15:17 u-boot.imx - no CONFIG_SYS_LONGHELP
# GCC does not produce working THUMB binaries.
#export PATH=$PATH:/opt/arm-2009q1/bin
NAME=arm-none-eabi-
## (crosstool-NG 1.20.0) 4.9.2
## (crosstool-NG 1.20.0) 2.24
# 222996 Dec 1 15:21 u-boot.imx
# 173844 Dec 1 15:32 u-boot.imx
#export PATH=$PATH:$HOME/x-tools/arm-none-linux-gnueabi-vybrid-4.9.2/bin/
## (crosstool-NG hg+default-2a773bd38e71) 4.7.3
## (crosstool-NG hg+default-2a773bd38e71) 2.22
# 222996 Dec 1 15:22 u-boot.imx
# 173844 Dec 1 15:31 u-boot.imx
#export PATH=$PATH:$HOME/x-tools/arm-none-linux-gnueabi-4.7.2/bin
## (crosstool-NG hg+-c7fa97debb36) 4.6.3
## (crosstool-NG hg+-c7fa97debb36) 2.21.1
# 227092 Dec 1 15:24 u-boot.imx
# 173844 Dec 1 15:30 u-boot.imx
#export PATH=$PATH:$HOME/x-tools/arm-none-linux-gnueabi.gcc4.6.3/bin
#NAME=arm-none-linux-gnueabi-
## (Timesys 20130708) 4.7.3
## (Timesys 20130708) 2.23.2
# 227092 Dec 1 15:25 u-boot.imx
# 173844 Dec 1 15:29 u-boot.imx
#export PATH=$PATH:$HOME/x-tools/armv7l-timesys-linux-gnueabi/bin
#NAME=armv7l-timesys-linux-gnueabi-
## (crosstool-NG linaro-1.13.1-4.8-2013.10 - Linaro GCC 2013.10) 4.8.2 20131014
## (crosstool-NG linaro-1.13.1-4.8-2013.10 - Linaro GCC 2013.10) 2.23.2.20130610 Linaro 2013.10-4
# 222996 Dec 1 15:26 u-boot.imx
# 173844 Dec 1 15:28 u-boot.imx
#export PATH=$PATH:$HOME/x-tools/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin
#NAME=arm-linux-gnueabihf-
make CROSS_COMPILE=$NAME vf610twr_config
make CROSS_COMPILE=$NAME $* u-boot.imx
cp u-boot.imx /srv/tftp
[end script]
I applied Stefan's memcpy/thumb patch, reverted c6150aaf and applied
'fs/ext4/ext4fs.c, fs/fs.c fs/fat/fat_write.c: Adjust 64bit math
methods' by Tom Rini <trini@ti.com> (it has a little whitespace fat in
it). All of the images booted on a Vybrid Tower (Rev H) from an SD
card. Only issue is that I think the 'AFLAGS_NOWARN' can be removed as
per below...
On 21 Nov 2014, stefan at agner.ch wrote:
> Resynchronize memcpy/memset with kernel and build them explicitly
> in Thumb2 mode (unified syntax). Those assembler files can be
> built and linked in ARM mode too, however when calling them from
> Thumb2 built code, the stack got corrupted and the copy did not
> succeed (the exact details have not been traced back). Hoever,
> the Linux kernel builds those files in Thumb2 mode. Hence U-Boot
> should build them in Thumb2 mode too when CONFIG_SYS_THUMB_BUILD
> is set.
> To build the files without warning, some assembler instructions
> had to be replaced with their UAL compliant variant (thanks
> Jeroen for this input).
> To build the file in Thumb2 mode the implicit-it=always option need
> to be set to generate Thumb2 compliant IT instructions where needed.
> We add this option to the general AFLAGS when building for Thumb2.
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
> Changes since v1: - Don't set auto-it in AFLAGS - Removed
> "no-warn-deprecated" warning suppression - Converted non-UAL assembler
> instructions to their UAL compliant variants
> Tested in ARM and Thumb2 mode on Vybrid SoC. Disassembled the memset/
> memcpy object files before and after converting the instructions to
> UAL, the output was identical.
>
> arch/arm/config.mk | 4 +- arch/arm/include/asm/assembler.h | 33
> ++++++++++-- arch/arm/lib/memcpy.S | 80 +++++++++++++++++++---------
> arch/arm/lib/memset.S | 112 ++++++++++++++++++++------------------- 4
> files changed, 142 insertions(+), 87 deletions(-)
>
> diff --git a/arch/arm/config.mk b/arch/arm/config.mk
> index f0eafd6..14f4e9f 100644
> --- a/arch/arm/config.mk
> +++ b/arch/arm/config.mk
> @@ -26,7 +26,9 @@ PLATFORM_CPPFLAGS += -D__ARM__
>
> # Choose between ARM/Thumb instruction sets ifeq
> ($(CONFIG_SYS_THUMB_BUILD),y) -PF_CPPFLAGS_ARM := $(call cc-option,
> -mthumb -mthumb-interwork,\ +AFLAGS_IMPLICIT_IT := $(call
> as-option,-Wa$(comma)-mimplicit-it=always) +PF_CPPFLAGS_ARM :=
> $(AFLAGS_IMPLICIT_IT) $(AFLAGS_NOWARN) \ + $(call cc-option, -mthumb
I don't think we need the '$(AFLAGS_NOWARN)' as you fixed that? I
removed it during my tests and didn't see anything. Especially all
builds produced output. I guess this is copy/paste from a Linux
Makefile as I don't even see where it is set in U-Boot.
> -mthumb-interwork,\ $(call cc-option,-marm,)\ $(call
> cc-option,-mno-thumb-interwork,)\ ) diff --git
> a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
> index 5e4789b..11b80fb 100644 --- a/arch/arm/include/asm/assembler.h
> +++ b/arch/arm/include/asm/assembler.h @@ -14,12 +14,14 @@ * assembler
> source. */
[snip]
Tested-by: Bill Pringlemeir <bpringlemeir@nbsps.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: thumb-mode.patch
Type: text/x-diff
Size: 1155 bytes
Desc: patches to 2015.01-rc2
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141203/fdc2d39f/attachment.patch>
next prev parent reply other threads:[~2014-12-03 15:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-21 15:34 [U-Boot] [PATCH v2] arm: build arch memset/memcpy in Thumb2 mode Stefan Agner
2014-11-27 23:02 ` Stefan Agner
2014-11-30 19:33 ` Simon Glass
2014-11-30 20:07 ` Stefan Agner
2014-12-03 15:44 ` Bill Pringlemeir [this message]
2014-12-03 17:04 ` Stefan Agner
2014-12-15 14:24 ` Andreas Färber
2014-12-15 21:06 ` Stefan Agner
2014-12-18 15:39 ` Albert ARIBAUD
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=87iohsvity.fsf@nbsps.com \
--to=bpringlemeir@nbsps.com \
--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