added more checks and optimised extraction script

fsdg20230625
shmalebx9 2022-11-20 20:14:22 -07:00
parent b2c71747cd
commit 175b48a4e0
2 changed files with 24 additions and 15 deletions

View File

@ -92,8 +92,8 @@ Build_deps(){
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 ) || Fail 'could not build ifdtool' 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
printf "building ifdtool from coreboot\n" if ! [ -f coreboot/default/util/ifdtool/ifdtool ]; then
( cd coreboot/default/util/ifdtool && make ) printf "building ifdtool from coreboot\n"
} 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
printf "gbe, ifd, and me extracted to ${_me_destination%/*}\n"
if [ -f ${_ifd_destination} ]; then
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