Wednesday, June 9, 2010

Beagleboard: Designing the 2nd stage Bootloader (XLOADER)

One of the main functionality of this 2nd stage bootloader is to setup a basic Interrupt Vector Table to catch exceptions that might occur during the initial boot stages, setting up external SDRAM for early availability, basic console setup to track the boot progress and finally setting up stacks for all available ARM modes in preparation for a complete C runtime environment.
As there are no initialized segments or stacks available to run a C program, we will start with ARM assembly instructions for the first few steps.

We compile and link our loader image using the ARM GNU compiler toolchain for all development purposes here.
As soon as our program is loaded onto the board, we need to ensure that the control jumps to our program's entry point. We will label our entry point as '_start' as this is the most common entry point label generated by most of the compilers for any program, by default.
For any source file when being compiled and linked, we can notify the entry point of our code to the Linker using the directive ENTRY. So in our case, we write a linker script file called "PB.ld" and add the following directives:

OUTPUT_FORMAT ("elf32-littlearm")
OUTPUT_ARCH (arm)
ENTRY (_start)


Here the first directive OUTPUT_FORMAT notifies the linker that our file will be linked as an ELF32 executable, executed in LITTLE ENDIAN mode.
The second line OUTPUT_ARCH specifies that the file is to be linked in for an ARM architecture platform.
Finally, the third line, ENTRY specifies the label of entry point of our image to be _start.

To be continued.........

No comments:

Post a Comment