summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-07-06 23:36:13 +0100
committerLeah Rowe <leah@libreboot.org>2024-07-07 21:25:07 +0100
commit2f3cc5d379089d3def876fdc276c321236b0698f (patch)
tree98ce7dac2eaf0b9718b4c28226ee56671b5a18c2 /include
parent889afe16891c2b803e0e8c106fc4862e1295f69d (diff)
rom.sh: new file, to replace script/roms
stub it from the trees script. the way it works now, there is less code in the build system. ./build roms this is no longer a thing ./build roms serprog this is also no longer a thing. instead, do: ./update trees -b coreboot targetnamehere ./update trees -b pico-serprog ./update trees -b stm32-vserprog the old commands still works, which causes the new commands to run coreboot roms now appear in elf/, not bin/, as before, but those images now contain payloads. NOTE: to contradict the above: ./build roms is no longer a thing, in that it's now deprecated, but backward compatibility is present for now. it will be removed in a future release. ./build roms list also still works! it will do: ./update trees -b coreboot list also: ./update trees -b grub list this is now possible too if a target "list" is provided, for multi-tree sources, the targets are shown. there is another difference: seagrub roms are now seagrub_, instead of seabios_withgrub. seabios-only roms are no longer provided, where grub is also enabled; only seagrub is used. the user can easily remove the bootorder file, if they want seabios to not try grub first. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rwxr-xr-xinclude/lib.sh1
-rw-r--r--include/rom.sh122
-rwxr-xr-xinclude/vendor.sh2
3 files changed, 123 insertions, 2 deletions
diff --git a/include/lib.sh b/include/lib.sh
index e6a998d2..52187734 100755
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -10,7 +10,6 @@ _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
kbnotice="Insert a .gkb file from config/data/grub/keymap/ as keymap.gkb \
if you want a custom keymap in GRUB; use cbfstool from elf/cbfstool."
-cbelfdir="elf/.coreboot_nopayload_DO_NOT_FLASH"
ifdtool="elf/ifdtool/default/ifdtool"
cbfstool="elf/cbfstool/default/cbfstool"
tmpgit="$PWD/tmp/gitclone"
diff --git a/include/rom.sh b/include/rom.sh
new file mode 100644
index 00000000..7ffd685d
--- /dev/null
+++ b/include/rom.sh
@@ -0,0 +1,122 @@
+#!/usr/bin/env sh
+# SPDX-License-Identifier: GPL-3.0-or-later
+# Copyright (c) 2014-2016,2020-2021,2023-2024 Leah Rowe <leah@libreboot.org>
+# Copyright (c) 2021-2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
+# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
+# Copyright (c) 2022-2023 Alper Nebi Yasak <alpernebiyasak@gmail.com>
+# Copyright (c) 2023 Riku Viitanen <riku.viitanen@protonmail.com>
+
+mkserprog()
+{
+ basename -as .h "$serdir/"*.h > "$TMPDIR/ser" || $err "!mk $1 $TMPDIR"
+
+ while read -r sertarget; do
+ [ "$1" = "rp2040" ] && x_ cmake -DPICO_BOARD="$sertarget" \
+ -DPICO_SDK_PATH="$picosdk" -B "$sersrc/build" "$sersrc" \
+ && x_ cmake --build "$sersrc/build"
+ [ "$1" = "stm32" ] && x_ make -C "$sersrc" \
+ libopencm3-just-make BOARD=$sertarget && x_ make -C \
+ "$sersrc" BOARD=$sertarget; x_ mkdir -p "bin/serprog_$1"
+ x_ mv "$serx" "bin/serprog_$1/serprog_$sertarget.${serx##*.}"
+ done < "$TMPDIR/ser"
+
+ [ "$XBMK_RELEASE" = "y" ] && mkrom_tarball "bin/serprog_$1"; return 0
+}
+
+mkpayload_grub()
+{
+ eval `setvars "" grub_modules grub_install_modules`
+ eval `setcfg "$grubdata/module/$tree"`
+
+ x_ rm -f "$cdir/grub.elf"
+
+ "${cdir}/grub-mkstandalone" --grub-mkimage="${cdir}/grub-mkimage" \
+ -O i386-coreboot -o "${cdir}/grub.elf" -d "${cdir}/grub-core/" \
+ --fonts= --themes= --locales= --modules="$grub_modules" \
+ --install-modules="$grub_install_modules" \
+ "/boot/grub/grub_default.cfg=${cdir}/.config" \
+ "/boot/grub/grub.cfg=$grubdata/memdisk.cfg" \
+ "/background.png=$grubdata/background/background1280x800.png" || \
+ $err "$tree: cannot build grub.elf"; return 0
+}
+
+mkcorebootbin()
+{
+ [ "$target" = "$tree" ] && return 0
+
+ tmprom="$cdir/build/coreboot.rom"
+ initmode="${defconfig##*/}"; displaymode="${initmode##*_}"
+ initmode="${initmode%%_*}"
+ [ -n "$displaymode" ] && displaymode="_$displaymode"
+ cbfstool="elf/cbfstool/$tree/cbfstool"
+
+ [ -n "$uboot_config" ] || uboot_config="default"
+ [ "$payload_uboot" = "y" ] || payload_seabios="y"
+ [ "$payload_grub" = "y" ] && payload_seabios="y"
+ [ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "y" ] && \
+ $err "$target: U-Boot and SeaBIOS/GRUB are both enabled."
+
+ [ -z "$grub_scan_disk" ] && grub_scan_disk="nvme ahci ata"
+
+ [ -n "$grubtree" ] || grubtree="default"
+ grubelf="elf/grub/$grubtree/payload/grub.elf"
+
+ [ "$payload_memtest" = "y" ] || payload_memtest="n"
+ [ "$(uname -m)" = "x86_64" ] || payload_memtest="n"
+
+ x_ ./update trees -b coreboot utils $tree
+
+ [ "$payload_seabios" = "y" ] && pname="seabios" && add_seabios
+ [ "$payload_uboot" = "y" ] && pname="uboot" && add_uboot
+
+ newrom="bin/$target/${pname}_${target}_$initmode$displaymode.rom"
+ x_ mkdir -p "${newrom%/*}"; x_ mv "$tmprom" "$newrom"
+
+ [ "$XBMK_RELEASE" = "y" ] || return 0
+ mksha512sum "$newrom" "vendorhashes"
+ ./vendor inject -r "$newrom" -b "$target" -n nuke || $err "!n $newrom"
+}
+
+add_seabios()
+{
+ _seabioself="elf/seabios/default/$initmode/bios.bin.elf"
+
+ cbfs "$tmprom" "$_seabioself" "fallback/payload"
+ x_ "$cbfstool" "$tmprom" add-int -i 3000 -n etc/ps2-keyboard-spinup
+
+ _z="2"; [ "$initmode" = "vgarom" ] && _z="0"
+ x_ "$cbfstool" "$tmprom" add-int -i $_z -n etc/pci-optionrom-exec
+ x_ "$cbfstool" "$tmprom" add-int -i 0 -n etc/optionroms-checksum
+ [ "$initmode" = "libgfxinit" ] && \
+ cbfs "$tmprom" "$seavgabiosrom" vgaroms/seavgabios.bin raw
+
+ [ "$payload_memtest" = "y" ] && cbfs "$tmprom" \
+ "elf/memtest86plus/memtest.bin" img/memtest
+
+ [ "$payload_grub" = "y" ] && pname="seagrub" && add_grub; return 0
+}
+
+add_grub()
+{
+ cbfs "$tmprom" "$grubelf" "img/grub2"
+ printf "set grub_scan_disk=\"%s\"\n" "$grub_scan_disk" \
+ > "$TMPDIR/tmpcfg" || $err "$target: !insert scandisk"
+ cbfs "$tmprom" "$TMPDIR/tmpcfg" scan.cfg raw
+ cbfs "$tmprom" "$grubdata/bootorder" bootorder raw
+}
+
+add_uboot()
+{
+ ubdir="elf/u-boot/$target/$uboot_config"
+ ubootelf="$ubdir/u-boot.elf" && [ ! -f "$ubootelf" ] && \
+ ubootelf="$ubdir/u-boot"
+ [ -f "$ubootelf" ] || $err "cb/$target: Can't find u-boot"
+
+ cbfs "$tmprom" "$ubootelf" "fallback/payload"
+}
+
+mkcoreboottar()
+{
+ [ "$target" = "$tree" ] && return 0
+ [ "$XBMK_RELEASE" = "y" ] && mkrom_tarball "bin/$target"; return 0
+}
diff --git a/include/vendor.sh b/include/vendor.sh
index e282eedd..75f7e051 100755
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -248,7 +248,7 @@ detect_board()
path="$1"
filename="$(basename "$path")"
case "$filename" in
- grub_*) board="$(echo "$filename" | cut -d '_' -f2-3)" ;;
+ grub_*|seagrub_*) board="$(echo "$filename" | cut -d '_' -f2-3)" ;;
seabios_withgrub_*)
board="$(echo "$filename" | cut -d '_' -f3-4)" ;;
*.tar.xz)