Seabright Technology Header Image

Kernel not booting with Linaro GCC?

Is your ARM Linux kernel not booting when building with Linaro GCC or FSF GCC 4.7? Does it halt shortly after showing ‘Uncompressing Linux’? You may have run into an interaction between older kernels and the new unaligned access support in GCC. This affects Linaro GCC from 4.6-2011.11 onwards, GCC from 4.7.0 on, and kernels earlier than 3.2 including the Galaxy Nexus Icecream Sandwich release.

The work-around is to add -mno-unaligned-access to KBUILD_CFLAGS in the top level kernel Makefile or to backport 8428e84d42179c2a00f5f6450866e70d802d1d05 from the current kernel tree.

ARMv6K and later processors have hardware support for doing unaligned loads and stores which is faster than the old byte-by-byte/recombine that was done in software. Later versions of GCC use this to do quicker loads when working on known unaligned data, such as when working on a protocol buffer or a packed structure.

The CPU can be configured to trap on unaligned access. This trap is off at reset, but pre 3.2 kernels turn this on during the initial boot. An interaction between -fconserve-stack and -munaligned-access on a char buffer lead to an unaligned access, which causes a trap, which causes the kernel to halt.

This does not affect userspace programs as they run with the trap turned off.

2 Comments

  1. [...] dieser Kernel so? Ist kein kernel. Da sind jetzt ein haufen 4.6 und 4.7 ALPHA81 zum probieren. Kernel not booting with Linaro GCC? – Seabright Technology das hat er 40 minuten nach dem er mir geholfen hat Linaro GCC 4.6 und 4.7 zu verwenden geschrieben [...]

  2. Tim Harman says:

    Thanks very much. Couldn’t figure out why my new kernel wouldn’t boot anymore once I’d moved to gcc 4.7.1. This post fixed my problem, so thank you for taking the time to share it!

    Tim

Leave a Reply