[U-Boot-Users] u-boot as second stage boot loader

Friedrich, Lars lars.friedrich at wago.com
Tue Sep 21 11:16:45 CEST 2004


> The next step would be to load u-boot as a second stage boot loader,
> however how can someone do this?
[...]
> As it can be seen, the SRAM is too small for the 80-90kbyte u-boot
> image... What is the solution? Maybe i could take the u-boot image
> apart, and copy the code before relocation into the sram and the code
> after relocation into SDRAM and then make a "mov r5,#0;mov pc,r5"?

In the 16kbyte flash area you put an universal first stage bootloader.
This bootloader should not have any knowledge about _what_ it will start.
It should only:
- prepare the hardware to retrieve data from the flash device
- copy contents from the flash device to ram
- jump to a defined address in ram
(- maybe init the serial and do some output for debugging purposes)

So the first stage bootloader will need four things:
1) the start of data to copy
2) the destination in ram to copy it to
3) the amount of data to copy
4) the address to set the pc after copy, maybe the same as 2)

As a start, these values can be hardcoded into the first stage bootloader. Later
you might consider putting these values into the u-boot image (in other words:
in a defined area on the flash), so you will never have to touch the first stage
bootloader again if the second stage bootloader changes.

The first stage bootloader copies U-Boot completely into the ram and U-Boot should
be able to recognize that it is executed from ram already and not do any relocation
itself.

Regards,
Lars Friedrich




More information about the U-Boot mailing list