Files
lbmk/resources/scripts/blobs/inject
T
Leah Rowe 548872ce8e haswell boards: use libre mrc.bin replacement
courtesy of Angel Pons from the coreboot project

this uses the following patch set from gerrit, as yet
unmerged (in coreboot master) on this date:

    https://review.coreboot.org/c/coreboot/+/64198/5

logic for downloading mrc blobs has been deleted from
lbmk, as this is now completely obsolete (for haswell
boards)

if other platforms are added later that need mrc.bin,
then logic will be re-added again for that
2023-03-18 00:55:10 +00:00

137 lines
3.2 KiB
Bash
Executable File

#!/usr/bin/env sh
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# SPDX-FileCopyrightText: 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
# SPDX-License-Identifier: GPL-3.0-only
Fail(){
if [ ! -z ${@+x} ]; then
printf "\nERROR: ${@}\n"
fi
cat <<- EOF
USAGE: ./blobutil inject -r [/path/to/rom] -b [boardname] -m [macaddress]
Example: ./blobutil inject -r x230_12mb.rom -b x230_12mb
Adding a macadress to the gbe is optional.
If the [-m] parameter is left blank, the gbe will not be touched.
Type './blobutil inject listboards' to get a list of valid boards
EOF
exit 1
}
Modify_gbe(){
printf "changing mac address in gbe to ${new_mac}\n"
_gbe_location=${CONFIG_GBE_BIN_PATH#../../}
if [ ! -f util/nvmutil/nvm ]; then
make -C util/nvmutil || Fail 'failed to build nvmutil'
fi
_gbe_tmp=$(mktemp -t gbeXXXX.bin)
cp ${_gbe_location} ${_gbe_tmp}
./util/nvmutil/nvm ${_gbe_tmp} setmac ${new_mac} || Fail 'failed to modify mac address\nmake sure the mac address in the correct format'
./coreboot/default/util/ifdtool/ifdtool -i GbE:${_gbe_tmp} ${rom} -O ${rom} || exit 1
rm ${_gbe_tmp}
}
listboards() {
for boarddir in resources/coreboot/*; do
if [ ! -d "${boarddir}" ]; then continue; fi
board="${boarddir##resources/coreboot/}"
board="${board%/}"
printf '%s\n' "${board##*/}"
done
}
# This function tries to determine the board from the filename of the rom.
# It will only succeed if the filename is not changed from the build/download
Detect_board(){
filename=$(basename ${rom})
case ${filename} in
grub_*)
board=$(echo "${filename}" | cut -d '_' -f2-3)
;;
seabios_withgrub_*)
board=$(echo "${filename}" | cut -d '_' -f3-4)
;;
*)
return 1
esac
if [ -d "resources/coreboot/${board}/" ]; then
printf '%s\n' "${board}"
else
return 1
fi
}
Patch(){
set -- "resources/coreboot/${board}/config/*"
. ${1} 2>/dev/null
. "resources/coreboot/${board}/board.cfg"
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
_me_location=${CONFIG_ME_BIN_PATH#../../}
printf 'adding intel management engine\n'
./coreboot/default/util/ifdtool/ifdtool -i me:${_me_location} ${rom} -O ${rom} || exit 1
fi
if [ "${modifygbe}" = "true" ]; then
Modify_gbe
fi
}
if [ "${1}" = "listboards" ]; then
listboards
exit 0
fi
# Implementing parameter parsing now so more options can be added later
while getopts r:b:m: option
do
case "${option}"
in
r)rom=${OPTARG};;
b)board=${OPTARG};;
m)
modifygbe=true
new_mac=${OPTARG}
;;
esac
done
if [ -z ${rom+x} ]; then
Fail 'no rom specified'
elif [ ! -f "${rom}" ]; then
Fail "${rom} is not a valid path"
elif [ -z ${board+x} ]; then
board=$(Detect_board) || \
Fail 'no board specified'
fi
if [ ! -d "resources/coreboot/${board}/" ]; then
Fail "board ${board} not found"
fi
if [ ! -d coreboot/default ]; then
printf "downloading coreboot\n"
./download coreboot default
fi
if [ ! -f "coreboot/default/util/ifdtool/ifdtool" ]; then
printf "building ifdtool from coreboot\n"
./build module cbutils default || Fail 'could not build ifdtool'
fi
if [ ! -f "coreboot/default/util/cbfstool/cbfstool" ]; then
printf "building cbfstool from coreboot\n"
./build module cbutils default || Fail 'could not build cbfstool'
fi
./blobutil download ${board} && Patch