Skip to contentSkip to conversation

x86->x86 GRUB bootable image in OE?

DISCUSSION Leon Woestenberg 2 participants 6 messages Sep 28, 2009 – Sep 29, 2009

lore
Share & tools
lore
#0 lore raw

Hello,

on x86 target support, I have some ideas how to create bootable disk images from OE using GRUB (not using the post image command approach).

However, I suspect this will only work if we have GRUB on the host, i.e. assume a x86 host, and have grub-native.

grub-native would be step one, but I am having a hard time getting the staging to work.

In general, for staging host-native tools, do we use the "make install" approach?

Regards,

Leon.

DESCRIPTION = "GRand Unified Bootloader"
HOMEPAGE = "http://www.gnu.org/software/grub"
SECTION = "bootloaders"
PRIORITY = "optional"
RDEPENDS_${PN}-install = "diffutils"
PR = "r5"

SRC_URI = "ftp://alpha.gnu.org/gnu/grub/grub-${PV}.tar.gz \
           file://automake-1.10.patch;patch=1 \
           file://menu.lst"

inherit autotools_stage native

CFLAGS += "-fno-stack-protector"

#do_install() {

#       oenote do_install
#       oenote DESTDIR=${D}
#       oe_runmake 'DESTDIR=${D}' install

#}

do_stage() {
        oenote do_stage
        oenote DESTDIR=${STAGING_DIR_HOST}
        oe_runmake 'DESTDIR=${STAGING_DIR_HOST}' install
}

#do_stage() {
# oe_runmake 'DESTDIR=${STAGING_DIR_HOST}' install
# install -m 0644 -D ${WORKDIR}/menu.lst ${}/boot/grub/menu.lst
#

#        # Copy stage1/1_5/2 files to /boot/grub
#        GRUB_TARGET_ARCH=$(echo ${TARGET_ARCH} | sed -e 's/.86/386/')
#        install -m 0744 -d ${STAGING_DIR_HOST}/boot/grub/
#        install -m 0644 \

# ${D}/${libdir}/grub/${GRUB_TARGET_ARCH}${TARGET_VENDOR}/* \
# ${STAGING_DIR_HOST}/boot/grub/
#}

PACKAGES =+ "${PN}-install ${PN}-eltorito"

FILES_${PN}-install = " \
        ${sbindir}/grub-install \
        ${sbindir}/grub-terminfo \
        ${sbindir}/grub-md5-crypt \
        ${bindir}/mbchk \
        ${libdir}/grub \

"
FILES_${PN}-eltorito = "/boot/grub/stage2_eltorito" FILES_${PN} += "/boot"

COMPATIBLE_HOST = "i.86.*-linux"

Signature · 1 line
Leon
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Leon" == Leon Woestenberg <[email protected]> writes:

Leon> Hello, on x86 target support, I have some ideas how to create Leon> bootable disk images from OE using GRUB (not using the post Leon> image command approach).

Leon> However, I suspect this will only work if we have GRUB on the Leon> host, i.e. assume a x86 host, and have grub-native.

We tried this for our system. You need to split grub into the grub-installer part and the grub part, and the way that grub 0.97 works doesn't really fit nicely. Grub 2 may be better.

We ended up switching to syslinux which works nicely cross-platform.

Peter C

--
Dr Peter Chubb www.nicta.com.au peter DOT chubb AT nicta.com.au
http://www.ertos.nicta.com.au ERTOS within National ICT Australia

#2 lore raw

Hello Peter,

Quoted 6 lines · Peter Chubb
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Leon" == Leon Woestenberg <[email protected]> writes:

Leon> Hello, on x86 target support, I have some ideas how to create Leon> bootable disk images from OE using GRUB (not using the post Leon> image command approach).

Quoted 9 lines

Leon> However, I suspect this will only work if we have GRUB on the Leon> host, i.e. assume a x86 host, and have grub-native.

We tried this for our system.  You need to split grub into the grub-installer part and the grub part, and the way that grub 0.97 works doesn't really fit nicely.  Grub 2 may be better.

We ended up switching to syslinux which works nicely cross-platform.

It's good to know I could always bail out if it isn't going to work.

I think I have got grub working outside OE for this, I just need to get things into OE.

Do you maybe still have any recipe that at least stages grub for the host?

Regards,

Signature · 1 line
Leon
#3 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Leon" == Leon Woestenberg <[email protected]> writes:

Leon> Hello Peter, On Mon, Sep 28, 2009 at 11:06 PM, Peter Chubb Leon> <[email protected]> wrote:

Leon> Do you maybe still have any recipe that at least stages grub for Leon> the host?

I have one at work --- I'll send it off when I get there. --
Dr Peter Chubb www.nicta.com.au peter DOT chubb AT nicta.com.au
http://www.ertos.nicta.com.au ERTOS within National ICT Australia

#4 lore raw

Hello Peter,

Quoted 5 lines · Peter Chubb

Leon> Do you maybe still have any recipe that at least stages grub for Leon> the host?

I have one at work --- I'll send it off when I get there.

Tops.

I'll buy you a beer when I'm Down Under -- ...It's just, don't wait for that :-)

Regards,

Signature · 1 line
Leon
#5 lore raw

Here's the grub-native recipe.

We use it something like this, in a different recipe for building the image:

HOST_ARCH may need tweaking.

GRUB=${STAGING_DIR}/${HOST_ARCH}-linux/usr/lib/grub/${HOST_ARCH}-pc

#Build the image
dd if=/dev/zero of="${IMAGE}" bs=1M count=$SZ

# Set up mtools
echo "drive c: file=\"$IMAGE\" partition=1" > mtoolsrc export MTOOLSRC=mtoolsrc

# Create filesystem

mpartition -I c:
mpartition -c -t $CYLINDERS -h 16 -s 63 c:
mformat c:
mmd c:/boot
mmd c:/boot/grub

# Install grub
mcopy "${GRUB}/stage1" c:/boot/grub
mcopy "${GRUB}/stage2" c:/boot/grub
mcopy "${GRUB}/fat_stage1_5" c:/boot/grub

echo "(hd0) $IMAGE" > bmap
echo -e "geometry (hd0) $CYLINDERS 16 63\nroot (hd0,0)\nsetup (hd0)" | grub --device-map=bmap --batch

--
Dr Peter Chubb www.nicta.com.au peter DOT chubb AT nicta.com.au
http://www.ertos.nicta.com.au ERTOS within National ICT Australia
From Imagination to Impact Imagining the (ICT) Future