rom.sh: support grub-first setups

in this setup, seabios is never the default payload, grub is,
but only if grub is enabled.

set this in target.cfg:

payload_grubsea="y"

if payload_grub isn't enabled, this is auto-set to n

ditto if initmode=normal

NOTE: if flashing libgfx setups, you should make sure
that you're not booting with a graphics card, only intel
graphics. this setting will intentionally not be documented,
because it's not recommended, but is being implemented for
testing purposes (and i implemented it for some guy who i
think is cool). i'll probably also use this myself, since
i already do grub-only setups on all my own machines.

seagrub is the default on x86 because of past instabilities
with grub. to mitigate in case of future issues, since seabios
is always stable, we reduce the chance of bricks.

Signed-off-by: Leah Rowe <leah@libreboot.org>
master
Leah Rowe 2024-12-18 06:49:08 +00:00
parent f7801ef477
commit 1dd32ea548
2 changed files with 19 additions and 6 deletions

View File

@ -6,7 +6,7 @@ build_depend="seabios/default grub/default memtest86plus u-boot/amd64coreboot"
seavgabiosrom="elf/seabios/default/libgfxinit/vgabios.bin"
pv="payload_uboot payload_seabios payload_memtest payload_grub"
pv="$pv payload_uboot_i386 payload_uboot_amd64"
pv="$pv payload_uboot_i386 payload_uboot_amd64 payload_grubsea"
v="initmode ubootelf grub_scan_disk uboot_config grubtree grubelf pname"
v="$v displaymode tmprom newrom"
eval `setvars "n" $pv`

View File

@ -120,6 +120,10 @@ mkcorebootbin()
[ "$payload_memtest" = "y" ] || payload_memtest="n"
[ "$(uname -m)" = "x86_64" ] || payload_memtest="n"
[ "$payload_grubsea" = "y" ] && [ "$initmode" = "normal" ] && \
payload_grubsea="n"
[ "$payload_grub" = "y" ] || payload_grubsea="n"
if $dry grep "CONFIG_PAYLOAD_NONE=y" "$defconfig"; then
[ "$payload_seabios" = "y" ] && pname="seabios" && \
$dry add_seabios
@ -138,7 +142,9 @@ add_seabios()
_seabioself="elf/seabios/default/$initmode/bios.bin.elf"
cbfs "$tmprom" "$_seabioself" "fallback/payload"
_seaname="fallback/payload" && [ "$payload_grubsea" = "y" ] && \
_seaname="seabios.elf"
cbfs "$tmprom" "$_seabioself" "$_seaname"
x_ "$cbfstool" "$tmprom" add-int -i 3000 -n etc/ps2-keyboard-spinup
_z="2"; [ "$initmode" = "vgarom" ] && _z="0"
@ -152,15 +158,18 @@ add_seabios()
[ "$payload_grub" = "y" ] && add_grub
cprom
[ "$payload_grubsea" != "y" ] && cprom
[ "$payload_uboot_amd64" = "y" ] && [ "$displaymode" != "txtmode" ] && \
[ "$initmode" != "normal" ] && pname="seauboot" && cprom "seauboot"
[ "$initmode" != "normal" ] && [ "$payload_grubsea" != "y" ] && \
pname="seauboot" && cprom "seauboot"
[ "$payload_grub" = "y" ] && pname="seagrub" && mkseagrub; :
}
add_grub()
{
cbfs "$tmprom" "$grubelf" "img/grub2"
_grubname="img/grub2" && [ "$payload_grubsea" = "y" ] && \
_grubname="fallback/payload"
cbfs "$tmprom" "$grubelf" "$_grubname"
printf "set grub_scan_disk=\"%s\"\n" "$grub_scan_disk" \
> "$TMPDIR/tmpcfg" || $err "$target: !insert scandisk"
cbfs "$tmprom" "$TMPDIR/tmpcfg" scan.cfg raw
@ -171,7 +180,11 @@ add_grub()
mkseagrub()
{
cbfs "$tmprom" "$grubdata/bootorder" bootorder raw
if [ "$payload_grubsea" = "y" ]; then
pname="grub"
else
cbfs "$tmprom" "$grubdata/bootorder" bootorder raw
fi
for keymap in config/data/grub/keymap/*.gkb; do
[ -f "$keymap" ] && cprom "${keymap##*/}"; :
done; :