[PATCH 2/8] arm: Disable unaligned accesses

Andrey Smirnov andrew.smirnov at gmail.com
Sun Oct 11 11:43:35 PDT 2015


Form reading ARM architecture related documentation if appears that
while unaligned memory access is supported by the processor in general
it is not supported if MMU is disabled.

The problem in question can be easilty reproduced by building the code
without this patch, MMU disabled, and trying to run 'memtest'
command. Which would in turn call mem_test() which would eventually
call show_progress(). That last function, if build without
-mno-unaligned-access would result in unaligned memory access which
would result in Barebox hanging.

This patch instructs the compiler to not generate any unaligned
accesses to memory thus avoiding the problem.

Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
---
 arch/arm/Makefile | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 721aa9b..cae05ff 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -13,6 +13,13 @@ AS		+= -EL
 LD		+= -EL
 endif

+# Unaligned access is not supported when MMU is disabled, so given how
+# at least some of the code would be executed with MMU off, lets be
+# conservative and instruct the compiler not to generate any unaligned
+# accesses
+CFLAGS += -mno-unaligned-access
+
+
 # This selects which instruction set is used.
 # Note that GCC does not numerically define an architecture version
 # macro, but instead defines a whole series of macros which makes
--
2.1.4



More information about the barebox mailing list