bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cross-compile and install grub: PPC host & i386 target


From: Christoph Plattner
Subject: Re: Cross-compile and install grub: PPC host & i386 target
Date: Thu, 20 Jun 2002 10:09:59 +0200

It is not a good idea to run the GRUB shell on the development
host. As Mr. Okuji also mentioned. Further GRUB is not 
endian-safe, so values written to the disk by the PPC are
definitly in the wrong endian format.

But there are much better solutions. We use the a similar setup,
cross development on SUN/Sparc, target is also i386-family.

First of all, use stage 1.5 ! Whit this method you can forget
everything about block lists and install process.
The write a very small tool, patching an original stage1
and stage1_5 file with the apropriate values to hardcoded
load stage 1.5.
Now append the stage1.5 file onto the stage1 file:

        cat stage1.patched <fs>_stage1_5.patched > boot_block
        
and dump the boot block onto the disk:

        cat boot_block > /dev/sda

Then you can process using fdisk and create partitions
(do not used fdisk before dumping the boot_block, as
boot_block overwrites the partition table), then
make the file systems and load the files on it. The
file stage2 has to be on the first partition under
/boot/grub (or whatever you "patched" in the stage1 !).

To find out the patches: Refer to GRUB manual and source
code, or do a test installation of GRUB including stage1.5 !
Do a compare then ...

For stage1: Field 0x40..0x49 have to be patched !
                Bytes: 
                0x80 (drive), 0x00 (flags),
                0x00 0x20 (stage2=stage1.5 load address),
                0x01 0x00 0x00 0x00 (lba sector to start loading)               
        0x00 0x02 (stage2
(1.5) segment) 
For stage1_5: 0x1fc has to hold number of blocks of stage1.5
                size minus one block, as first is loaded by
                stage1
              0x217 holds partition (0xff 0xff 0x00 0xff for
                first partition), followed by the string 
                "/boot/grub/stage2 /boot/grub/menu.lst"


This really works well !

Christoph P.


.....
> 
> I've been experimenting with cross-compiling grub on a ppc host for
> an i386 target. The compile works quite fine (although I had to
> manually add <linux/linux.h> to grub-0.92/lib/device.c for it to
> compile).
> 
> The real problem is trying to get grub to install on my target's
> root device which is a CompactFlash card mounted using Linux's
> USB-storage layer as /dev/sda. On the target, this gets to be
> the primary hard disk.
> 
> I am able to get the stage1 and stage2 images on the device using
> "dd". Grub then does display the "GRUB" letters when the CF card
> is put on the target, but not much else (obviously).
> 
> Sifting through the manual, it seems that I really need to run
> the "grub" executable for it to prepare the root device if I want
> to have an ext2 fs on the root dev. The build process, however,
> simply refuses to go anywhere once it sees that it is running on
> a ppc host.
> 
> Would there be a "simple" way to get the "grub" utility to compile
> on the ppc in order to be able to format my root device? Or maybe
> I'm just missing something here ... ?
> 
> Any help would be greatly appreciated.
> 
> Karim
> 
> ===================================================
>                  Karim Yaghmour
>                address@hidden
>       Embedded and Real-Time Linux Expert
> ===================================================
> 
> _______________________________________________
> Bug-grub mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-grub

-- 
  +--------V--------+   address@hidden
  |  A L C A T E L  |   -----------------------------
  +-----------------+   Phone: +43 1 27722 3706 
         T A S          Fax:   +43 1 27722 3955



reply via email to

[Prev in Thread] Current Thread [Next in Thread]