v7-M: Fixing XIP when the kernel is in ROM
Russell King - ARM Linux
linux at arm.linux.org.uk
Tue Oct 27 15:40:19 PDT 2015
On Tue, Oct 27, 2015 at 10:20:20PM +0100, Uwe Kleine-König wrote:
> Hello Ezequiel,
>
> On Tue, Oct 27, 2015 at 05:57:46PM -0300, Ezequiel Garcia wrote:
> > On 27 October 2015 at 17:21, Uwe Kleine-König
> > <u.kleine-koenig at pengutronix.de> wrote:
> > > Hello Ezequiel,
> > >
> > > On Sun, Oct 25, 2015 at 10:27:10PM -0300, Ezequiel Garcia wrote:
> > >> I've been trying to make my ARM v7-M LPC43xx board
> > >> boot a XIP kernel from flash. Currently, this seems
> > >> to be broken in mainline due to this:
> > >>
> > >> arch/arm/mm/proc-v7m.S
> > >> [..]
> > >> @ SVC to run the kernel in this mode
> > >> badr r1, 1f
> > >> ldr r5, [r12, #11 * 4] @ read the SVC vector entry
> > >> str r1, [r12, #11 * 4] @ write the temporary SVC vector entry
> > >> mov r6, lr @ save LR
> > >> mov r7, sp @ save SP
> > >> ldr sp, =__v7m_setup_stack_top @ <<< Breaks XIP!
> > >
> > > How does this fail for you?
> > >
> >
> > My CPU just seems to stall.
> > I've added calls to the printch in arch/arm/kernel/debug.S
> > and can't get past the SVC call.
> Can you try to add something like:
>
> stmdb sp!, {r0-r4}
Wait one moment, and try reading the code.
The call path to this point is: entry text at stext in head-nommu.S
which goes on to call __v7m_setup.
Nothing in that path sets up a stack, so the value of 'sp' is
undefined - it's entirely whatever's left in the register after the
boot loader has passed control to the kernel.
So, it's pointless proc-v7m.S saving and restoring the stack pointer
around this. It also means that there probably isn't a reliable
stack here.
--
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
More information about the linux-arm-kernel
mailing list