mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 14:02:52 +02:00
e1bbdadc95
the intended use-case scenario was one in which vga rom initialisation would be used, on desktop configurations, but without coreboot itself handling vga rom initialisation, instead leaving that task to seabios it was assumed that grub, when running on the bare metal with build option "--with-platform=coreboot" would be able to display like this, but it is not so when tested in such setups (add-on gpu with grub payload), it is necessary to extract the video bios and insert it into the coreboot rom, having coreboot handle such execution. this is beyond the scope of lbmk, in context of automated building, because we cannot reliably predict things such as PCI IDs do away with this build option entirely, for it does not serve the intended purpose. it will be necessary to run PC GRUB instead (build option --with-platform=i386-pc). PC GRUB can still read from CBFS, and you could provide it as a floppy image file inside CBFS for SeaBIOS to execute. in this setup, GRUB would function as originally intended by the seabios_withgrub option; such a configuration is referred to as "SeaGRUB" by the libreboot project, and experimentation was done with it in the past, to no avail it's better to keep things simple, in the libreboot project. simpler for users, that is
142 lines
3.3 KiB
Bash
Executable File
142 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
Error_out(){
|
|
if [ ! -z ${@+x} ]; then
|
|
printf "ERROR: ${@}\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
|
|
( cd util/nvmutil/ && make )
|
|
fi
|
|
|
|
_gbe_tmp=$(mktemp -t gbeXXXX.bin)
|
|
cp ${_gbe_location} ${_gbe_tmp}
|
|
./util/nvmutil/nvm ${_gbe_tmp} setmac ${new_mac} || Error_out '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=$(cut -d '_' -f2-3 <<<${filename})
|
|
;;
|
|
seabios_withgrub_*)
|
|
board=$(cut -d '_' -f3-4 <<<${filename})
|
|
;;
|
|
*)
|
|
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_MRC" = "y" ]; then
|
|
printf 'adding mrc\n'
|
|
./coreboot/default/util/cbfstool/cbfstool ${rom} add -f mrc/haswell/mrc.bin -n mrc.bin -t mrc || exit 1
|
|
fi
|
|
|
|
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
|
|
Error_out 'no rom specified'
|
|
elif [ ! -f "${rom}" ]; then
|
|
Error_out "${rom} is not a valid path"
|
|
elif [ -z ${board+x} ]; then
|
|
board=$(Detect_board) || \
|
|
Error_out 'no board specified'
|
|
fi
|
|
|
|
if [ ! -d "resources/coreboot/${board}/" ]; then
|
|
printf "board ${board} not found\n"
|
|
Error_out
|
|
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"
|
|
( cd coreboot/default/util/ifdtool && make )
|
|
fi
|
|
|
|
if [ ! -f "coreboot/default/util/cbfstool/cbfstool" ]; then
|
|
printf "building cbfstool from coreboot\n"
|
|
( cd coreboot/default/util/cbfstool && make )
|
|
fi
|
|
|
|
./blobutil download ${board} && Patch
|