summaryrefslogtreecommitdiff
path: root/include/vendor.sh
diff options
context:
space:
mode:
Diffstat (limited to 'include/vendor.sh')
-rw-r--r--include/vendor.sh160
1 files changed, 90 insertions, 70 deletions
diff --git a/include/vendor.sh b/include/vendor.sh
index ace3f7ce..0f97a641 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 -d coreboot $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
}
@@ -82,33 +91,35 @@ fetch()
download "$dl" "$dl_bkup" "$_dl" "$dlsum"
- rm -Rf "${_dl}_extracted" || \
- $err "!rm -Rf ${_ul}_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
@@ -131,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 \
@@ -149,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"
@@ -195,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" ;;
@@ -215,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()
@@ -246,15 +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_*|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"
@@ -265,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"
@@ -276,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 -d coreboot $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
@@ -312,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"
@@ -324,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
@@ -348,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
@@ -359,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()
@@ -371,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."
}