diff --git a/board/amd64/grub.cfg b/board/amd64/grub.cfg index ee62c6e41..192017165 100644 --- a/board/amd64/grub.cfg +++ b/board/amd64/grub.cfg @@ -1,29 +1,73 @@ set timeout="1" -set default="primary" -set log="loglevel=4" - load_env ORDER DEBUG +if [ -z "$ORDER" ]; then + set ORDER="primary secondary" +fi + +set ORDER="$ORDER reboot" + for slot in $ORDER; do - set default="$slot" - break + if [ -z "$default" ]; then + set default="$slot" + else + # Contrary to what the documentation says, GRUB (2.06) does + # not support using titles or IDs in the fallback variable, so + # we translate to indices. + if [ "$slot" = "primary" ]; then + set fallback="$fallback 0" + elif [ "$slot" = "secondary" ]; then + set fallback="$fallback 1" + elif [ "$slot" = "net" ]; then + set fallback="$fallback 2" + elif [ "$slot" = "reboot" ]; then + set fallback="$fallback 3" + fi + fi done if [ "$DEBUG" ]; then set log="debug" +else + set log="loglevel=4" fi submenu "primary" "$log" { - set slot="$1" - set append="$2" - set root=(hd0,gpt3) - source /boot/grub/grub.cfg + set slot="$1" + set append="console=ttyS0 root=PARTLABEL=$slot $2" + set root=(hd0,gpt3) + source /boot/grub/grub.cfg } submenu "secondary" "$log" { + set slot="$1" + set append="console=ttyS0 root=PARTLABEL=$slot $2" + set root=(hd0,gpt4) + source /boot/grub/grub.cfg +} + +submenu "net" "$log" { + net_dhcp + + if [ "$net_efinet0_dhcp_next_server" -a "$net_efinet0_dhcp_boot_file" ]; then + set initrd=(tftp,$net_efinet0_dhcp_next_server)/$net_efinet0_dhcp_boot_file + loopback initrd $initrd + set root=(initrd) + set slot="$1" - set append="$2" - set root=(hd0,gpt4) + set append="console=ttyS0 root=/dev/ram ramdisk_size=65536 $2" source /boot/grub/grub.cfg + else + if [ -z "$net_efinet0_dhcp_next_server" ]; then + echo "No TFTP server supplied in DHCP response" + fi + if [ -z "$net_efinet0_dhcp_boot_file" ]; then + echo "No bootfile supplied in DHCP response" + fi + fi +} + +submenu "reboot" { + reboot } diff --git a/board/amd64/grubenv b/board/amd64/grubenv index 242f68093..b1eb67d38 100644 --- a/board/amd64/grubenv +++ b/board/amd64/grubenv @@ -1,8 +1,10 @@ # GRUB Environment Block # WARNING: Do not edit this file by tools other than grub-editenv!!! -ORDER=primary secondary +ORDER=primary secondary net primary_OK=1 secondary_OK=1 +net_OK=1 primary_TRY=0 secondary_TRY=0 -################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################ \ No newline at end of file +net_TRY=0 +######################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### \ No newline at end of file diff --git a/board/amd64/rootfs/boot/grub/grub.cfg b/board/amd64/rootfs/boot/grub/grub.cfg index 6fd71f727..e02660ec2 100644 --- a/board/amd64/rootfs/boot/grub/grub.cfg +++ b/board/amd64/rootfs/boot/grub/grub.cfg @@ -1,3 +1,6 @@ menuentry "Infix" --id infix { - linux /boot/bzImage root=PARTLABEL=$slot rauc.slot=$slot console=ttyS0 $append nokaslr + linux /boot/bzImage rauc.slot=$slot nokaslr $append + if [ "$initrd" ]; then + initrd $initrd + fi } diff --git a/board/amd64/rootfs/etc/rauc/system.conf b/board/amd64/rootfs/etc/rauc/system.conf index acc81dd4a..1dce71f88 100644 --- a/board/amd64/rootfs/etc/rauc/system.conf +++ b/board/amd64/rootfs/etc/rauc/system.conf @@ -16,3 +16,7 @@ bootname=primary [slot.rootfs.1] device=/dev/disk/by-partlabel/secondary bootname=secondary + +[slot.net.0] +device=/dev/ram +bootname=net diff --git a/configs/amd64_defconfig b/configs/amd64_defconfig index 650d1711e..e3aa1ffeb 100644 --- a/configs/amd64_defconfig +++ b/configs/amd64_defconfig @@ -103,7 +103,7 @@ BR2_TARGET_ROOTFS_SQUASHFS=y BR2_TARGET_EDK2=y BR2_TARGET_GRUB2=y BR2_TARGET_GRUB2_X86_64_EFI=y -BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI="boot linux ext2 fat squash4 part_gpt normal efi_gop configfile loadenv test terminfo terminal echo" +BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI="boot linux ext2 squash4 part_gpt normal efi_gop configfile loadenv test echo reboot net efinet tftp loopback" BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI="${BR2_EXTERNAL_INFIX_PATH}/board/amd64/grub-embed.cfg" BR2_TARGET_GRUB2_INSTALL_TOOLS=y BR2_PACKAGE_HOST_DOSFSTOOLS=y