diff --git a/repos/base-fiasco/run/env b/repos/base-fiasco/run/env index 46a724d66..ebf324d47 100644 --- a/repos/base-fiasco/run/env +++ b/repos/base-fiasco/run/env @@ -120,7 +120,8 @@ proc build_boot_image {binaries} { puts $fh "timeout 0" puts $fh "default 0" puts $fh "\ntitle Genode on L4/Fiasco" - puts $fh " kernel /fiasco/bootstrap -serial -modaddr=0x02000000" + puts $fh " kernel /boot/bender" + puts $fh " module /fiasco/bootstrap -serial -modaddr=0x02000000" puts $fh " module /fiasco/fiasco -serial -jdb_cmd=JH $fiasco_serial_esc_arg" puts $fh " module /fiasco/sigma0" puts $fh " module /genode/core" @@ -137,6 +138,7 @@ proc build_boot_image {binaries} { install_pxe_bootloader_to_run_dir create_iso_image_from_run_dir + create_disk_image_from_run_dir # # Generate pulsar config file diff --git a/repos/base-foc/run/env b/repos/base-foc/run/env index 107ac1fbc..3418e2f73 100644 --- a/repos/base-foc/run/env +++ b/repos/base-foc/run/env @@ -161,7 +161,8 @@ proc build_boot_image_x86 {binaries} { puts $fh "timeout 0" puts $fh "default 0" puts $fh "\ntitle Genode on Fiasco.OC" - puts $fh " kernel /fiasco/bootstrap -modaddr=0x01100000" + puts $fh " kernel /boot/bender" + puts $fh " module /fiasco/bootstrap -modaddr=0x01100000" puts $fh " module /fiasco/fiasco $fiasco_serial_esc_arg" puts $fh " module /fiasco/sigma0" puts $fh " module /genode/core" @@ -174,6 +175,7 @@ proc build_boot_image_x86 {binaries} { install_pxe_bootloader_to_run_dir create_iso_image_from_run_dir + create_disk_image_from_run_dir # # Generate pulsar config file diff --git a/repos/base-nova/run/env b/repos/base-nova/run/env index e9e4d00ce..de7185a79 100644 --- a/repos/base-nova/run/env +++ b/repos/base-nova/run/env @@ -83,6 +83,7 @@ proc build_boot_image {binaries} { install_pxe_bootloader_to_run_dir create_iso_image_from_run_dir + create_disk_image_from_run_dir # # Generate pulsar config file diff --git a/repos/base-okl4/run/env b/repos/base-okl4/run/env index b8ec42c51..29e38a308 100644 --- a/repos/base-okl4/run/env +++ b/repos/base-okl4/run/env @@ -200,11 +200,13 @@ proc build_boot_image {binaries} { puts $fh "default 0" puts $fh "hiddenmenu" puts $fh "\ntitle Genode on OKL4" - puts $fh "kernel /image.elf" - puts $fh "vbeset 0x117" + puts $fh " kernel /boot/bender" + puts $fh " module /image.elf" + puts $fh " vbeset 0x117" close $fh create_iso_image_from_run_dir + create_disk_image_from_run_dir # # Generate pulsar config file diff --git a/repos/base-pistachio/run/env b/repos/base-pistachio/run/env index 3a23f3f80..2400a99fb 100644 --- a/repos/base-pistachio/run/env +++ b/repos/base-pistachio/run/env @@ -115,6 +115,7 @@ proc build_boot_image {binaries} { install_pxe_bootloader_to_run_dir create_iso_image_from_run_dir + create_disk_image_from_run_dir # # Generate pulsar config file diff --git a/tool/README b/tool/README index 3cb7e7b01..826b47c0c 100644 --- a/tool/README +++ b/tool/README @@ -23,6 +23,19 @@ of Genode. This simple tool helps to build bootable ISO images from your build of Genode. For getting usage information, start the tool without arguments. +:'create_grub2': + + This tool prepares a partitioned disk image with GRUB2 as boot + loader. + +:'grub2-head.img': + + This file is the head part of a partioned disk image including an + installation of GRUB2 as boot loader. GRUB2 is available from + http://www.gnu.org/software/grub/ and in major Linux distributions. + Steps to reproduce the image creation can be found in + 'create_grub2'. + :'beautify': Beautify is a coding-style checking tool that analyzes source code for its diff --git a/tool/boot/README b/tool/boot/README index 8a0db2d96..6a3c3b1d8 100644 --- a/tool/boot/README +++ b/tool/boot/README @@ -13,7 +13,7 @@ code respectively the download source of binaries are described below. 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. diff --git a/tool/create_grub2 b/tool/create_grub2 new file mode 100755 index 000000000..aa8f2cce2 --- /dev/null +++ b/tool/create_grub2 @@ -0,0 +1,77 @@ +#!/bin/bash +# +# \brief Create hard-disk image bootable via GRUB2 +# \author Christian Helmuth +# \date 2014-07-11 +# +# We generate an head-image file only. This image contains MBR, label +# (partition table), and one primary partition where GRUB2 is installed. The +# image size fits only the GRUB2 binaries and must be extended later to include +# further binaries and data. +# +# Some parts of this script must be executed with superuser privileges and +# utilize 'sudo' for this purpose. + +set -e +#set -x + +# +# config +# + +head_size="4MiB" + head_img="grub2-head.img" + +# generate image file +if [ -f $head_img ]; then + echo "$head_img exists. Exiting..." + exit 1 +fi +fallocate -l $head_size $head_img + +# prepare label and partition table +parted="parted -s $head_img -- unit MiB" + +$parted "mklabel msdos" +$parted "mkpart primary ext2 1MiB 4MiB" + +# loop image as disk (loop0) and partition 1 (loop1) +sudo losetup /dev/loop0 $head_img +sudo losetup /dev/loop1 $head_img -o 1MiB + +# initialize ext2 on partition +sudo mkfs.ext2 /dev/loop1 -L GENODE -q + +# install GRUB2 +mnt=$(mktemp -d) + +sudo mount /dev/loop1 $mnt + +sudo grub-install --root-directory=$mnt --no-floppy \ + --modules="biosdisk part_msdos ext2" /dev/loop0 + +# generate GRUB2 configuration +cfg=$(mktemp) + +cat > $cfg < ... disk size in MiB +# +proc create_disk_image_from_run_dir { } { + + global run_target + + if {![regexp "disk" $run_target]} { return } + + requires_installation_of parted + requires_installation_of resize2fs + requires_installation_of fallocate + + set grub_img "[genode_dir]/tool/grub2-head.img" + set disk_img "[run_dir].img" + set part1_img "[run_dir]-part1.img" + set run_size [expr [regsub {\s.*} [exec du -sm [run_dir]] {}] + 4] + set disk_size [get_cmd_arg --disk-size $run_size] + set part1_size [expr $disk_size - 1]MiB + + # extract and resize partition image + exec dd if=$grub_img of=$part1_img bs=1M skip=1 2>/dev/null + exec fallocate -l $part1_size $part1_img + exec resize2fs $part1_img 2>/dev/null + + # populate partition with binaries + exec [genode_dir]/tool/rump -F ext2fs -p [run_dir] $part1_img + + # merge final image from GRUB2 head and partition + exec dd if=$grub_img of=$disk_img status=noxfer bs=1M count=1 2>/dev/null + exec dd if=$part1_img of=$disk_img status=noxfer bs=1M seek=1 2>/dev/null + exec parted -s $disk_img -- rm 1 mkpart primary 2048s -1s + + exec rm -f $part1_img + + puts "Created image file $disk_img ($disk_size MiB)" +} + + ## # Wait for a specific output of a already running spawned process # @@ -572,7 +614,7 @@ proc is_amt_available { } { if {![have_spec x86] || ![regexp "amt" $run_target]} { return false } - if {[info exists ::env(AMT_TEST_MACHINE_IP)] && + if {[info exists ::env(AMT_TEST_MACHINE_IP)] && [info exists ::env(AMT_TEST_MACHINE_PWD)] && [have_installed amtterm] && [have_installed amttool]} { @@ -596,7 +638,7 @@ proc is_serial_available { } { ## -# Execute scenario using Intel's AMT +# Execute scenario using Intel's AMT # proc spawn_amt { wait_for_re timeout_value } { global spawn_id