tool: use grub2 instead of grub1 for iso boot

Fixes #2526
This commit is contained in:
Alexander Boettcher 2017-09-20 22:56:00 +02:00 committed by Christian Helmuth
parent 7ff6e96623
commit 44adc3c404
24 changed files with 182 additions and 163 deletions

View File

@ -25,7 +25,7 @@ that your system satisfies the following requirements:
* 'libSDL-dev'
* 'tclsh' and 'expect'
* 'byacc' (only needed for the L4/Fiasco kernel)
* 'qemu' and 'genisoimage' (for testing non-Linux platforms via Qemu)
* 'qemu' and 'xorriso' (for testing non-Linux platforms via Qemu)
For using the entire collection of ported 3rd-party software, the following
packages should be installed additionally: 'autoconf2.64', 'autogen', 'bison',
@ -85,6 +85,11 @@ tool:
! ./tool/ports/prepare_port x86emu
On x86 base platforms the GRUB2 boot loader is required and can be
downloaded and prepared by invoking:
! ./tool/ports/prepare_port grub2
Now that the base platform is prepared, the 'create_builddir' tool can be used
to create a build directory for your platform of choice by giving the platform
as argument. To see the list of available platforms, execute 'create_builddir'

View File

@ -0,0 +1 @@
62b897bbff200f0ce5a0c01e52135cfdc7656104

View File

@ -0,0 +1,10 @@
LICENSE := GPLv3
VERSION := git
DOWNLOADS := g2fg.git
URL(g2fg) := https://github.com/alex-ab/g2fg.git
REV(g2fg) := ed4811471d3b7f5acdd409870e35d63de037003d
DIR(g2fg) := boot
default: $(DOWNLOADS)
$(VERBOSE)tar -C boot -xjf boot/grub2.tar.bz2

View File

@ -18,17 +18,6 @@ code respectively the download source of binaries are described below.
The 'pulsar' tool was obtained in binary form from
http://os.inf.tu-dresden.de/~us15/pulsar.
:'chain.c32', 'isolinux.bin'
These files are part of the 'Syslinux Project' hosting several bootloaders.
The sources has been obtained from http://www.syslinux.org.
:'stage2_eltorito':
This file is part of a modified Grub 0.97 available under GPL. The sources
of the modified Grub 0.97 were obtained from
http://os.inf.tu-dresden.de/~adam/grub.
:'unzip'
The 'unzip' tool is part of the 'morbo' toolchain available under GPL.
@ -38,15 +27,6 @@ code respectively the download source of binaries are described below.
The changes are available on the genode_bender branch of
https://github.com/skalk/morbo.git.
:'grub2_32.efi', 'grub2_64.efi'
GRUB 2 UEFI bootloader for x86
Source code was obtained from git://git.savannah.gnu.org/grub.git, git
commit 972765fe8245cdf44d465329f33b5aa9ac6c2f47.
The following modules were included: part_msdos iso9660 part_gpt ext2 multiboot multiboot2 fat normal configfile setpci serial efi_uga efi_gop gzio
:'tianocore.bin'
Open Virtual Machine Firmware (OVMF) developed by

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +0,0 @@
DEFAULT grub
LABEL grub
KERNEL chain.c32
APPEND grub=/boot/grub/stage2_eltorito

Binary file not shown.

View File

@ -57,13 +57,11 @@ cat > $cfg <<EOF
set prefix=(hd0,msdos1)/boot/grub
insmod normal
insmod legacycfg
terminal_input console
terminal_output console
## just legacy load Genode
legacy_configfile /boot/grub/menu.lst
configfile /boot/grub/grub.cfg
EOF
sudo cp $cfg $mnt/boot/grub/grub.cfg

Binary file not shown.

View File

@ -45,10 +45,14 @@ proc run_boot_dir {binaries} {
if {[have_include "image/iso"] || [have_include "image/disk"]} {
#
# Install isolinux/GRUB files and bender
#
install_iso_bootloader_to_run_dir
if {[have_include "image/disk"]} {
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
}
if {[have_include "image/iso"]} {
install_iso_bootloader_to_run_dir
}
#
# Generate GRUB config file
@ -56,16 +60,16 @@ proc run_boot_dir {binaries} {
# The core binary is part of the 'binaries' list but it must
# appear right after 'sigma0' as boot module. Hence the special case.
#
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
puts $fh "timeout 0"
puts $fh "default 0"
puts $fh "\ntitle Genode on L4/Fiasco"
puts $fh " kernel /boot/bender"
set fh [open "[run_dir]/boot/grub/grub.cfg" "WRONLY CREAT TRUNC"]
puts $fh "set timeout=0"
puts $fh "menuentry 'Genode on L4/Fiasco' {"
puts $fh " insmod multiboot"
puts $fh " multiboot /boot/bender"
puts $fh " module /bootstrap -serial"
puts $fh " module /kernel -serial -jdb_cmd=JH [fiasco_serial_esc_arg]"
puts $fh " module /sigma0"
puts $fh " module /image.elf"
puts $fh " vbeset 0x117 506070"
puts $fh "}"
close $fh
}

View File

@ -88,10 +88,14 @@ proc run_boot_dir_x86 {binaries} {
if {[have_include "image/iso"] || [have_include "image/disk"]} {
#
# Install isolinux/GRUB files and bender
#
install_iso_bootloader_to_run_dir
if {[have_include "image/disk"]} {
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
}
if {[have_include "image/iso"]} {
install_iso_bootloader_to_run_dir
}
#
# Generate grub config file
@ -99,15 +103,16 @@ proc run_boot_dir_x86 {binaries} {
# The core binary is part of the 'binaries' list but it must
# appear right after 'sigma0' as boot module. Hence the special case.
#
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
puts $fh "timeout 0"
puts $fh "default 0"
puts $fh "\ntitle Genode on Fiasco.OC"
puts $fh " kernel /boot/bender"
set fh [open "[run_dir]/boot/grub/grub.cfg" "WRONLY CREAT TRUNC"]
puts $fh "set timeout=0"
puts $fh "menuentry 'Genode on Fiasco.OC' {"
puts $fh " insmod multiboot"
puts $fh " multiboot /boot/bender"
puts $fh " module /bootstrap"
puts $fh " module /kernel [fiasco_serial_esc_arg]"
puts $fh " module /sigma0"
puts $fh " module /image.elf"
puts $fh "}"
close $fh
}

View File

@ -95,36 +95,26 @@ proc run_boot_dir {binaries} {
exec rm -fr [run_dir]/genode
exec [cross_dev_prefix]strip [run_dir]/image.elf
if {[have_include "image/iso"] || [have_include "image/disk"]} {
#
# Install isolinux/GRUB files and bender
#
install_iso_bootloader_to_run_dir
if {[have_include "image/iso"] || [have_include "image/disk"] || [have_include image/uefi]} {
#
# Generate GRUB config file
#
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
puts $fh "timeout 0"
puts $fh "default 0"
if {[have_spec "muen"]} {
puts $fh "\ntitle Genode on base-hw/Muen SK"
puts $fh " kernel /image.bin"
} else {
puts $fh "\ntitle Genode on base-hw"
puts $fh " kernel /boot/bender"
puts $fh " module /image.elf"
if {[have_include "image/disk"]} {
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
}
close $fh
}
if {[have_include image/uefi]} {
exec mkdir -p [run_dir]/efi/boot
exec cp [genode_dir]/tool/boot/grub2_32.efi [run_dir]/efi/boot/bootia32.efi
exec cp [genode_dir]/tool/boot/grub2_64.efi [run_dir]/efi/boot/bootx64.efi
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
if {[have_include "image/iso"]} {
install_iso_bootloader_to_run_dir
}
if {[have_include image/uefi]} {
set grub2_path [get_grub2_dir]
exec mkdir -p [run_dir]/efi/boot
exec cp $grub2_path/boot/grub2/grub2_32.efi [run_dir]/efi/boot/bootia32.efi
exec cp $grub2_path/boot/grub2/grub2_64.efi [run_dir]/efi/boot/bootx64.efi
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
}
#
# Generate GRUB2 config file
@ -132,8 +122,9 @@ proc run_boot_dir {binaries} {
set fh [open "[run_dir]/boot/grub/grub.cfg" "WRONLY CREAT TRUNC"]
puts $fh "set timeout=0"
puts $fh "menuentry 'Genode on base-hw' {"
puts $fh " multiboot2 /boot/bender serial_fallback"
puts $fh " module2 /image.elf"
puts $fh " insmod multiboot"
puts $fh " multiboot /boot/bender"
puts $fh " module /image.elf image.elf"
puts $fh "}"
close $fh
}

View File

@ -61,31 +61,27 @@ proc run_boot_dir {binaries} {
#
exec gzip [run_dir]/image.elf
if {[have_include "image/iso"] || [have_include "image/disk"]} {
set serial_bender_opt ""
# Install isolinux/GRUB files and bender
#
if {[have_include "image/disk"]} {
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
}
if {[have_include "image/iso"]} {
install_iso_bootloader_to_run_dir
#
# Generate GRUB config file
#
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
puts $fh "timeout 0"
puts $fh "default 0"
puts $fh "\ntitle Genode on NOVA"
puts $fh " kernel /boot/bender"
puts $fh " module /hypervisor iommu serial novpid novga"
puts $fh " module /image.elf.gz"
close $fh
}
if {[have_include image/uefi]} {
set grub2_path [get_grub2_dir]
exec mkdir -p [run_dir]/efi/boot
exec cp [genode_dir]/tool/boot/grub2_32.efi [run_dir]/efi/boot/bootia32.efi
exec cp [genode_dir]/tool/boot/grub2_64.efi [run_dir]/efi/boot/bootx64.efi
exec cp $grub2_path/boot/grub2/grub2_32.efi [run_dir]/efi/boot/bootia32.efi
exec cp $grub2_path/boot/grub2/grub2_64.efi [run_dir]/efi/boot/bootx64.efi
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
set serial_bender_opt "serial_fallback"
}
#
@ -96,7 +92,9 @@ proc run_boot_dir {binaries} {
# tell grub2 to prefer 32bit framebuffer resolution
puts $fh "set gfxpayload=\"0x0x32\""
puts $fh "menuentry 'Genode on NOVA' {"
puts $fh " multiboot2 /boot/bender serial_fallback"
puts $fh " insmod multiboot2"
puts $fh " insmod gzio"
puts $fh " multiboot2 /boot/bender $serial_bender_opt"
puts $fh " module2 /hypervisor hypervisor iommu serial novpid novga"
puts $fh " module2 /image.elf.gz image.elf"
puts $fh "}"

View File

@ -148,25 +148,29 @@ proc run_boot_dir {binaries} {
exec rm -rf [run_dir]/genode
if {[have_include "image/iso"] || [have_include "image/disk"]} {
#
# Install GRUB
#
install_iso_bootloader_to_run_dir
if {[have_include "image/disk"]} {
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
}
if {[have_include "image/iso"]} {
install_iso_bootloader_to_run_dir
}
#
# Generate grub config file
# Generate GRUB config file
#
# The core binary is part of the 'binaries' list but it must
# appear right after 'sigma0' as boot module. Hence the special case.
#
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
puts $fh "timeout 0"
puts $fh "default 0"
puts $fh "hiddenmenu"
puts $fh "\ntitle Genode on OKL4"
puts $fh " kernel /boot/bender"
set fh [open "[run_dir]/boot/grub/grub.cfg" "WRONLY CREAT TRUNC"]
puts $fh "set timeout=0"
puts $fh "menuentry 'Genode on OKL4' {"
puts $fh " insmod multiboot"
puts $fh " multiboot /boot/bender"
puts $fh " module /image.elf"
puts $fh " vbeset 0x117"
puts $fh "}"
close $fh
}

View File

@ -45,25 +45,31 @@ proc run_boot_dir {binaries} {
if {[have_include "image/iso"] || [have_include "image/disk"]} {
#
# Install isolinux/GRUB files and bender
#
install_iso_bootloader_to_run_dir
if {[have_include "image/disk"]} {
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
}
if {[have_include "image/iso"]} {
install_iso_bootloader_to_run_dir
}
#
# Generate grub config file
# Generate GRUB config file
#
# The core binary is part of the 'binaries' list but it must
# appear right after 'sigma0' as boot module. Hence the special case.
#
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
puts $fh "timeout 0"
puts $fh "default 0"
puts $fh "\ntitle Genode on L4ka::Pistachio"
puts $fh " kernel /kickstart"
set fh [open "[run_dir]/boot/grub/grub.cfg" "WRONLY CREAT TRUNC"]
puts $fh "set timeout=0"
puts $fh "menuentry 'Genode on L4ka::Pistachio' {"
puts $fh " insmod multiboot"
puts $fh " multiboot /boot/bender"
puts $fh " module /kickstart"
puts $fh " module /kernel"
puts $fh " module /sigma0"
puts $fh " module /image.elf"
puts $fh "}"
close $fh
}

View File

@ -45,23 +45,41 @@ proc run_boot_dir {binaries} {
file copy -force [run_dir]/genode/sel4 [run_dir]/sel4
exec rm -r [run_dir]/genode
if {[have_include "image/iso"] || [have_include "image/disk"]} {
#
# Install isolinux/GRUB files and bender
#
install_iso_bootloader_to_run_dir
if {[have_include "image/iso"] || [have_include "image/disk"] || [have_include image/uefi]} {
set serial_bender_opt ""
if {[have_include "image/disk"]} {
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
}
if {[have_include "image/iso"]} {
install_iso_bootloader_to_run_dir
}
if {[have_include image/uefi]} {
set grub2_path [get_grub2_dir]
exec mkdir -p [run_dir]/efi/boot
exec cp $grub2_path/boot/grub2/grub2_32.efi [run_dir]/efi/boot/bootia32.efi
exec cp $grub2_path/boot/grub2/grub2_64.efi [run_dir]/efi/boot/bootx64.efi
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
set serial_bender_opt "serial_fallback"
}
#
# Generate GRUB config file
# Generate GRUB2 config file
#
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
puts $fh "timeout 0"
puts $fh "default 0"
puts $fh "\ntitle Genode on seL4"
puts $fh " kernel /boot/bender phys_max=256M"
puts $fh " module /sel4 disable_iommu"
puts $fh " module /image.elf"
set fh [open "[run_dir]/boot/grub/grub.cfg" "WRONLY CREAT TRUNC"]
puts $fh "set timeout=0"
puts $fh "menuentry 'Genode on seL4' {"
puts $fh " insmod multiboot2"
puts $fh " multiboot2 /boot/bender phys_max=256M $serial_bender_opt"
puts $fh " module2 /sel4 sel4 disable_iommu"
puts $fh " module2 /image.elf image.elf"
puts $fh "}"
close $fh
}
@ -82,26 +100,6 @@ proc run_boot_dir {binaries} {
exec [sel4_elfloader_dir]/gen_boot_image.sh [run_dir]/sel4 [run_dir]/genode.elf [run_dir]/image.elf
}
if {[have_spec x86] && [have_include image/uefi]} {
exec mkdir -p [run_dir]/efi/boot
exec cp [genode_dir]/tool/boot/grub2_32.efi [run_dir]/efi/boot/bootia32.efi
exec cp [genode_dir]/tool/boot/grub2_64.efi [run_dir]/efi/boot/bootx64.efi
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
#
# Generate GRUB2 config file
#
set fh [open "[run_dir]/boot/grub/grub.cfg" "WRONLY CREAT TRUNC"]
puts $fh "set timeout=0"
puts $fh "menuentry 'Genode on seL4' {"
puts $fh " multiboot2 /boot/bender phys_max=256M serial_fallback"
puts $fh " module2 /sel4 sel4 disable_iommu"
puts $fh " module2 /image.elf image.elf"
puts $fh "}"
close $fh
}
run_image [run_dir]/image.elf
# set symbolic link to image.elf file in TFTP directory for PXE boot

17
tool/run/grub2.inc Normal file
View File

@ -0,0 +1,17 @@
##
# Determine GRUB2 directory
#
proc get_grub2_dir { } {
set ::env(MAKEFLAGS) s
set grub2_path [exec [genode_dir]/tool/ports/current grub2]
if {![file exists $grub2_path]} {
puts ""
puts "GRUB2 binaries are missing."
puts "You can download the GRUB2 binaries by invoking:"
puts "\ttool/ports/prepare_port grub2"
puts ""
exit 1
}
return $grub2_path
}

View File

@ -6,14 +6,18 @@ source [genode_dir]/tool/run/iso.inc
#
proc run_image { {unused ""} } {
requires_installation_of xorriso
puts "creating ISO image..."
exec rm -f "[run_dir].iso"
set grub2_path [get_grub2_dir]
#
# The 'create_iso' writes diagnostics to stderr, which are interpreted as
# 'xorriso' writes diagnostics to stderr, which are interpreted as
# execution failure by expect unless '-ignorestderr' is set on 'exec'.
#
if {[catch {exec -ignorestderr [genode_dir]/tool/create_iso iso ISO=[run_dir]} ]} {
if {[catch {exec -ignorestderr xorriso -out_charset utf-8 -report_about HINT -as mkisofs -f -l -R -hide-rr-moved -graft-points --modification-date=2017101816570300 -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table --embedded-boot $grub2_path/boot/grub2/embedded.img --protective-msdos-label -o [run_dir].iso -r [run_dir] --sort-weight 0 / --sort-weight 1 /boot} ]} {
puts stderr "Error: ISO image creation failed"
exit -5
}

View File

@ -1,3 +1,5 @@
source [genode_dir]/tool/run/grub2.inc
##
# Create GPT disk image with UEFI boot loaders and content of the run directory
#

View File

@ -1,20 +1,21 @@
##
# Install files needed to create a bootable ISO image
#
# The ISO boot concept uses isolinux to load GRUB, which in turn loads Genode.
# This way we can make use of isolinux' support for booting ISO images from a
# USB stick.
# The ISO boot concept uses GRUB2 and xorriso to boot from ISO and USB stick.
#
source [genode_dir]/tool/run/grub2.inc
proc install_iso_bootloader_to_run_dir { } {
puts "install bootloader"
exec mkdir -p [run_dir]/boot/isolinux
exec cp [genode_dir]/tool/boot/chain.c32 [run_dir]/boot/isolinux
exec cp [genode_dir]/tool/boot/isolinux.bin [run_dir]/boot/isolinux
exec cp [genode_dir]/tool/boot/isolinux.cfg [run_dir]/boot/isolinux
set grub2_path [get_grub2_dir]
exec mkdir -p [run_dir]/boot/grub
exec cp [genode_dir]/tool/boot/stage2_eltorito [run_dir]/boot/grub
exec mkdir -p [run_dir]/boot/grub/i386-pc
exec cp $grub2_path/boot/grub2/eltorito.img [run_dir]/boot/grub/i386-pc/.
foreach file [glob -nocomplain $grub2_path/boot/grub2/\*.mod] {
exec cp $file [run_dir]/boot/grub/i386-pc/[file tail $file]
}
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
}

View File

@ -116,7 +116,7 @@ proc run_power_on { } {
append qemu_args " -cdrom [run_dir].iso "
} else {
if {[have_include "image/disk"]} {
append qemu_args " -hda [run_dir].img "
append qemu_args " -drive format=raw,file=[run_dir].img "
} else {
if {[have_include "image/uefi"]} {
append qemu_args " --bios [genode_dir]/tool/boot/tianocore.bin -net none -drive format=raw,file=[run_dir].img "