Merge branch 'dev' of shmalebx9/lbmk into master

fsdg20230625
Leah Rowe 2022-11-26 21:22:06 +00:00 committed by Gogs
commit 59e4f560d6
4 changed files with 56 additions and 36 deletions

View File

@ -3,8 +3,11 @@
# SPDX-License-Identifier: GPL-3.0-only # SPDX-License-Identifier: GPL-3.0-only
Set_placeholder(){ Set_placeholder(){
# Check if username and or email is set.
if ! git config user.name || git config user.email ; then
git config user.name || git config user.name 'lbmkplaceholder' git config user.name || git config user.name 'lbmkplaceholder'
git config user.email || git config user.email 'placeholder@lbmkplaceholder.com' git config user.email || git config user.email 'placeholder@lbmkplaceholder.com'
fi
} }
Clean(){ Clean(){
@ -21,9 +24,13 @@ Run(){
if [ "${1}" = "clean" ]; then if [ "${1}" = "clean" ]; then
Clean Clean
else else
# Check if username and or email is set.
if ! git config user.name || git config user.email ; then
Set_placeholder Set_placeholder
# Check coreboot as well to prevent errors during building
if [ -d coreboot ]; then
cd coreboot
Set_placeholder
cd -
fi fi
fi fi
} }

View File

@ -14,6 +14,11 @@ else
redistributable=false redistributable=false
fi fi
Fail(){
printf "\nERROR: $@\n"
exit 1
}
Download_needed(){ Download_needed(){
for need in ${needs}; do for need in ${needs}; do
case ${need} in case ${need} in
@ -27,8 +32,7 @@ Download_needed(){
done done
if [ ! -z ${_failed+x} ]; then if [ ! -z ${_failed+x} ]; then
printf "\nERROR: failed to obtain${_failed}\nrun: './blobutil extract ${board} /path/to/romdump.rom' to extract the remaining blobs\n" Fail "failed to obtain ${_failed}\nYou may try manually extracting blobs with './blobutil extract'"
exit 1
fi fi
} }
@ -68,27 +72,28 @@ Extract_me(){
return 1 return 1
fi fi
( cd blobs && innoextract me.exe )
printf 'extracting and stripping intel management engine\n' printf 'extracting and stripping intel management engine\n'
innoextract blobs/me.exe -d blobs || Fail 'could not extract me executable with innoextract'
./me_cleaner/me_cleaner.py -r -t -O ${_me_destination} blobs/app/*ME*.bin \ ./me_cleaner/me_cleaner.py -r -t -O ${_me_destination} blobs/app/*ME*.bin \
|| ./resources/blobs/me7_update_parser.py -O ${_me_destination} blobs/app/ME7*.bin || ./resources/blobs/me7_update_parser.py -O ${_me_destination} blobs/app/ME7*.bin \
|| return 1
printf "Truncated and cleaned me output to ${_me_destination}\n" printf "Truncated and cleaned me output to ${_me_destination}\n"
} }
Build_deps(){ Build_deps(){
if [ ! -d me_cleaner ]; then if [ ! -d me_cleaner ]; then
printf "downloading me_cleaner\n" printf "downloading me_cleaner\n"
./download me_cleaner ./download me_cleaner || Fail 'could not download me_cleaner'
fi fi
if [ ! -d coreboot/default ]; then if [ ! -d coreboot/default ]; then
printf "downloading coreboot\n" printf "downloading coreboot\n"
./download coreboot default ./download coreboot default || Fail 'could not download coreboot'
fi fi
if [ ! -f "coreboot/default/util/ifdtool/ifdtool" ]; then if [ ! -f "coreboot/default/util/ifdtool/ifdtool" ]; then
printf "building ifdtool from coreboot\n" printf "building ifdtool from coreboot\n"
( cd coreboot/default/util/ifdtool && make ) make -C coreboot/default/util/ifdtool || Fail 'could not build ifdtool'
fi fi
} }

View File

@ -13,10 +13,15 @@ Print_help(){
printf "\nYou need to specify exactly 2 arguments\n" printf "\nYou need to specify exactly 2 arguments\n"
} }
Fail(){
printf "\nERROR: $@\n"
exit 1
}
Build_deps(){ Build_deps(){
if [ ! -d me_cleaner ]; then if [ ! -d me_cleaner ]; then
printf "downloading me_cleaner\n" printf "downloading me_cleaner\n"
./download me_cleaner ./download me_cleaner || Fail 'could not download me_cleaner'
else else
printf "me_cleaner already downloaded. Skipping.\n" printf "me_cleaner already downloaded. Skipping.\n"
printf "run ./download me_cleaner to manually overwrite\n" printf "run ./download me_cleaner to manually overwrite\n"
@ -24,19 +29,16 @@ Build_deps(){
if [ ! -d coreboot/default ]; then if [ ! -d coreboot/default ]; then
printf "downloading coreboot\n" printf "downloading coreboot\n"
./download coreboot default ./download coreboot default || Fail 'could not download coreboot'
else else
printf "coreboot already downloaded. Skipping.\n" printf "coreboot already downloaded. Skipping.\n"
printf "run ./download coreboot to manually overwrite\n" printf "run ./download coreboot to manually overwrite\n"
fi fi
if ! [ -f coreboot/default/util/ifdtool/ifdtool ]; then
printf "building ifdtool from coreboot\n" printf "building ifdtool from coreboot\n"
( cd coreboot/default/util/ifdtool && make ) make -C coreboot/default/util/ifdtool || Fail 'could not build ifdtool'
} fi
Error_out(){
printf "failed to extract ${1}\nmake sure that your rom dump is valid\n"
exit 1
} }
@ -48,7 +50,7 @@ Extract_blobs(){
if [ "$CONFIG_HAVE_MRC" = "y" ]; then if [ "$CONFIG_HAVE_MRC" = "y" ]; then
printf 'haswell board detected, downloading mrc\n' printf 'haswell board detected, downloading mrc\n'
./download mrc ./download mrc || Fail 'could not download mrc, check network connection'
fi fi
_me_destination=${CONFIG_ME_BIN_PATH#../../} _me_destination=${CONFIG_ME_BIN_PATH#../../}
@ -56,15 +58,22 @@ Extract_blobs(){
_ifd_destination=${CONFIG_IFD_BIN_PATH#../../} _ifd_destination=${CONFIG_IFD_BIN_PATH#../../}
printf "extracting clean ime and modified ifd\n" printf "extracting clean ime and modified ifd\n"
./me_cleaner/me_cleaner.py -D ${_ifd_destination} -M ${_me_destination} ${vendor_rom} -t -r -S || Error_out me ./me_cleaner/me_cleaner.py -D ${_ifd_destination} -M ${_me_destination} ${vendor_rom} -t -r -S \
|| ./resources/blobs/me7_update_parser.py -O ${_me_destination} ${vendor_rom} \
|| Fail 'me_cleaner failed to extract blobs from rom'
printf "extracting gigabit ethernet firmware" printf "extracting gigabit ethernet firmware"
./coreboot/default/util/ifdtool/ifdtool -x ${vendor_rom} ./coreboot/default/util/ifdtool/ifdtool -x ${vendor_rom}
mv flashregion*gbe.bin ${_gbe_destination} || Error_out gbe mv flashregion*gbe.bin ${_gbe_destination} || Fail 'could not extract gbe'
# Cleans up other files extracted with ifdtool # Cleans up other files extracted with ifdtool
rm flashregion*.bin 2> /dev/null rm flashregion*.bin 2> /dev/null
if [ -f ${_ifd_destination} ]; then
printf "gbe, ifd, and me extracted to ${_me_destination%/*}\n" printf "gbe, ifd, and me extracted to ${_me_destination%/*}\n"
else
printf "WARNING: Intel firmware descriptor could not be extracted with modified me\n"
fi
} }
if [ ! -f "${vendor_rom}" ] ; then if [ ! -f "${vendor_rom}" ] ; then

View File

@ -3,9 +3,9 @@
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com> # SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# SPDX-License-Identifier: GPL-3.0-only # SPDX-License-Identifier: GPL-3.0-only
Error_out(){ Fail(){
if [ ! -z ${@+x} ]; then if [ ! -z ${@+x} ]; then
printf "ERROR: ${@}\n" printf "\nERROR: ${@}\n"
fi fi
cat <<- EOF cat <<- EOF
@ -26,12 +26,12 @@ Modify_gbe(){
_gbe_location=${CONFIG_GBE_BIN_PATH#../../} _gbe_location=${CONFIG_GBE_BIN_PATH#../../}
if [ ! -f util/nvmutil/nvm ]; then if [ ! -f util/nvmutil/nvm ]; then
( cd util/nvmutil/ && make ) make -C /util/nvmutil || Fail 'failed to build nvmutil'
fi fi
_gbe_tmp=$(mktemp -t gbeXXXX.bin) _gbe_tmp=$(mktemp -t gbeXXXX.bin)
cp ${_gbe_location} ${_gbe_tmp} 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' ./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 ./coreboot/default/util/ifdtool/ifdtool -i GbE:${_gbe_tmp} ${rom} -O ${rom} || exit 1
@ -110,17 +110,16 @@ do
done done
if [ -z ${rom+x} ]; then if [ -z ${rom+x} ]; then
Error_out 'no rom specified' Fail 'no rom specified'
elif [ ! -f "${rom}" ]; then elif [ ! -f "${rom}" ]; then
Error_out "${rom} is not a valid path" Fail "${rom} is not a valid path"
elif [ -z ${board+x} ]; then elif [ -z ${board+x} ]; then
board=$(Detect_board) || \ board=$(Detect_board) || \
Error_out 'no board specified' Fail 'no board specified'
fi fi
if [ ! -d "resources/coreboot/${board}/" ]; then if [ ! -d "resources/coreboot/${board}/" ]; then
printf "board ${board} not found\n" Fail "board ${board} not found"
Error_out
fi fi
if [ ! -d coreboot/default ]; then if [ ! -d coreboot/default ]; then
@ -130,12 +129,12 @@ fi
if [ ! -f "coreboot/default/util/ifdtool/ifdtool" ]; then if [ ! -f "coreboot/default/util/ifdtool/ifdtool" ]; then
printf "building ifdtool from coreboot\n" printf "building ifdtool from coreboot\n"
( cd coreboot/default/util/ifdtool && make ) make -C coreboot/default/util/ifdtool || Fail 'could not build ifdtool'
fi fi
if [ ! -f "coreboot/default/util/cbfstool/cbfstool" ]; then if [ ! -f "coreboot/default/util/cbfstool/cbfstool" ]; then
printf "building cbfstool from coreboot\n" printf "building cbfstool from coreboot\n"
( cd coreboot/default/util/cbfstool && make ) make -C cd coreboot/default/util/cbfstool || Fail 'could not build ifdtool'
fi fi
./blobutil download ${board} && Patch ./blobutil download ${board} && Patch