[U-Boot] Separately compile Master boot loader

Albert ARIBAUD albert.u.boot at aribaud.net
Wed Jul 10 14:23:01 CEST 2013


Hi Rajdeep,

On Wed, 10 Jul 2013 15:04:12 +0530, Rajdeep Vaghasia
<rajdeep.vaghasia at gmail.com> wrote:

> Waiting for a reply.

Well, maybe if you had not e-mailed your 8:32 AM answer to me but to
the list... :)

Here it is, with my comments.

> On Tue, Jul 9, 2013 at 5:31 PM, Albert ARIBAUD <albert.u.boot at aribaud.net>wrote:
> 
> > Hi Rajdeep,
> >
> > On Tue, 9 Jul 2013 16:12:14 +0530, Rajdeep Vaghasia
> > <rajdeep.vaghasia at gmail.com> wrote:
> >
> > > Hi
> > > I am working on one board with an arm11 based cpu, NOR flash and DDR2
> > SDRAM.
> > > When I compile u-boot source code, I get u-boot.bin image generated.
> > > This image has primary(second stage) and secondary(third stage)
> > bootloader
> > > combined.
> > >
> > > I have following queries:
> > > 1) The question that still eats me everyday is, How can I compile
> > > primary(Master) boot loader and secondary boot loader separately?
> > > 2) I want to Flash only initial 4kb of code (Master boot loader or second
> > > stage). The remaining code I want to keep at another partition in the
> > > Flash. How can I achieve this?
> > > 3) Is there any separate code available for Master boot loader, which
> > > copies the third stage bootloader to SDRAM and then transfers control to
> > > that third stage boot loader(u-boot)?
> > >
> > > I am unable to find a way to do this.
> > >
> > > Can anyone help me please?
> >
> > Since you do not indicate exactly which target you're building, I'll
> > assume it is one with SPL (what you describe as master or second stage,
> > with third stage being u-boot itself).
> >
> > I don't know of a way to build SPL alone.
> >
> > As for building separate U-Boot and SPL, you'll find them in ELF format
> > in file ./u-boot and ./spl/u-boot-spl. You can then use
> > $(CROSS_COMPILE)objcopy to convert from ELF to .bin.
> >
> > Note that your target may need a specific format different from the
> > pure binary that objcopy can produce.
> >
> > Can you tell us more about your target?
> >
> > Amicalement,
> > --
> > Albert.
> >
> 
> Sorry, My target board is not with SPL.

Then your question does not make sense, since a target without SPL has
no "second" and "third" stage, only a single standalone U-Boot stage.

> According to my understanding, SPL is required when we want to use NAND or
> oneNAND flash. And even in that case, the image generated, is combined of
> u-boot.bin+nand_driver.

This is quite reductive and partly wrong. 

SPL is required when you cannot directly boot into U-boot, one of the
cases being when you boot from NAND as it usually only allows very small
binaries; but NAND is far from the only case where SPL is needed or
useful.

Also, as I said, the image generated in the SPL case is not "u-boot +
NAND driver", it is "complete SPL + complete U-Boot" (although you can
have them separate as I explained), and the "complete SPL" part is not
itself an "U-Boot plus NAND driver".

> I am using NOR flash.

Ok.

> Actually, I am building firmware upgrade procedure.
> For that I need 3 partitions for u-boot.
> One with master u-boot.
> Other two with u-boot-1 and u-boot-2. (One contains current working u-boot,
> whereas another is with upgraded u-boot code).
> For that I need one Master uboot which contains code that initializes the
> SDRAM, choses one of the 2 secondary u-boot with the help of an environment
> variable (Or fixed jump to the start address of u-boot-1 or u-boot-2) and
> then copies u-boot(Secondary boot loader) to SDRAM and executes it from
> there.

Ok, so "secondary" is a concept specific to your design. No wonder I
could not understand it properly until you explained.

> These steps of initializing SDRAM and copying of u-boot code there, are
> already implemented in u-boot code. I just want to separate it from the
> main source code and want to generate binary of that much code only.
> 
> Is there any way to achieve this?

Several; and then there is an infinity of other possible approaches,
depending, not on *what* you want to do, but on *why* you want to do
it. Can you give more details on why your firmware upgrade procedure
needs to boot two different U-Boots  ?

> or
> Is there any resource of information available which can help me to
> understand this?

The source code and the Denx website, at this point; once you explain
the goal you are trying to reach, people on the list might point you
to more specific resources.

> Rajdeep.

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list