RedBoot? (ARM newlib build)
Bill Gatliff
bgat@billgatliff.com
Wed Dec 10 20:28:00 GMT 2003
Toralf:
Actually, arm-elf newlib assumes ARM's toolchain (esp. the Angel
monitor/debugger), which works using SWIs. The following procedure,
which I excerpted from one of my training manuals (and I think it's on
my website somewhere), rebuilds newlib without SWIs. Please pardon the
reformatting, it looks much better in PDF. :^)
As to your second question, don't port anything you don't need.
Regards,
b.g.
--
Bill Gatliff
It said Windows 95/98/NT/XP/2000 or better, so I installed Linux.
bgat@billgatliff.com
--------------
The startup code that interacts with RDP and RDI is in
newlib/libc/sys/arm/crt0.S. The SWI opcode is plainly visible within a
conditional code block.
To rebuild Newlib without RDP or RDI, edit the definition of
newlib_cflags in newlib/configure.host. Remove the definitions for
-DARM_RDI_MONITOR and -DARM_RDP_MONITOR. Then run the configure script
as usual.
After configuring the source tree, edit the topmost Makefile. Replace
the -O2 in CFLAGS_FOR_TARGET with -O0, and add a -g if necessary, so
that the library will support debugging (all optional).
Make and install as usual.
The resulting library is nearly functional. Applications built with the
non-RDI, non-RDP library will crash, usually in the
__do_global_ctors_aux() function. The reason is because the initial
stack pointer gets improperly set, the stack overwrites __CTOR_LIST__,
and a formerly null list terminator becomes an invalid function pointer.
The problem, found in crt0.S, is here:
...
#else
/* Set up the stack pointer to a fixed value */
ldr r3, .LC0
mov sp, r3
...
.LC0:
#ifdef ARM_RDI_MONITOR
.word HeapBase
#else
#ifndef ARM_RDP_MONITOR
#ifdef __pe__
.word 0x800000
#else
/* .word 0x80000 */ /* Top of RAM on the PIE board. */
#endif
#endif
#endif
.LC1:
.word __bss_start__
Without RDP and RDI, the value of .LC0, the initial stack pointer,
becomes the start of the .bss section. Which, it turns out, is
immediately after the .ctors section.
The fix is to uncomment the 0x80000, or better still, assign .LC0 to _stack:
#ifndef ARM_RDP_MONITOR
#ifdef __pe__
.word 0x800000
#else
.word _stack
#endif
#endif
Toralf Lund wrote:
> I think part of the answer to the question I asked yesterday, is that
> the default arm build of newlib assumes RedBoot routines to be
> present. Related questions:
>
> 1. Is there a simple way to build without it?
> 2. (Somewhat off-topic.) Should I port RedBoot to my platform? Do you
> think it would be worth the effort, or would it be simpler to
> write a custom loader + my own versions of the low-level I/O
> routines (using existing sourcecode when possible)? Note that I
> don't expect to need gdb support or a command line interface, as
> I'll be using a BDI2000 for debug support etc.. What I do need is
> some kind of a loader that will move my application from flash to
> memory and execute it. I might also want native flash update
> support in the future, although I can use the BDI2000 for that
> purpose, too.
>
> - Toralf
>
>
>
> ------
> Want more information? See the CrossGCC FAQ,
> http://www.objsw.com/CrossGCC/
> Want to unsubscribe? Send a note to
> crossgcc-unsubscribe@sources.redhat.com
>
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
More information about the crossgcc
mailing list