summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/lib.sh25
-rw-r--r--include/rom.sh17
-rw-r--r--include/vendor.sh56
3 files changed, 85 insertions, 13 deletions
diff --git a/include/lib.sh b/include/lib.sh
index a9a292c2..b43d83f3 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -82,7 +82,13 @@ pyver="2"
python="python3"
command -v python3 1>/dev/null || python="python"
command -v $python 1>/dev/null || pyver=""
-[ -n "$pyver" ] && pyver="$($python --version | awk '{print $2}')"
+[ -z "$pyver" ] || \
+ python -c 'import sys; print(sys.version_info[:])' 1>/dev/null \
+ 2>/dev/null || $err "Cannot determine which Python version."
+[ -n "$pyver" ] && \
+ pyver="`python -c 'import sys; print(sys.version_info[:])' | \
+ awk '{print $1}'`" && \
+ pyver="${pyver#(}" && pyver="${pyver%,}"
if [ "${pyver%%.*}" != "3" ]; then
printf "Wrong python version, or python missing. Must be v 3.x.\n" 1>&2
exit 1
@@ -107,10 +113,19 @@ if [ -z "${TMPDIR+x}" ]; then
export TMPDIR="/tmp"
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
touch lock || $err "cannot create 'lock' file"
- rm -Rf "$XBMK_CACHE/xbmkpath" || $err "cannot remove xbmkpath"
- mkdir -p "$XBMK_CACHE/xbmkpath" || $err "cannot create xbmkpath"
- export PATH="$XBMK_CACHE/xbmkpath:$PATH" || \
- $err "Can't create xbmkpath"
+ rm -Rf "$XBMK_CACHE/xbmkpath" "$XBMK_CACHE/gnupath" || \
+ $err "cannot remove xbmkpath"
+ mkdir -p "$XBMK_CACHE/gnupath" "$XBMK_CACHE/xbmkpath" || \
+ $err "cannot create gnupath"
+ export PATH="$XBMK_CACHE/xbmkpath:$XBMK_CACHE/gnupath:$PATH" || \
+ $err "Can't create gnupath/xbmkpath"
+ (
+ # set up python v3.x in PATH, in case it's not set up correctly.
+ # see code above that detected the correct python3 command.
+ cd "$XBMK_CACHE/xbmkpath" || $err "can't cd $XBMK_CACHE/xbmkpath"
+ ln -s "`command -v "$python"`" python || \
+ $err "Can't set up python symlink in $XBMK_CACHE/xbmkpath"
+ ) || $err "Can't set up python symlink in $XBMK_CACHE/xbmkpath"
xbmk_parent="y"
fi
diff --git a/include/rom.sh b/include/rom.sh
index 2a7bc837..3e8c9c9b 100644
--- a/include/rom.sh
+++ b/include/rom.sh
@@ -7,7 +7,11 @@
mkserprog()
{
+ [ $# -lt 1 ] && $err "mkserprog: no arguments provided"
[ "$_f" = "-d" ] && return 0 # dry run
+
+ [ "$1" = "pico" ] && mkpicotool
+
basename -as .h "$serdir/"*.h > "$TMPDIR/ser" || $err "!mk $1 $TMPDIR"
while read -r sertarget; do
@@ -20,6 +24,7 @@ mkserprog()
ln -srf "$sersrc/build_$pt/" "$sersrc/build") \
&& x_ cmake -DPICO_BOARD="$sertarget" \
-DPICO_SDK_PATH="$picosdk" -B "$sersrc/build" "$sersrc" \
+ -Dpicotool_DIR="$picotool/picotool" \
&& x_ cmake --build "$sersrc/build"
[ "$1" = "stm32" ] && x_ make -C "$sersrc" \
libopencm3-just-make BOARD=$sertarget && x_ make -C \
@@ -30,6 +35,18 @@ mkserprog()
[ "$XBMK_RELEASE" = "y" ] && mkrom_tarball "bin/serprog_$1"; return 0
}
+mkpicotool()
+{
+ rm -Rf "$picotool" || $err "Can't remove picotool builddir"
+ (
+ x_ cd src/picotool
+ cmake -DCMAKE_INSTALL_PREFIX=xbmkbin -DPICOTOOL_FLAT_INSTALL=1 \
+ -DPICO_SDK_PATH=../pico-sdk || \
+ $err "Can't prep picotool"
+ make install || $err "Can't build picotool"; :
+ ) || $err "Can't build picotool"; :
+}
+
copyps1bios()
{
x_ rm -Rf bin/playstation
diff --git a/include/vendor.sh b/include/vendor.sh
index cefed456..bde245d9 100644
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -12,7 +12,7 @@ appdir="$vendir/app"
cbcfgsdir="config/coreboot"
hashfiles="vendorhashes blobhashes" # blobhashes for backwards compatibility
dontflash="!!! AN ERROR OCCURED! Please DO NOT flash if injection failed. !!!"
-vfix="DO_NOT_FLASH_YET._FIRST,_INJECT_BLOBS_VIA_INSTRUCTIONS_ON_LIBREBOOT.ORG_"
+vfix="DO_NOT_FLASH_YET._FIRST,_INJECT_FILES_VIA_INSTRUCTIONS_ON_LIBREBOOT.ORG_"
vguide="https://libreboot.org/docs/install/ivy_has_common.html"
tmpromdel="$PWD/tmp/DO_NOT_FLASH"
@@ -33,7 +33,8 @@ eval "`setvars "" has_hashes EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \
archive EC_url boarddir rom cbdir DL_url nukemode cbfstoolref FSPFD_hash \
_7ztest ME11bootguard ME11delta ME11version ME11sku ME11pch tmpromdir \
IFD_platform ifdprefix cdir sdir _me _metmp mfs TBFW_url_bkup TBFW_url \
- TBFW_hash TBFW_size hashfile xromsize xchanged EC_url_bkup need_files $cv`"
+ TBFW_hash TBFW_size hashfile xromsize xchanged EC_url_bkup need_files \
+ vfile $cv`"
vendor_download()
{
@@ -65,7 +66,7 @@ readkconfig()
CONFIG_LENOVO_TBFW_BIN CONFIG_FSP_M_FILE CONFIG_FSP_S_FILE; do
eval "[ \"\${$c}\" = \"/dev/null\" ] && continue"
eval "[ -z \"\${$c}\" ] && continue"
- eval "`setcfg "config/vendor/$vcfg/pkg.cfg"`"; return 0
+ eval "`setcfg "$vfile"`"; return 0
done
printf "Vendor files not needed for: %s\n" "$board" 1>&2; return 1
}
@@ -348,18 +349,40 @@ vendor_inject()
set +u +e; [ $# -lt 1 ] && $err "No options specified. - $dontflash"
eval "`setvars "" nukemode new_mac xchanged`"
+ # randomise the MAC address by default
+ # TODO: support setting CBFS MAC address for GA-G41M-ES2L
+ new_mac="??:??:??:??:??:??"
+
archive="$1";
[ $# -gt 1 ] && case "$2" in
- nuke) nukemode="nuke" ;;
+ nuke)
+ new_mac=""
+ nukemode="nuke" ;;
setmac)
- new_mac="??:??:??:??:??:??"
- [ $# -gt 2 ] && new_mac="$3" ;;
+ [ $# -gt 2 ] && new_mac="$3" && \
+ [ -z "$new_mac" ] && $err \
+ "You set an empty MAC address string" ;;
*) $err "Unrecognised inject mode: '$2'"
esac
+ # allow the user to skip setting MAC addresses.
+ # if new_mac is empty, this script skips running nvmutil
+ [ "$new_mac" = "keep" ] && new_mac=""
+
+ # we don't allow the *user* to clear new_mac, in the setmac
+ # command, in case the build system is being integrated with
+ # another, where setmac is relied upon and is being set
+ # explicitly. this is a preventative error handle, as a courtes
+ # to that hypothetical user e.g. Linux distro package maintainer
+ # integrating this build system into their distro. if they used
+ # a variable for that, and they forgot to initialise it, they'll know.
+
check_release "$archive" || \
$err "You must run this script on a release archive. - $dontflash"
+ [ "$new_mac" = "restore" ] && \
+ printf "Restoring default GbE for '$archive', board '$board'\n"
+
readcfg && need_files="y"
if [ "$need_files" = "y" ] || [ -n "$new_mac" ]; then
[ "$nukemode" = "nuke" ] || x_ ./mk download "$board"
@@ -387,6 +410,10 @@ vendor_inject()
&& printf "DO NOT flash images from '%s'\n" \
"$archive" 1>&2
+ [ "$need_files" = "n" ] && printf \
+ "Board '%s' doesn't use vendorfiles, so none were inserted.\n" \
+ "$board"
+
#
# catch-all error handler, for libreboot release opsec:
#
@@ -441,6 +468,9 @@ readcfg()
x_ ./mk -d coreboot "$tree" # even if vendorfiles not used, see: setmac
[ -z "$vcfg" ] && return 1
+ vfile="config/vendor/$vcfg/pkg.cfg"
+ [ -L "$vfile" ] && $err "'$archive', '$board': $vfile is a symlink"
+ [ -f "$vfile" ] || $err "'$archive', '$board': $vfile doesn't exist"
cbdir="src/coreboot/$tree"
cbfstool="elf/cbfstool/$tree/cbfstool"
@@ -508,6 +538,8 @@ patch_release_roms()
1>&2
printf "This board probably lacks Intel ethernet.\n" \
1>&2
+ printf "(or it's pre-IFD Intel with Intel GbE NIC)\n" \
+ 1>&2
fi
fi
@@ -689,7 +721,9 @@ modify_mac_addresses()
[ -n "$CONFIG_GBE_BIN_PATH" ] || return 1
e "${CONFIG_GBE_BIN_PATH##*../}" f n && $err "missing gbe file"
- x_ make -C util/nvmutil
+ [ "$new_mac" != "restore" ] && \
+ x_ make -C util/nvmutil
+
x_ mkdir -p tmp
[ -L "tmp/gbe" ] && $err "tmp/gbe exists but is a symlink"
[ -d "tmp/gbe" ] && $err "tmp/gbe exists but is a directory"
@@ -698,7 +732,8 @@ modify_mac_addresses()
fi
x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "tmp/gbe"
- x_ "util/nvmutil/nvm" "tmp/gbe" setmac "$new_mac"
+ [ "$new_mac" != "restore" ] && \
+ x_ "util/nvmutil/nvm" "tmp/gbe" setmac "$new_mac"
find "$tmpromdir" -maxdepth 1 -type f -name "*.rom" > "tmp/rom.list" \
|| $err "'$archive' -> Can't make tmp/rom.list - $dontflash"
@@ -713,4 +748,9 @@ modify_mac_addresses()
printf "\nThe following GbE NVM words were written in '%s':\n" \
"$archive"
x_ util/nvmutil/nvm tmp/gbe dump
+
+ [ "$new_mac" = "restore" ] && \
+ printf "\nNOTE: User specified setmac 'restore' argument.\n" && \
+ printf "Default GbE file '%s' written without running nvmutil.\n" \
+ "${CONFIG_GBE_BIN_PATH##*../}"; :
}