From e1883f1d5a1722a2ab088c0dd4906bbdf860c003 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 27 May 2024 20:16:49 +0100 Subject: grub.cfg: use grub_scan_disk to set boot order Previously, grub_scan_disk could set ata, ahci or "both", which would make both be tried (ahci first). This worked when we only dealt with ata and ahci devices, but now we support nvme devices so the logic is inherently flawed. Instead, use grub_scan_disk to store the boot order, e.g.: grub_scan_disk="ahci nvme ata" grub_scan_disk="nvme ata" In the first example, it would make GRUB scan ahci first, then nvme and then ata. In the secontd example, it would make GRUB scan nvme first, and then ata. If "both" is set, or anything other than ahci/ata/nvme, grub_scan_disk is now changed to "nvme ahci ata". Actual grub_scan_disk entries in target.cfg files will now be modified, to match each machine. Signed-off-by: Leah Rowe --- script/roms | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'script/roms') diff --git a/script/roms b/script/roms index f79a8e75..744afc52 100755 --- a/script/roms +++ b/script/roms @@ -150,9 +150,21 @@ configure_target() # Override the above defaults using target.cfg . "$targetdir/target.cfg" - [ -z "$grub_scan_disk" ] && grub_scan_disk="both" - [ "$grub_scan_disk" != "both" ] && [ "$grub_scan_disk" != "ata" ] && \ - [ "$grub_scan_disk" != "ahci" ] && grub_scan_disk="both" + [ -z "$grub_scan_disk" ] && grub_scan_disk="nvme ahci ata" + _ata="" + _ahci="" + _nvme="" + _grub_scan_disk="" + for _disk in $grub_scan_disk; do + [ "$_disk" != "nvme" ] && [ "$_disk" != "ahci" ] && \ + [ "$_disk" != "ata" ] && _grub_scan_disk="nvme ahci ata" \ + && break + eval "[ -n \"\$_$_disk\" ] && continue" + eval "_$_disk=\"$_disk\"" + _grub_scan_disk="$_grub_scan_disk $_disk" + done + [ -z "$_grub_scan_disk" ] && _grub_scan_disk="nvme ahci ata" + grub_scan_disk="${_grub_scan_disk# }" [ -z "$tree" ] && $err "$board: tree not defined" @@ -333,8 +345,7 @@ build_grub_roms() tmpcfg="$(mktemp -t coreboot_rom.XXXXXXXXXX)" printf "set grub_scan_disk=\"%s\"\n" "$grub_scan_disk" > "$tmpcfg" || \ $err "set grub_scandisk, $grub_scan_disk, $tmpcfg" - [ "$grub_scan_disk" = "both" ] || \ - x_ "$cbfstool" "$tmprom" add -f "$tmpcfg" -n scan.cfg -t raw + x_ "$cbfstool" "$tmprom" add -f "$tmpcfg" -n scan.cfg -t raw printf "set timeout=%s\n" "$grub_timeout" > "$tmpcfg" || \ $err "set timeout, $grub_timeout, $tmpcfg" [ -z "$grub_timeout" ] || x_ "$cbfstool" "$tmprom" add \ -- cgit v1.2.1