Sign in

username:

password:



Not a member?

Search Comp.Arch.FPGA



Search tips

fpga by Keywords

Altera | ASIC | CPLD | Cyclone | DCM | DDR | DSP | Ethernet | ISE | JTAG | Linux | LVDS | Microblaze | ML310 | Modelsim | NIOS | OPB | PCI | Quartus | RocketIO | SDRAM | Spartan | Spartan3 | SRAM | Stratix | Verilog | VHDL | Virtex | Virtex-4 | Virtex-II | Xilinx | XST


Ads

See Also

DSPEmbedded SystemsElectronics

Comp.Arch.FPGA | Booting Linux from my own bootloader

There are 13 messages in this thread.

You are currently looking at messages 0 to 10.

Booting Linux from my own bootloader - Martin =?UTF-8?B?QnLDvGNrbmVy?= - 2010-04-26 16:50:00

Hello,

I'm writing a boot loader to start Linux on the PowerPC440 (Virtex5FXT).
At first the program copies the kernel into the RAM at address
0x00400000 and afterwards it boots Linux with the following lines:

#define LINUX_START_ADDRESS 0x004002b4

int main()
{
	void (*linux)();
	linux = (void*) LINUX_START_ADDRESS;

	... // here is the code which copies the kernel into ram

	(*linux)();
}

With the following steps, booting works fine:
(1). comment out the line (*linux)();
(2). start the program
(3). start xmd and enter "rst -processor"
(4). set the program counter: "rwr pc 0x004002b4"
(5). enter "con"

What does not work:
Starting Linux directly within the program with the last line.
All I can see is the following and thats all.

zImage starting: loaded at 0x00400000 (sp: 0x00569fb0)
Allocating 0x2efa98 bytes for kernel ...
gunzipping (0x00000000 <- 0x0040d000:0x0056837e)...done 0x2d2270 bytes

Linux/PowerPC load: console=ttyUL0 root=/dev/mmcblk0p1 rootdelay=5
Finalizing device tree... flat tree at 0x576300



So the question is: What do I have to do to boot Linux from within the
program?


Best Regards
Martin Brückner
______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.



Re: Booting Linux from my own bootloader - glen herrmannsfeldt - 2010-04-26 18:08:00

Martin Br?ckner <b...@alice-dsl.net>
wrote:
 
> I'm writing a boot loader to start Linux on the PowerPC440 (Virtex5FXT).
> At first the program copies the kernel into the RAM at address
> 0x00400000 and afterwards it boots Linux with the following lines:
 
> #define LINUX_START_ADDRESS 0x004002b4
 
(snip)
 
>        (*linux)();

With the assumption that data pointers can be properly
cast to function pointers, that line should jump to 
location 0x4002b4 and start executing the code there.
 
> With the following steps, booting works fine:
> (1). comment out the line (*linux)();
> (2). start the program
> (3). start xmd and enter "rst -processor"
> (4). set the program counter: "rwr pc 0x004002b4"
> (5). enter "con"

I presume that mostly starts executing at 0x4002b4?

> What does not work:
> Starting Linux directly within the program with the last line.
> All I can see is the following and thats all.
 
> zImage starting: loaded at 0x00400000 (sp: 0x00569fb0)
> Allocating 0x2efa98 bytes for kernel ...
> gunzipping (0x00000000 <- 0x0040d000:0x0056837e)...done 0x2d2270 bytes
 
> Linux/PowerPC load: console=ttyUL0 root=/dev/mmcblk0p1 rootdelay=5
> Finalizing device tree... flat tree at 0x576300

So it does start executing, and doing things that it is
supposed to do, but doesn't end up working?

> So the question is: What do I have to do to boot Linux from within the
> program?

-- glen

Re: Booting Linux from my own bootloader - Martin =?UTF-8?B?QnLDvGNrbmVy?= - 2010-04-27 04:03:00

Am Mon, 26 Apr 2010 22:08:02 +0000 (UTC)
schrieb glen herrmannsfeldt <g...@ugcs.caltech.edu>:

> Martin Br?ckner <b...@alice-dsl.net> wrote:
>  
> > I'm writing a boot loader to start Linux on the PowerPC440
> > (Virtex5FXT). At first the program copies the kernel into the RAM
> > at address 0x00400000 and afterwards it boots Linux with the
> > following lines:
>  
> > #define LINUX_START_ADDRESS 0x004002b4
>  
> (snip)
>  
> >        (*linux)();
> 
> With the assumption that data pointers can be properly
> cast to function pointers, that line should jump to 
> location 0x4002b4 and start executing the code there.
>  
> > With the following steps, booting works fine:
> > (1). comment out the line (*linux)();
> > (2). start the program
> > (3). start xmd and enter "rst -processor"
> > (4). set the program counter: "rwr pc 0x004002b4"
> > (5). enter "con"
> 
> I presume that mostly starts executing at 0x4002b4?

Yes.

> 
> > What does not work:
> > Starting Linux directly within the program with the last line.
> > All I can see is the following and thats all.
>  
> > zImage starting: loaded at 0x00400000 (sp: 0x00569fb0)
> > Allocating 0x2efa98 bytes for kernel ...
> > gunzipping (0x00000000 <- 0x0040d000:0x0056837e)...done 0x2d2270
> > bytes
>  
> > Linux/PowerPC load: console=ttyUL0 root=/dev/mmcblk0p1 rootdelay=5
> > Finalizing device tree... flat tree at 0x576300
> 
> So it does start executing, and doing things that it is
> supposed to do, but doesn't end up working?

Yes, exactly. When resetting the CPU before booting, everything is
fine. But in this case it ends up here.
At the moment I'm learning how to extract the syslog out of Linux to get
messages before the console is initialized. I'll post the result here,
soon.

> 
> > So the question is: What do I have to do to boot Linux from within
> > the program?
> 
> -- glen
-- Martin Brückner

Re: Booting Linux from my own bootloader - Brian Drummond - 2010-04-27 06:17:00

On Tue, 27 Apr 2010 10:03:34 +0200, Martin
Brückner
<b...@alice-dsl.net> wrote:

>Am Mon, 26 Apr 2010 22:08:02 +0000 (UTC)
>schrieb glen herrmannsfeldt <g...@ugcs.caltech.edu>:
>
>> Martin Br?ckner <b...@alice-dsl.net> wrote:
>>  
>> > I'm writing a boot loader to start Linux on the PowerPC440
>> > (Virtex5FXT). At first the program copies the kernel into the RAM
>> > at address 0x00400000 and afterwards it boots Linux with the
>> > following lines:
>>  
>> > #define LINUX_START_ADDRESS 0x004002b4
>>  
>> (snip)
>>  
>> >        (*linux)();
>> 
>> With the assumption that data pointers can be properly
>> cast to function pointers, that line should jump to 
>> location 0x4002b4 and start executing the code there.

I haven't used the PPC since the V2Pro, but...

Xilinx example code typically has boilerplate to do things like
invalidate caches and set up interrupt state before handing over to
"real" code. It is possible that using XMD to reset the CPU does that
for you.

Have you covered these bases in your own code?

- Brian

Re: Booting Linux from my own bootloader - Marc Jet - 2010-04-27 07:07:00

Martin Br=FCckner wrote:
> 	void (*linux)();
>            ...
> 	(*linux)();

Wouldn't the last line have to be just this?

 	linux();

Re: Booting Linux from my own bootloader - Joe Chisolm - 2010-04-27 13:26:00

On Mon, 26 Apr 2010 22:50:19 +0200, Martin
Brückner wrote:

> Hello,
> 
> I'm writing a boot loader to start Linux on the PowerPC440 (Virtex5FXT).
> At first the program copies the kernel into the RAM at address
> 0x00400000 and afterwards it boots Linux with the following lines:
> 
> #define LINUX_START_ADDRESS 0x004002b4
> 
> int main()
> {
> 	void (*linux)();
> 	linux = (void*) LINUX_START_ADDRESS;
> 
> 	... // here is the code which copies the kernel into ram
> 
> 	(*linux)();
> }
> 

Did you setup the stack pointer?  The above is going to try and push
the return address on the stack.  Compile with -S and look at the
resulting asm output.

[snip]

> Best Regards
> Martin Brückner


-- 
Joe Chisolm
Marble Falls, Tx.
______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.

Re: Booting Linux from my own bootloader - glen herrmannsfeldt - 2010-04-27 14:23:00

Joe Chisolm <j...@earthlink.net>
wrote:
> On Mon, 26 Apr 2010 22:50:19 +0200, Martin Br?ckner wrote:

>> I'm writing a boot loader to start Linux on the PowerPC440 (Virtex5FXT).
>> At first the program copies the kernel into the RAM at address
>> 0x00400000 and afterwards it boots Linux with the following lines:
 
>> #define LINUX_START_ADDRESS 0x004002b4
(snip) 
>>       (*linux)();
 
> Did you setup the stack pointer?  The above is going to try and push
> the return address on the stack.  Compile with -S and look at the
> resulting asm output.

Not knowing at all about the linux boot process, I would have
assumed that one of the first thing that the booting kernel does
would be to set up its own stack.

It might, though, depend on a previous level of boot program
to have set up a stack for it.  I wouldn't expect the boot
ROM to have done it, but often there are multiple levels of
boot programs.

-- glen

Re: Booting Linux from my own bootloader - Martin =?UTF-8?B?QnLDvGNrbmVy?= - 2010-04-27 18:12:00

Am Tue, 27 Apr 2010 11:17:03 +0100
schrieb Brian Drummond <b...@btconnect.com>:

> On Tue, 27 Apr 2010 10:03:34 +0200, Martin Brückner
> <b...@alice-dsl.net> wrote:
> 
> >Am Mon, 26 Apr 2010 22:08:02 +0000 (UTC)
> >schrieb glen herrmannsfeldt <g...@ugcs.caltech.edu>:
> >
> >> Martin Br?ckner <b...@alice-dsl.net> wrote:
> >>  
> >> > I'm writing a boot loader to start Linux on the PowerPC440
> >> > (Virtex5FXT). At first the program copies the kernel into the RAM
> >> > at address 0x00400000 and afterwards it boots Linux with the
> >> > following lines:
> >>  
> >> > #define LINUX_START_ADDRESS 0x004002b4
> >>  
> >> (snip)
> >>  
> >> >        (*linux)();
> >> 
> >> With the assumption that data pointers can be properly
> >> cast to function pointers, that line should jump to 
> >> location 0x4002b4 and start executing the code there.
> 
> I haven't used the PPC since the V2Pro, but...
> 
> Xilinx example code typically has boilerplate to do things like
> invalidate caches and set up interrupt state before handing over to
> "real" code. It is possible that using XMD to reset the CPU does that
> for you.
> 
> Have you covered these bases in your own code?

When I started with this project I was sure that Linux invalidates
caches and sets up the interrupt state and the comments in
arch/powerpc/kernel/head_44x.S seems to confirm that (I am not deep
enough into PowerPC Assembler to understand all of its code).
Probably there might be a bug in this initializing code.

Anyway, all I tried out yet was disabling the cache but that did not
help. Do you know where to find more Xilinx-Commands to handle Cache
and MMU?

> 
> - Brian
Martin

Re: Booting Linux from my own bootloader - Martin =?UTF-8?B?QnLDvGNrbmVy?= - 2010-04-27 18:15:00

Am Tue, 27 Apr 2010 18:23:11 +0000 (UTC)
schrieb glen herrmannsfeldt <g...@ugcs.caltech.edu>:

> Joe Chisolm <j...@earthlink.net> wrote:
> > On Mon, 26 Apr 2010 22:50:19 +0200, Martin Br?ckner wrote:
> 
> >> I'm writing a boot loader to start Linux on the PowerPC440
> >> (Virtex5FXT). At first the program copies the kernel into the RAM
> >> at address 0x00400000 and afterwards it boots Linux with the
> >> following lines:
>  
> >> #define LINUX_START_ADDRESS 0x004002b4
> (snip) 
> >>       (*linux)();
>  
> > Did you setup the stack pointer?  The above is going to try and push
> > the return address on the stack.  Compile with -S and look at the
> > resulting asm output.
> 
> Not knowing at all about the linux boot process, I would have
> assumed that one of the first thing that the booting kernel does
> would be to set up its own stack.
> 
> It might, though, depend on a previous level of boot program
> to have set up a stack for it.  I wouldn't expect the boot
> ROM to have done it, but often there are multiple levels of
> boot programs.
> 
> -- glen

As I wrote before (answering Brian), I also assumed that Linux would
manage that.

What I found out this day is, that the Linux syslog-buffer is empty.

Martin
______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.

Re: Booting Linux from my own bootloader - Martin =?ISO-8859-1?Q?Br=FCckner?= - 2010-04-28 05:29:00

Am Tue, 27 Apr 2010 04:07:41 -0700 (PDT)
schrieb Marc Jet <j...@hotmail.com>:

> Martin Br=FCckner wrote:
> > 	void (*linux)();
> >            ...
> > 	(*linux)();
>=20
> Wouldn't the last line have to be just this?
>=20
>  	linux();

The result of (*linux)() and linux() is the same.

| 1 | 2 | next