[PATCH 2/2] OMAP: disable unaligned access when building the IFT

Sascha Hauer s.hauer at pengutronix.de
Wed Dec 5 05:46:27 EST 2012


On Tue, Dec 04, 2012 at 01:02:49PM +0100, Enrico Scholz wrote:
> MLO is located in SRAM and OMAP4 does not allow unaligned access in
> this area:
> 
> | :/ md -w 0x40300000+2
> | 40300000: 9001                                               ..
> | :/ md -w 0x40300001+2
> | unable to handle paging request at address 0x40300001
> 
> Patch sets the ARM_NOUNALIGNED option introduced by a previous patch.
> 
> Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
> ---
>  arch/arm/mach-omap/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
> index 81f6127..445a35a 100644
> --- a/arch/arm/mach-omap/Kconfig
> +++ b/arch/arm/mach-omap/Kconfig
> @@ -68,6 +68,7 @@ config OMAP_GPMC
>  
>  config OMAP_BUILD_IFT
>  	prompt "build ift binary"
> +	select ARM_NOUNALIGNED

This needs more investigation. Coupling this to OMAP_BUILD_IFT does not
seem to be correct. Unaligned accesses work for cached memory once the MMU
is enabled, it won't work with MMU disabled though. In barebox MMU
support is optional and even when the MMU is enabled in the config parts
of the initialization run with MMU disabled.

This U-Boot commit shows what's going on:

> commit b823fd9ba56d56e3cbb5b05e7a4815fb0914204a
> Author: Albert ARIBAUD <albert.u.boot at aribaud.net>
> Date:   Tue Oct 9 09:28:15 2012 +0000
>     ARM: prevent misaligned array inits
>     
>     Under option -munaligned-access, gcc can perform local char
>     or 16-bit array initializations using misaligned native
>     accesses which will throw a data abort exception. Fix files
>     where these array initializations were unneeded, and for
>     files known to contain such initializations, enforce gcc
>     option -mno-unaligned-access.
>     
>     Signed-off-by: Albert ARIBAUD <albert.u.boot at aribaud.net>
>     [trini: Switch to usign call cc-option for -mno-unaligned-access as
>     Albert had done previously as that's really correct]
>     Signed-off-by: Tom Rini <trini at ti.com>
> 

This patch explicitely mentions char arrays initialized on the stack
like this:

function foo()
{
       char buffer[] = "initial value";
/* or */
       char buffer[] = { 'i', 'n', 'i', 't', 0 };
       ...
}

Is this the place where you see problems?

The U-Boot people work around this issue by converting the above to
const char *buffer = "initial value"; where possible and pass the
-mno-unaligned-access flag to files where this is not possible.

I really do not want to go the way to pass compiler flags to individual
files. Also the above is valid C code which should work.

barebox is written to not contain unaligned accesses, everything else
will fail on earlier ARM CPUs. I think we should pass the
-mno-unaligned-access unconditionally. Normally this will have no impact
as barebox doesn't do explicit unaligned accesses. For the rare cases
like the one above barebox should just work without having to pass
additional flags to files.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list