Dylan Saunders | 7 May 22:24
Picon
Favicon

ipengine boot

I have a couple of Brightstar ipengine boards that I have been trying Inferno on. The supplied Inferno port boots and runs just fine via tftp with the ipengine’s bootloader. I would like to get the Inferno image to boot from flash rather than tftp, but so far no success. I can load the image into flash but get errors/traps when I run it. Can anyone tell me if the ipengine port has ever been able to boot from flash, or is that just not implemented?

 

Thanks,

 

Dylan  Saunders

 

Richard Miller | 11 May 10:19

Re: ipengine boot

> I can load the
> image into flash but get errors/traps when I run it.

I think inferno won't run directly from flash - it will have to relocate itself
to RAM and run from there.  To run Plan 9 on the ipengine I inserted this code
into l.s early on (just after the MSRSYNC).  If you're lucky this will work
for inferno too:

	/* if executing in rom, relocate to ram */
	MOVW	LR, R3
	MOVW	$4,	R4
	SUBCC	R4, R3
	BGE		ram
	MOVW	$start(SB), R4
	MOVW	$edata+63(SB), R5
	SUB		R4, R5, R1
	SRAW	$6, R1
	MOVW	R1,CTR
	MOVW	$KZERO, R2
	ANDN	R2, R4
	MOVW	R4, LR
reloc:
	MOVMW	0(R3), R16
	MOVMW	R16, 0(R4)
	ADD		$64, R4
	ADD		$64, R3
	BDNZ	reloc
	BR		(LR)
ram:

Charles Forsyth | 11 May 11:44

Re: ipengine boot

> I think inferno won't run directly from flash - it will have to relocate itself
> to RAM and run from there.  To run Plan 9 on the ipengine I inserted this code

it can, and it was done on an MPC823, but perhaps not the ipengine.
it copied the data segment to RAM but kept the code in flash.

Richard Miller | 11 May 18:00

Re: ipengine boot

>> I think inferno won't run directly from flash ...
>
> it can, and it was done on an MPC823, but perhaps not the ipengine.
> it copied the data segment to RAM but kept the code in flash.

Did you also have to do some trickery to be able to write to the
flash filesystem while running from flash?  On some (most?) flash
hardware this is not possible - at least the lowest-level flash
write / erase code has to be run from RAM.

Richard Miller | 12 May 17:07

Re: ipengine boot

I've confirmed that the relocation code I posted yesterday works
for loading inferno from flash, with the addition of one more
instruction: immediately after label 'start(SB)', you need to insert
	BL	1(PC)
which loads LR with the original kernel start address (+4).

Sorry I overlooked that essential point.

An obvious improvement on just copying the kernel from flash
to RAM would be storing a compressed kernel image in flash
with a bit of self-decompression code at the start.  That's
left as an exercise for the reader ...

Charles Forsyth | 12 May 17:27

Re: ipengine boot

> An obvious improvement on just copying the kernel from flash
> to RAM would be storing a compressed kernel image in flash
> with a bit of self-decompression code at the start.  That's
> left as an exercise for the reader ...

there is some code with Inferno that will compress ARM and PowerPC using an ARM-designed
scheme (that works well on the powerpc too). the advantage is that decompression
is much faster than (say) for gz format, and the compression ratio is still reasonably good.
there's some decompression code for it in at least one of the bootstraps.

Dylan Saunders | 13 May 23:42
Picon
Favicon

RE: ipengine boot

Hello

Thank you very much for the assistance. Just to confirm, the modified
os/mpc/l.s should look like:
------------------------
/*
 * Boot first processor
 */
	TEXT start(SB), $-4

	MOVW	MSR, R3
	RLWNM	$0, R3, $~EE, R3
	RLWNM	$0, R3, $~FPE, R3
	OR	$ME, R3
	ISYNC
	MOVW	R3, MSR	/* turn off interrupts but enable traps */
	MSRSYNC
	
|/* if executing in rom, relocate to ram */ <--is this the right spot?
|	MOVW	LR, R3
|	MOVW	$4,	R4
|	SUBCC	R4, R3
|	BGE		ram
|	MOVW	$start(SB), R4
|	BL	1(PC)    /*loads LR with the original kernel start
address */
|	MOVW	$edata+63(SB), R5
|	SUB		R4, R5, R1
|	SRAW	$6, R1
|	MOVW	R1,CTR
|	MOVW	$KZERO, R2
|	ANDN	R2, R4
|	MOVW	R4, LR
|reloc:
|	MOVMW	0(R3), R16
|	MOVMW	R16, 0(R4)
|	ADD		$64, R4
|	ADD		$64, R3
|	BDNZ	reloc
|	BR		(LR)
|ram: <--does this code get pushed down to here?
	MOVW	$0, R0 /* except during trap handling, R0 is zero from
now on */
	MOVW	R0, CR
	MOVW	$setSB(SB), R2

----------------------

Btw:
Much of the C code in os/boot/mpc tries to include libc.h, which doesn't
seem to be part of the distribution (20060303). Perhaps this was part of
older distributions.

Dylan Saunders

-----Original Message-----
From: inferno-list-admin@...
[mailto:inferno-list-admin@...] On Behalf Of Richard Miller
Sent: Monday, May 12, 2008 9:07 AM
To: inferno-list@...
Subject: Re: [inferno-list] ipengine boot

I've confirmed that the relocation code I posted yesterday works
for loading inferno from flash, with the addition of one more
instruction: immediately after label 'start(SB)', you need to insert
	BL	1(PC)
which loads LR with the original kernel start address (+4).

Sorry I overlooked that essential point.

An obvious improvement on just copying the kernel from flash
to RAM would be storing a compressed kernel image in flash
with a bit of self-decompression code at the start.  That's
left as an exercise for the reader ...

Charles Forsyth | 14 May 10:49

RE: ipengine boot

more things:
os/boot/mpc/l.s and os/boot/mpc/init*.c
contain 1st-level boot code that runs from flash but has data in RAM.
init*.c initialise the memory controllers on different mpc8xx
platforms.  they are odd because sysinit is called when running
with both code and initialised data in flash (because DRAM isn't ready yet),
so the code plays games with SB to address the initialised data in flash
until DRAM is ready, then switches it back.

it also includes unsqueeze code i mentioned earlier.
os/boot/puma has an ARM version of it.

both are based too much on the pc boot program because
the person intended to use them needed something familiar.

Richard Miller | 14 May 11:23

RE: ipengine boot

dylan.saunders@... wrote:

> Thank you very much for the assistance. Just to confirm, the modified
> os/mpc/l.s should look like:
> ------------------------

Not quite.  As I said in my follow-up message, it needs to start like this:

	TEXT start(SB), $-4
	BL	1(PC)
	MOVW	MSR, R3
	...

Also, you should not really modify os/mpc/l.s because that's common for
several powerpc platforms not just the ipengine.  What I did was to copy
os/mpc/l.s to os/ipengine/ll.s, modify that, and change os/ipengine/mkfile
to use ll.$O instead of l.$O.  (There's probably a more elegant way to
do this.)

> Btw:
> Much of the C code in os/boot/mpc tries to include libc.h, ...

os/boot/mpc is something else altogether - a "proper" bootstrap loader
which can load kernel images from a formatted flash filesystem.  My
self-relocation mechanism assumes that you have simply used the
ipengine ROM monitor to install a kernel image in a chunk of flash
which is not part of a filesystem, e.g.
	load /lib/tftpd/iipe fe010000
and then executed it in place with
	go fe010020

You could of course make an ipengine boot loader based on the stuff in
os/boot/mpc, but it would be quite a bit more work (see Charles Forsyth's
recent message).

Dylan Saunders | 14 May 17:24
Picon
Favicon

RE: ipengine boot


Thanks Richard, that works. As you may have guessed I am not really an
assembly language programmer, I am more familiar with getting Linux
working on these systems; and of course the Linux kernel comes with its
own boot code. This is a good learning opportunity for me.

Dylan Saunders

>Not quite.  As I said in my follow-up message, it needs to start like
this:
>
>	TEXT start(SB), $-4
>	BL	1(PC)
>	MOVW	MSR, R3
>	...


Gmane