[U-Boot] [PATCH v3 1/2] arm: move C runtime setup code in crt0.S

Albert ARIBAUD
2012-11-15T22:41:07Z

Hi Simon,

On Thu, 15 Nov 2012 11:35:27 -0800, Simon Glass <sjg@chromium.org>
wrote:

> Hi Albert,
>
> On Sat, Nov 10, 2012 at 9:00 AM, Albert ARIBAUD
> <albert.u.boot@aribaud.net> wrote:
> > Move all the C runtime setup code from every start.S
> > in arch/arm into arch/arm/lib/crt0.S. This covers
> > the code sequence from isetting up the initial stack
> > to calling into board_init_r().
> >
> > Also, rewrite the C runtime setup and make functions
> > board_init_*() and relocate_code() behave according to
> > normal C semantics (no jumping across the C stack any
> > more, etc).
> >
> > Some SPL targets had to be touched because they use
> > start.S exolicitly or for some reason; the relevant
> > maintainers and custodians are cc:ed.
> >
> > Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
>
> I am very pleased to see this. My generic relocation series from some
> time ago is still hanging around. Your series tidies up some things
> which would make that series easier to do. I'm happy to take another
> look at it.

I do remember your series -- it is part of what gave me the incentive
toput this patch series together. :)

> I have tested your series on a Tegra seaboard, and got it running with
> a few changes. Please see comments below.

> > + ldr r0, =__bss_start /* this is auto-relocated! */
> > + ldr r1, =__bss_end__ /* this is auto-relocated! */
>
> I noticed this last time around - really we should have __bss_end__,
> not __bss_end. Something to look at in future work, perhaps.

Noted.

> > + bhs clbss_l
>
> I think this should be blo, not bhs. Otherwise the BSS does not get
> cleared and my seaboard doesn't boot properly.

Thanks -- not the first time I see these... I'll have a go at checking
all loops.

> > + /* call board_init_r */
> > + ldr pc, _board_init_r /* this is auto-relocated! */
>
> For my toolchain I need:
>
> ldr pc, =board_init_r
>
> otherwise I get:
>
> crt0.S: Assembler messages:
> crt0.S:176: Error: internal_relocation (type: OFFSET_IMM) not fixed up

Thanks -- this could well cure errors that Tom Warren reported to me
for various toolchains.

> Also _board_init_r seems to be the wrong symbol name for me:
>
> arch/arm/lib/libarm.o: In function `clbss_l':
> /home/sjg/trunk/src/third_party/u-boot/files/arch/arm/lib/crt0.S:176:
> undefined reference to `_board_init_r'

Thanks a lot for the feedback and analysis! This should make V4 work on
a much wider range of ARM boards.

> Regards,
> Simon

Amicalement,
--
Albert.