summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--[-rwxr-xr-x]include/git.sh66
-rw-r--r--[-rwxr-xr-x]include/lib.sh80
-rw-r--r--[-rwxr-xr-x]include/mrc.sh0
-rw-r--r--include/rom.sh227
-rw-r--r--[-rwxr-xr-x]include/vendor.sh164
5 files changed, 413 insertions, 124 deletions
diff --git a/include/git.sh b/include/git.sh
index b0acd7dc..2c43cd22 100755..100644
--- a/include/git.sh
+++ b/include/git.sh
@@ -2,18 +2,18 @@
# Copyright (c) 2020-2021,2023-2024 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
-eval `setvars "" loc url bkup_url subfile mdir subhash subrepo subrepo_bkup \
- depend subfile_bkup`
+eval `setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \
+ depend subfile_bkup repofail`
fetch_targets()
{
[ -n "$tree_depend" ] && [ "$tree_depend" != "$tree" ] && \
- x_ ./update trees -f "$project" "$tree_depend"
+ x_ ./mk -f "$project" "$tree_depend"
e "src/$project/$tree" d && return 0
printf "Creating %s tree %s\n" "$project" "$tree"
- git_prep "$loc" "$loc" "$PWD/$cfgsdir/$tree/patches" \
- "${loc%/*}/$tree" u; nuke "$project/$tree" "$project/$tree"
+ git_prep "$loc" "$loc" "$PWD/$configdir/$tree/patches" \
+ "src/$project/$tree" u; nuke "$project/$tree" "$project/$tree"
}
fetch_project()
@@ -23,10 +23,10 @@ fetch_project()
chkvars url
- [ -n "$xtree" ] && x_ ./update trees -f coreboot "$xtree"
+ [ -n "$xtree" ] && x_ ./mk -f coreboot "$xtree"
[ -z "$depend" ] || for d in $depend ; do
printf "'%s' needs '%s'; grabbing '%s'\n" "$project" "$d" "$d"
- x_ ./update trees -f $d
+ x_ ./mk -f $d
done
clone_project
@@ -37,41 +37,32 @@ fetch_project()
clone_project()
{
- loc="src/$project/$project" && singletree "$project" && loc="${loc%/*}"
-
+ loc="$XBMK_CACHE/repo/$project" && singletree "$project" && \
+ loc="src/$project"
printf "Downloading project '%s' to '%s'\n" "$project" "$loc"
- e "$loc" d && return 0
- remkdir "${tmpgit%/*}"
- git_prep "$url" "$bkup_url" "$PWD/config/$project/patches" "$loc"
+ e "$loc" d missing && remkdir "${tmpgit%/*}" && git_prep \
+ "$url" "$bkup_url" "$PWD/config/$project/patches" "$loc"; :
}
git_prep()
{
- _patchdir="$3" # $1 and $2 are gitrepo and gitrepo_backup
- _loc="$4"
-
- chkvars rev
+ _patchdir="$3"; _loc="$4" # $1 and $2 are gitrepo and gitrepo_backup
- tmpclone "$1" "$2" "$tmpgit" "$rev" "$_patchdir"
+ chkvars rev; tmpclone "$1" "$2" "$tmpgit" "$rev" "$_patchdir"
if singletree "$project" || [ $# -gt 4 ]; then
- prep_submodules "$_loc"
- fi
+ prep_submodules "$_loc"; fi
[ "$project" = "coreboot" ] && [ -n "$xtree" ] && [ $# -gt 2 ] && \
[ "$xtree" != "$tree" ] && link_crossgcc "$_loc"
-
- [ "$XBMK_RELEASE" = "y" ] && [ "$_loc" != "src/$project/$project" ] \
- && rmgit "$tmpgit"
+ [ "$XBMK_RELEASE" = "y" ] && \
+ [ "$_loc" != "$XBMK_CACHE/repo/$project" ] && rmgit "$tmpgit"
move_repo "$_loc"
}
prep_submodules()
{
- mdir="$PWD/config/submodule/$project"
- [ -n "$tree" ] && mdir="$mdir/$tree"
-
[ -f "$mdir/module.list" ] && while read -r msrcdir; do
fetch_submodule "$msrcdir"
done < "$mdir/module.list"; return 0
@@ -88,7 +79,6 @@ fetch_submodule()
_seval="if [ -n \"\$sub$xt\" ] || [ -n \"\$sub${xt}_bkup\" ]"
eval "$_seval; then st=\"\$st \$xt\"; fi"
done
-
st="${st# }" && [ "$st" = "repo file" ] && $err "$mdir: repo+file"
[ -z "$st" ] && return 0 # subrepo/subfile not defined
@@ -101,11 +91,33 @@ fetch_submodule()
"$mdir/${1##*/}/patches"
}
+livepull="n"
tmpclone()
{
- git clone $1 "$3" || git clone $2 "$3" || $err "!clone $1 $2 $3 $4 $5"
+ [ "$repofail" = "y" ] && \
+ printf "Cached clone failed; trying online.\n" 1>&2 && livepull="y"
+
+ repofail="n"
+
+ [ $# -lt 6 ] || rm -Rf "$3" || $err "git retry: !rm $3 ($1)"
+ repodir="$XBMK_CACHE/repo/${1##*/}" && [ $# -gt 5 ] && repodir="$3"
+ mkdir -p "$XBMK_CACHE/repo" || $err "!rmdir $XBMK_CACHE/repo"
+
+ if [ "$livepull" = "y" ] && [ ! -d "$repodir" ]; then
+ git clone $1 "$repodir" || git clone $2 "$repodir" || \
+ $err "!clone $1 $2 $repodir $4 $5" #
+ elif [ -d "$repodir" ] && [ $# -lt 6 ]; then
+ git -C "$repodir" pull || sleep 3 || git -C "$repodir" pull \
+ || sleep 3 || git -C "$repodir" pull || :
+ fi
+ (
+ [ $# -gt 5 ] || git clone "$repodir" "$3" || $err "!clone $repodir $3"
git -C "$3" reset --hard "$4" || $err "!reset $1 $2 $3 $4 $5"
git_am_patches "$3" "$5"
+ ) || repofail="y"
+
+ [ "$repofail" = "y" ] && [ $# -lt 6 ] && tmpclone $@ retry
+ [ "$repofail" = "y" ] && $err "!clone $1 $2 $3 $4 $5"; :
}
git_am_patches()
diff --git a/include/lib.sh b/include/lib.sh
index e6a998d2..e439ef8b 100755..100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -7,10 +7,7 @@ export LC_COLLATE=C
export LC_ALL=C
_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"
@@ -38,7 +35,7 @@ chkvars()
}
eval `setvars "" _nogit board xbmk_parent versiondate projectsite projectname \
- aur_notice cfgsdir datadir version relname`
+ aur_notice configdir datadir version relname`
for fv in projectname projectsite version versiondate; do
eval "[ ! -f "$fv" ] || read -r $fv < \"$fv\" || :"
@@ -59,8 +56,7 @@ e()
estr="[ -$es_t \"\$1\" ] || return 1"
[ $# -gt 2 ] && estr="[ -$es_t \"\$1\" ] && return 1" && es2="missing"
- eval "$estr"
- printf "%s %s\n" "$1" "$es2" 1>&2
+ eval "$estr"; printf "%s %s\n" "$1" "$es2" 1>&2
}
install_packages()
@@ -89,6 +85,14 @@ if [ -z "${TMPDIR+x}" ]; then
xbmk_parent="y"
fi
+# XBMK_CACHE is a directory, for caching downloads and git repositories
+[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$PWD/cache"
+[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache"
+[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$PWD/cache" ] && \
+ $err "cachedir is default, $PWD/cache, but it exists and is a symlink"
+[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache"
+[ -f "$XBMK_CACHE" ] && $err "cachedir '$XBMK_CACHE' exists but it's a file"
+
# if "y": a coreboot target won't be built if target.cfg says release="n"
# (this is used to exclude certain build targets from releases)
[ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n"
@@ -99,7 +103,8 @@ expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \
1>/dev/null 2>/dev/null || export XBMK_THREADS=1 # user gave a non-integer
x_() {
- [ $# -lt 1 ] || $@ || $err "Unhandled non-zero exit: $@"; return 0
+ [ $# -lt 1 ] || $@ || \
+ $err "Unhandled non-zero exit: $(echo "$@")"; return 0
}
[ -e ".git" ] || [ -f "version" ] || printf "unknown\n" > version || \
@@ -114,8 +119,7 @@ versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
for p in projectname version versiondate projectsite; do
- chkvars "$p"
- eval "x_ printf \"%s\\n\" \"\$$p\" > $p"
+ chkvars "$p"; eval "x_ printf \"%s\\n\" \"\$$p\" > $p"
done
relname="$projectname-$version"
export LOCALVERSION="-$projectname-${version%%-*}"
@@ -140,8 +144,7 @@ mkrom_tarball()
printf "%s\n" "$versiondate" > "$1/versiondate" || $err "$1 !vdate"
printf "%s\n" "$projectname" > "$1/projectname" || $err "$1 !pname"
- mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"
- x_ rm -Rf "$1"
+ mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"; x_ rm -Rf "$1"; :
}
mktarball()
@@ -175,36 +178,61 @@ rmgit()
singletree()
{
for targetfile in "config/${1}/"*/target.cfg; do
- [ -e "$targetfile" ] && [ -f "$targetfile" ] && return 1
+ [ -e "$targetfile" ] && [ -f "$targetfile" ] && return 1; :
done; return 0
}
download()
{
- dl_fail="y" # 1 url, 2 url backup, 3 destination, 4 checksum
- vendor_checksum "$4" "$3" 2>/dev/null || dl_fail="n"
+ cached="$XBMK_CACHE/file/$4"
+ dl_fail="n" # 1 url, 2 url backup, 3 destination, 4 checksum
+ vendor_checksum "$4" "$cached" 2>/dev/null && dl_fail="y"
[ "$dl_fail" = "n" ] && e "$3" f && return 0
- x_ mkdir -p "${3%/*}" && for url in "$1" "$2"; do
+ mkdir -p "${3%/*}" "$XBMK_CACHE/file" || \
+ $err "!mkdir '$3' '$XBMK_CACHE/file'"
+ for url in "$1" "$2"; do
[ "$dl_fail" = "n" ] && break
[ -z "$url" ] && continue
- x_ rm -f "$3"
- curl --location --retry 3 -A "$_ua" "$url" -o "$3" || \
- wget --tries 3 -U "$_ua" "$url" -O "$3" || continue
- vendor_checksum "$4" "$3" || dl_fail="n"
- done;
- [ "$dl_fail" = "y" ] && $err "$1 $2 $3 $4: not downloaded"; return 0
+ rm -f "$cached" || $err "!rm -f '$cached'"
+ curl --location --retry 3 -A "$_ua" "$url" -o "$cached" || \
+ wget --tries 3 -U "$_ua" "$url" -O "$cached" || continue
+ vendor_checksum "$4" "$cached" || dl_fail="n"
+ done; [ "$dl_fail" = "y" ] && $err "$1 $2 $3 $4: not downloaded"
+ [ "$cached" = "$3" ] || cp "$cached" "$3" || $err "!d cp $cached $3"; :
}
vendor_checksum()
{
[ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1
- printf "Bad checksum for file: %s\n" "$2" 1>&2
- rm -f "$2" || :
+ printf "Bad checksum for file: %s\n" "$2" 1>&2; rm -f "$2" || :; :
}
cbfs()
{
- ccmd="add-payload" && [ $# -gt 3 ] && ccmd="add"
- lzma="-c lzma" && [ $# -gt 3 ] && lzma="-t raw"
- x_ "$cbfstool" "$1" $ccmd -f "$2" -n "$3" $lzma
+ fRom="$1" # image to operate on
+ fAdd="$2" # file to add
+ fName="$3" # filename when added in CBFS
+
+ ccmd="add-payload" && [ $# -gt 3 ] && [ $# -lt 5 ] && ccmd="add"
+ lzma="-c lzma" && [ $# -gt 3 ] && [ $# -lt 5 ] && lzma="-t $4"
+
+ # hack. TODO: do it better. this whole function is cursed
+ if [ $# -gt 4 ]; then
+ # add flat binary for U-Boot (u-boot.bin) on x86
+ if [ "$5" = "0x1110000" ]; then
+ ccmd="add-flat-binary"
+ lzma="-c lzma -l 0x1110000 -e 0x1110000"
+ fi
+ fi
+
+ "$cbfstool" "$fRom" $ccmd -f "$fAdd" -n "$fName" $lzma || \
+ $err "CBFS fail: $fRom $ccmd -f '$fAdd' -n '$fName' $lzma"; :
+}
+
+mk()
+{
+ mk_flag="$1" || $err "No argument given"
+ shift 1 && for mk_arg in $@; do
+ ./mk $mk_flag $mk_arg || $err "./mk $mk_flag $mk_arg"; :
+ done; :
}
diff --git a/include/mrc.sh b/include/mrc.sh
index 2e00d9f9..2e00d9f9 100755..100644
--- a/include/mrc.sh
+++ b/include/mrc.sh
diff --git a/include/rom.sh b/include/rom.sh
new file mode 100644
index 00000000..808f83a4
--- /dev/null
+++ b/include/rom.sh
@@ -0,0 +1,227 @@
+#!/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()
+{
+ [ "$_f" = "-d" ] && return 0 # dry run
+ 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
+}
+
+copyps1bios()
+{
+ x_ rm -Rf bin/playstation
+ x_ mkdir -p bin/playstation
+ x_ cp src/pcsx-redux/src/mips/openbios/openbios.bin bin/playstation
+
+ printf "MIT License\n\nCopyright (c) 2019-2024 PCSX-Redux authors\n\n" \
+ > bin/playstation/COPYING.txt || $err "!pcsx-redux copyright"
+ cat config/snippet/mit >>bin/playstation/COPYING.txt || $err "!pcsx MIT"
+}
+
+mkpayload_grub()
+{
+ eval `setvars "" grub_modules grub_install_modules`
+ $dry eval `setcfg "$grubdata/module/$tree"`
+ $dry x_ rm -f "$srcdir/grub.elf"; $dry \
+ "$srcdir/grub-mkstandalone" --grub-mkimage="$srcdir/grub-mkimage" \
+ -O i386-coreboot -o "$srcdir/grub.elf" -d "${srcdir}/grub-core/" \
+ --fonts= --themes= --locales= --modules="$grub_modules" \
+ --install-modules="$grub_install_modules" \
+ "/boot/grub/grub_default.cfg=${srcdir}/.config" \
+ "/boot/grub/grub.cfg=$grubdata/memdisk.cfg" \
+ "/background.png=$grubdata/background/background1280x800.png" || \
+ $err "$tree: cannot build grub.elf"; return 0
+}
+
+mkvendorfiles()
+{
+ [ -z "$mode" ] && $dry cook_coreboot_config
+ check_coreboot_utils "$tree"
+ printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \
+ $err "!mk $srcdir .coreboot-version"
+ [ -z "$mode" ] && [ "$target" != "$tree" ] && \
+ x_ ./vendor download $target; return 0
+}
+
+cook_coreboot_config()
+{
+ [ -f "$srcdir/.config" ] || return 0
+ printf "CONFIG_CCACHE=y\n" >> "$srcdir/.config" || \
+ $err "$srcdir/.config: Could not enable ccache"
+ make -C "$srcdir" oldconfig || $err "Could not cook $srcdir/.config"; :
+}
+
+check_coreboot_utils()
+{
+ for util in cbfstool ifdtool; do
+ [ "$badhash" = "y" ] && x_ rm -f "elf/$util/$1/$util"
+ e "elf/$util/$1/$util" f && continue
+
+ utilelfdir="elf/$util/$1"
+ utilsrcdir="src/coreboot/$1/util/$util"
+
+ utilmode="" && [ -n "$mode" ] && utilmode="clean"
+ x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $makeargs
+ [ -z "$mode" ] && [ ! -f "$utilelfdir/$util" ] && \
+ x_ mkdir -p "$utilelfdir" && \
+ x_ cp "$utilsrcdir/$util" "elf/$util/$1"
+ [ -z "$mode" ] || x_ rm -Rf "$utilelfdir"; continue
+ done; return 0
+}
+
+mkcorebootbin()
+{
+ [ "$target" = "$tree" ] && return 0
+
+ tmprom="$TMPDIR/coreboot.rom"
+ $dry x_ cp "$srcdir/build/coreboot.rom" "$tmprom"
+
+ initmode="${defconfig##*/}"; displaymode="${initmode##*_}"
+ initmode="${initmode%%_*}"
+ [ -n "$displaymode" ] && displaymode="_$displaymode"
+ cbfstool="elf/cbfstool/$tree/cbfstool"
+
+ [ "$payload_uboot_i386" = "y" ] && \
+ [ "$payload_uboot_amd64" = "y" ] && \
+ $err "'$target' enables 32- and 64-bit x86 U-Boot"
+
+ if [ "$payload_uboot_i386" = "y" ] || \
+ [ "$payload_uboot_amd64" = "y" ]; then
+ printf "'$target' has x86 U-Boot; assuming SeaBIOS=y\n" 1>&2
+ payload_seabios="y"
+ fi
+
+ [ -n "$uboot_config" ] || uboot_config="default"
+ [ "$payload_uboot" = "y" ] || payload_seabios="y"
+ [ "$payload_grub" = "y" ] && payload_seabios="y"
+ [ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "y" ] && \
+ $dry $err "$target: U-Boot(arm64) and SeaBIOS/GRUB 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"
+
+ if $dry grep "CONFIG_PAYLOAD_NONE=y" "$defconfig"; then
+ [ "$payload_seabios" = "y" ] && pname="seabios" && \
+ $dry add_seabios
+ [ "$payload_uboot" = "y" ] && pname="uboot" && $dry add_uboot
+ else
+ pname="custom" && $dry cprom; :
+ fi; :
+}
+
+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
+
+ if [ "$payload_uboot_i386" = "y" ] || \
+ [ "$payload_uboot_amd64" = "y" ]; then
+ $dry add_uboot
+ fi
+
+ [ "$payload_grub" = "y" ] && add_grub
+
+ cprom && [ "$payload_grub" = "y" ] && pname="seagrub" && mkseagrub; :
+}
+
+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
+}
+
+mkseagrub()
+{
+ cbfs "$tmprom" "$grubdata/bootorder" bootorder raw
+ for keymap in config/data/grub/keymap/*.gkb; do
+ [ -f "$keymap" ] && cprom "${keymap##*/}"; :
+ done; :
+}
+
+add_uboot()
+{
+ # TODO: re-work to allow each coreboot target to say which ub tree
+ # instead of hardcoding as in the current logic below:
+
+ # aarch64 targets:
+ ubcbfsargs=""
+ ubpath="fallback/payload"
+ ubtarget="$target"
+ # override for x86/x86_64 targets:
+ if [ "$payload_uboot_i386" = "y" ] || \
+ [ "$payload_uboot_amd64" = "y" ]; then
+ ubcbfsargs="-l 0x1110000 -e 0x1110000" # 64-bit and 32-bit
+ # on 64-bit, 0x1120000 is the SPL, and stub before that
+ ubpath="img/u-boot"
+ ubtarget="amd64coreboot"
+ [ "$payload_uboot_i386" = "y" ] && ubtarget="i386coreboot"; :
+ fi
+
+ ubdir="elf/u-boot/$ubtarget/$uboot_config"
+
+ # aarch64 targets:
+ ubootelf="$ubdir/u-boot.elf" && [ ! -f "$ubootelf" ] && \
+ ubootelf="$ubdir/u-boot"
+ # override for x86/x86_64 targets:
+ [ "$payload_uboot_i386" = "y" ] && ubootelf="$ubdir/u-boot-dtb.bin"
+ [ "$payload_uboot_amd64" = "y" ] && \
+ ubootelf="$ubdir/u-boot-x86-with-spl.bin" # EFI-compatible
+
+ [ -f "$ubootelf" ] || $err "cb/$ubtarget: Can't find u-boot"
+ cbfs "$tmprom" "$ubootelf" "$ubpath" $ubcbfsargs; cprom
+}
+
+cprom()
+{
+ newrom="bin/$target/${pname}_${target}_$initmode$displaymode.rom"
+ [ $# -gt 0 ] && newrom="${newrom%.rom}_${1%.gkb}.rom"
+
+ x_ mkdir -p "bin/$target"
+ x_ cp "$tmprom" "$newrom" && [ $# -gt 0 ] && \
+ cbfs "$newrom" "config/data/grub/keymap/$1" keymap.gkb raw
+
+ [ "$XBMK_RELEASE" = "y" ] || return 0
+ $dry mksha512sum "$newrom" "vendorhashes"; $dry ./vendor inject \
+ -r "$newrom" -b "$target" -n nuke || $err "!nuke $newrom"
+}
+
+mkcoreboottar()
+{
+ [ "$target" = "$tree" ] && return 0; [ "$XBMK_RELEASE" = "y" ] && \
+ [ "$release" != "n" ] && $dry mkrom_tarball "bin/$target"; :
+}
diff --git a/include/vendor.sh b/include/vendor.sh
index e282eedd..0f97a641 100755..100644
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -11,33 +11,45 @@ vendir="vendorfiles"
appdir="$vendir/app"
cbcfgsdir="config/coreboot"
+cv="CONFIG_HAVE_ME_BIN CONFIG_ME_BIN_PATH CONFIG_INCLUDE_SMSC_SCH5545_EC_FW \
+ CONFIG_SMSC_SCH5545_EC_FW_FILE CONFIG_KBC1126_FIRMWARE CONFIG_KBC1126_FW1 \
+ CONFIG_KBC1126_FW2 CONFIG_KBC1126_FW1_OFFSET CONFIG_KBC1126_FW2_OFFSET \
+ CONFIG_VGA_BIOS_FILE CONFIG_VGA_BIOS_ID CONFIG_BOARD_DELL_E6400 \
+ CONFIG_HAVE_MRC CONFIG_MRC_FILE CONFIG_HAVE_REFCODE_BLOB \
+ CONFIG_REFCODE_BLOB_FILE CONFIG_GBE_BIN_PATH CONFIG_IFD_BIN_PATH"
+
eval `setvars "" EC_url_bkup EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \
E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \
- E6400_VGA_romname CONFIG_HAVE_MRC SCH5545EC_DL_url_bkup SCH5545EC_DL_hash \
+ E6400_VGA_romname SCH5545EC_DL_url_bkup SCH5545EC_DL_hash _dest tree \
mecleaner kbc1126_ec_dump MRC_refcode_cbtree new_mac _dl SCH5545EC_DL_url \
- CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_ME_BIN archive EC_url boarddir rom \
- CONFIG_ME_BIN_PATH CONFIG_KBC1126_FIRMWARE _dest tree CONFIG_GBE_BIN_PATH \
- CONFIG_KBC1126_FW1_OFFSET CONFIG_KBC1126_FW2 CONFIG_KBC1126_FW2_OFFSET \
- CONFIG_VGA_BIOS_FILE CONFIG_VGA_BIOS_ID CONFIG_KBC1126_FW1 cbdir DL_url \
- CONFIG_INCLUDE_SMSC_SCH5545_EC_FW CONFIG_SMSC_SCH5545_EC_FW_FILE nukemode \
- CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE CONFIG_HAVE_REFCODE_BLOB cbfstoolref \
- CONFIG_REFCODE_BLOB_FILE vrelease verify _7ztest`
+ archive EC_url boarddir rom cbdir DL_url nukemode cbfstoolref vrelease \
+ verify _7ztest ME_bootguard IFD_platform ifdprefix $cv`
vendor_download()
{
- export PATH="$PATH:/sbin"
-
- [ $# -gt 0 ] || $err "No argument given"
- board="$1" && readcfg && readkconfig && bootstrap && getfiles; return 0
+ [ $# -gt 0 ] || $err "No argument given"; export PATH="$PATH:/sbin"
+ board="$1"; readcfg && readkconfig && bootstrap && getfiles; :
}
readkconfig()
{
check_defconfig "$boarddir" 1>"$TMPDIR/vendorcfg.list" && return 1
+
+ rm -f "$TMPDIR/tmpcbcfg" || $err "!rm -f \"$TMPDIR/tmpcbcfg\""
while read -r cbcfgfile; do
- set +u +e; . "$cbcfgfile" 2>/dev/null; set -u -e
+ for cbc in $cv; do
+ rm -f "$TMPDIR/tmpcbcfg2" || \
+ $err "!rm $TMPDIR/tmpcbcfg2"
+ grep "$cbc" "$cbcfgfile" 1>"$TMPDIR/tmpcbcfg2" \
+ 2>/dev/null || :
+ [ -f "$TMPDIR/tmpcbcfg2" ] || continue
+ cat "$TMPDIR/tmpcbcfg2" >> "$TMPDIR/tmpcbcfg" || \
+ $err "!cat $TMPDIR/tmpcbcfg2"
+ done
done < "$TMPDIR/vendorcfg.list"
+ eval `setcfg "$TMPDIR/tmpcbcfg"`
+
for c in CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN CONFIG_KBC1126_FIRMWARE \
CONFIG_VGA_BIOS_FILE CONFIG_INCLUDE_SMSC_SCH5545_EC_FW; do
eval "[ \"\${$c}\" = \"/dev/null\" ] && continue"
@@ -49,14 +61,12 @@ readkconfig()
bootstrap()
{
- x_ ./update trees -f coreboot ${cbdir##*/}
- for d in uefitool biosutilities bios_extract; do
- x_ ./update trees -b "$d"
- done
+ x_ ./mk -f coreboot ${cbdir##*/}
+ mk -b uefitool biosutilities bios_extract
[ -d "${kbc1126_ec_dump%/*}" ] && x_ make -C "$cbdir/util/kbc1126"
[ -n "$MRC_refcode_cbtree" ] && \
cbfstoolref="elf/cbfstool/$MRC_refcode_cbtree/cbfstool" && \
- x_ ./update trees -b coreboot utils $MRC_refcode_cbtree; return 0
+ x_ ./mk -d coreboot $MRC_refcode_cbtree; return 0
}
getfiles()
@@ -68,9 +78,8 @@ getfiles()
"$CONFIG_SMSC_SCH5545_EC_FW_FILE"
[ -z "$CONFIG_KBC1126_FIRMWARE" ] || fetch kbc1126ec "$EC_url" \
"$EC_url_bkup" "$EC_hash" "$CONFIG_KBC1126_FW1"
- [ -z "$CONFIG_VGA_BIOS_FILE" ] || fetch "e6400vga" \
- "$E6400_VGA_DL_url" "$E6400_VGA_DL_url_bkup" "$E6400_VGA_DL_hash" \
- "$CONFIG_VGA_BIOS_FILE"
+ [ -z "$CONFIG_VGA_BIOS_FILE" ] || fetch e6400vga "$E6400_VGA_DL_url" \
+ "$E6400_VGA_DL_url_bkup" "$E6400_VGA_DL_hash" "$CONFIG_VGA_BIOS_FILE"
[ -z "$CONFIG_HAVE_MRC" ] || fetch "mrc" "$MRC_url" "$MRC_url_bkup" \
"$MRC_hash" "$CONFIG_MRC_FILE"; return 0
}
@@ -78,36 +87,39 @@ getfiles()
fetch()
{
dl_type="$1"; dl="$2"; dl_bkup="$3"; dlsum="$4"; _dest="${5##*../}"
- [ "$5" = "/dev/null" ] && return 0; _dl="$vendir/cache/$dlsum"
+ [ "$5" = "/dev/null" ] && return 0; _dl="$XBMK_CACHE/file/$dlsum"
download "$dl" "$dl_bkup" "$_dl" "$dlsum"
- x_ rm -Rf "${_dl}_extracted"
+ rm -Rf "${_dl}_extracted" || $err "!rm -Rf ${_ul}_extracted"
e "$_dest" f && return 0
mkdir -p "${_dest%/*}" || $err "mkdirs: !mkdir -p ${_dest%/*}"
- remkdir "$appdir"
- extract_archive "$_dl" "$appdir" || [ "$dl_type" = "e6400vga" ] || \
- $err "mkdirs $_dest $dl_type: !extract"
+ remkdir "$appdir"; extract_archive "$_dl" "$appdir" || \
+ [ "$dl_type" = "e6400vga" ] || $err "mkd $_dest $dl_type: !extract"
- eval "extract_$dl_type"
- set -u -e
-
- e "$_dest" f missing && $err "!extract_$dl_type"; return 0
+ eval "extract_$dl_type"; set -u -e
+ e "$_dest" f missing && $err "!extract_$dl_type"; :
}
extract_intel_me()
{
e "$mecleaner" f not && $err "$cbdir: me_cleaner missing"
- _me="$PWD/$_dest" # must always be an absolute path
- cdir="$PWD/$appdir" # must always be an absolute path
+ _me="$PWD/$_dest"; cdir="$PWD/$appdir"
+ if [ "$ME_bootguard" = "me11disreguard" ]; then
+ # run mkukri's util to extract me.bin and disable bootguard
+ # for Dell OptiPlex 3050 Micro, using the deguard util.
+ extract_deguard_me "$cdir" "$_me"
+ return 0
+ fi
+ # All other ME setups are extracted with brute force and me_cleaner:
+
[ $# -gt 0 ] && _me="${1}" && cdir="$2"
e "$_me" f && return 0
- sdir="$(mktemp -d)"
- [ -z "$sdir" ] && return 0
+ sdir="$(mktemp -d)"; [ -z "$sdir" ] && return 0
mkdir -p "$sdir" || $err "extract_intel_me: !mkdir -p \"$sdir\""
set +u +e
@@ -130,14 +142,36 @@ extract_intel_me()
else
continue
fi
- cdir="$1"
- [ "${cdir#/a}" != "$cdir" ] && cdir="${cdir#/}"
+ cdir="$1"; [ "${cdir#/a}" != "$cdir" ] && cdir="${cdir#/}"
cd "$cdir" || :
done
)
rm -Rf "$sdir" || $err "extract_intel_me: !rm -Rf $sdir"
}
+extract_deguard_me()
+{
+ x_ ./mk -f deguard
+ cp -R src/deguard "$1/disreguard" || \
+ $err "Cannot make temporary deguard clone in $1/disreguard"
+ if [ ! -e "$1/disreguard/.git" ]; then
+ git -C "$1/disreguard" init || $err "!init $1/disreguard"
+ git -C "$1/disreguard" add -A . || $err "!add $1/disreguard"
+ git -C "$1/disreguard" commit -m "tmp" || \
+ $err "!commit $1/disreguard"
+ fi
+ git -C "$1/disreguard" am "$PWD/config/data/deguard/appdir.patch" || \
+ $err "Cannot temporarily patch deguard clone in $1/disreguard"
+ (
+ cd "$1/disreguard" || $err "Cannot cd to '$1/disreguard'"
+ x_ ./RUNME.sh
+ ) || $err "$1/disreguard: RUNME.sh returned error status"
+ "$mecleaner" --whitelist MFS --truncate "$1/disreguard/me.bin" || \
+ $err "extract_intel_me: Can't truncate disreguarded ME"
+ cp "$cdir/disreguard/me.bin" "$2" || \
+ $err "extract_intel_me: Can't move disreguarded me.bin"
+}
+
extract_archive()
{
innoextract "$1" -d "$2" || python "$pfs_extract" "$1" -e || 7z x \
@@ -148,8 +182,7 @@ extract_kbc1126ec()
{
e "$kbc1126_ec_dump" f missing && $err "$cbdir: kbc1126 util missing"
(
- x_ cd "$appdir/"
- mv Rompaq/68*.BIN ec.bin || :
+ x_ cd "$appdir/"; mv Rompaq/68*.BIN ec.bin || :
if [ ! -f "ec.bin" ]; then
unar -D ROM.CAB Rom.bin || unar -D Rom.CAB Rom.bin || \
unar -D 68*.CAB Rom.bin || $err "can't extract Rom.bin"
@@ -194,14 +227,10 @@ extract_sch5545ec()
vendor_inject()
{
- set +u +e
-
- [ $# -lt 1 ] && $err "No options specified."
+ set +u +e; [ $# -lt 1 ] && $err "No options specified."
[ "$1" = "listboards" ] && eval "ls -1 config/coreboot || :; exit 0"
- archive="$1"
-
- while getopts n:r:b:m: option; do
+ archive="$1"; while getopts n:r:b:m: option; do
case "$option" in
n) nukemode="$OPTARG" ;;
r) rom="$OPTARG" ;;
@@ -214,11 +243,7 @@ vendor_inject()
check_board || return 0
[ "$nukemode" = "nuke" ] || x_ ./vendor download $board
[ "$vrelease" != "y" ] && patch_rom "$rom"
- [ "$vrelease" = "y" ] && patch_release_roms
-
- [ "$nukemode" = "nuke" ] && return 0
- printf "Friendly reminder (this is *not* an error message):\n"
- printf "Make sure the files were inserted. ALSO:\n%s\n" "$kbnotice"
+ [ "$vrelease" = "y" ] && patch_release_roms; :
}
check_board()
@@ -245,14 +270,13 @@ check_release()
# It will only succeed if the filename is not changed from the build/download
detect_board()
{
- path="$1"
- filename="$(basename "$path")"
+ path="$1"; filename="$(basename "$path")"
case "$filename" in
- grub_*) board="$(echo "$filename" | cut -d '_' -f2-3)" ;;
+ grub_*|seagrub_*|custom_*)
+ board="$(echo "$filename" | cut -d '_' -f2-3)" ;;
seabios_withgrub_*)
board="$(echo "$filename" | cut -d '_' -f3-4)" ;;
- *.tar.xz)
- _stripped_prefix="${filename#*_}"
+ *.tar.xz) _stripped_prefix="${filename#*_}"
board="${_stripped_prefix%.tar.xz}" ;;
*) $err "detect_board $filename: could not detect board type"
esac; printf "%s\n" "$board"
@@ -263,10 +287,8 @@ readcfg()
if [ "$board" = "serprog_rp2040" ] || \
[ "$board" = "serprog_stm32" ]; then
return 1
- fi
- boarddir="$cbcfgsdir/$board"
- eval `setcfg "$boarddir/target.cfg"`
- chkvars vcfg tree
+ fi; boarddir="$cbcfgsdir/$board"
+ eval `setcfg "$boarddir/target.cfg"`; chkvars vcfg tree
cbdir="src/coreboot/$tree"
cbfstool="elf/cbfstool/$tree/cbfstool"
@@ -274,14 +296,14 @@ readcfg()
kbc1126_ec_dump="$PWD/$cbdir/util/kbc1126/kbc1126_ec_dump"
cbfstool="elf/cbfstool/$tree/cbfstool"
ifdtool="elf/ifdtool/$tree/ifdtool"
+ [ -n "$IFD_platform" ] && ifdprefix="-p $IFD_platform"
- x_ ./update trees -b coreboot utils $tree
+ x_ ./mk -d coreboot $tree
}
patch_release_roms()
{
- remkdir "tmp/romdir"
- tar -xf "$archive" -C "tmp/romdir" || \
+ remkdir "tmp/romdir"; tar -xf "$archive" -C "tmp/romdir" || \
$err "patch_release_roms: !tar -xf \"$archive\" -C \"tmp/romdir\""
for x in "tmp/romdir/bin/"*/*.rom ; do
@@ -310,8 +332,7 @@ patch_release_roms()
patch_rom()
{
rom="$1"
-
- . "$(check_defconfig "$boarddir")" 2>/dev/null || exit 0
+ readkconfig || exit 0
[ "$CONFIG_HAVE_MRC" = "y" ] && inject "mrc.bin" "$CONFIG_MRC_FILE" \
"mrc" "0xfffa0000"
@@ -322,8 +343,7 @@ patch_rom()
"$CONFIG_KBC1126_FW1" raw "$CONFIG_KBC1126_FW1_OFFSET" && inject \
ecfw2.bin "$CONFIG_KBC1126_FW2" raw "$CONFIG_KBC1126_FW2_OFFSET"
[ -n "$CONFIG_VGA_BIOS_FILE" ] && [ -n "$CONFIG_VGA_BIOS_ID" ] && \
- inject "pci$CONFIG_VGA_BIOS_ID.rom" \
- "$CONFIG_VGA_BIOS_FILE" "optionrom"
+ inject "pci$CONFIG_VGA_BIOS_ID.rom" "$CONFIG_VGA_BIOS_FILE" optionrom
[ "$CONFIG_INCLUDE_SMSC_SCH5545_EC_FW" = "y" ] && \
[ -n "$CONFIG_SMSC_SCH5545_EC_FW_FILE" ] && \
inject sch5545_ecfw.bin "$CONFIG_SMSC_SCH5545_EC_FW_FILE" raw
@@ -346,10 +366,11 @@ inject()
e "$_dest" f n && [ "$nukemode" != "nuke" ] && $err "!inject $dl_type"
if [ "$cbfsname" = "IFD" ]; then
- [ "$nukemode" = "nuke" ] || "$ifdtool" -i $_t:$_dest "$rom" \
- -O "$rom" || $err "failed: inject '$_t' '$_dest' on '$rom'"
- [ "$nukemode" != "nuke" ] || "$ifdtool" --nuke $_t "$rom" \
- -O "$rom" || $err "$rom: can't nuke $_t in IFD"; return 0
+ [ "$nukemode" = "nuke" ] || "$ifdtool" $ifdprefix -i \
+ $_t:$_dest "$rom" -O "$rom" || \
+ $err "failed: inject '$_t' '$_dest' on '$rom'"
+ [ "$nukemode" != "nuke" ] || "$ifdtool" $ifdprefix --nuke $_t \
+ "$rom" -O "$rom" || $err "$rom: !nuke IFD/$_t"; return 0
elif [ "$nukemode" = "nuke" ]; then
"$cbfstool" "$rom" remove -n "$cbfsname" || \
$err "inject $rom: can't remove $cbfsname"; return 0
@@ -357,7 +378,7 @@ inject()
[ "$_t" != "stage" ] || "$cbfstool" "$rom" add-stage -f \
"$_dest" -n "$cbfsname" -t stage -c lzma || $err "$rom: !add ref"
[ "$_t" = "stage" ] || "$cbfstool" "$rom" add -f "$_dest" \
- -n "$cbfsname" -t $_t $_offset || $err "$rom !add $_t ($_dest)"
+ -n "$cbfsname" -t $_t $_offset || $err "$rom !add $_t ($_dest)"; :
}
modify_gbe()
@@ -369,5 +390,6 @@ modify_gbe()
x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "$TMPDIR/gbe"
x_ "util/nvmutil/nvm" "$TMPDIR/gbe" setmac $new_mac
- x_ "$ifdtool" -i GbE:"$TMPDIR/gbe" "$1" -O "$1"
+ "$ifdtool" $ifdprefix -i GbE:"$TMPDIR/gbe" "$1" -O "$1" || \
+ $err "Cannot insert modified GbE region into target image."
}