2023-01-10 21:29:22 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
echo -n \
|
2023-02-25 19:39:18 -05:00
|
|
|
"Usage: $(basename "$0") path_to_original_rom path_to_output_directory
|
2023-01-10 21:29:22 -05:00
|
|
|
Extract Intel firmware from the original ROM.
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
|
|
|
if [[ "${1:-}" == "--help" ]]; then
|
|
|
|
usage
|
|
|
|
else
|
2023-02-25 19:39:18 -05:00
|
|
|
if [[ -z "${COREBOOT_DIR}" ]]; then
|
|
|
|
echo "ERROR: No COREBOOT_DIR variable defined."
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-01-10 21:29:22 -05:00
|
|
|
|
2023-02-25 19:39:18 -05:00
|
|
|
if [[ -n "$1" ]]; then
|
2023-01-10 21:29:22 -05:00
|
|
|
pushd "${COREBOOT_DIR}"
|
2023-02-25 19:39:18 -05:00
|
|
|
|
2023-01-10 21:29:22 -05:00
|
|
|
cd util/me_cleaner
|
|
|
|
|
|
|
|
# Neutralize and shrink Intel ME.
|
|
|
|
# https://github.com/corna/me_cleaner/wiki/External-flashing#neutralize-and-shrink-intel-me-useful-only-for-coreboot
|
|
|
|
python me_cleaner.py -S -r -t -d -O out.bin -D ifd_shrinked.bin -M me_shrinked.bin "$1"
|
|
|
|
|
2023-02-25 19:39:18 -05:00
|
|
|
mv ifd_shrinked.bin "$2/ifd.bin"
|
|
|
|
mv me_shrinked.bin "$2/me.bin"
|
2023-01-10 21:29:22 -05:00
|
|
|
rm ./*.bin
|
|
|
|
|
|
|
|
cd ../ifdtool
|
|
|
|
make
|
|
|
|
|
|
|
|
# Extract the Intel Gigabit Ethernet (GbE) firmware from the
|
|
|
|
# original ROM.
|
|
|
|
./ifdtool -x "$1"
|
|
|
|
|
2023-02-25 19:39:18 -05:00
|
|
|
mv flashregion_3_gbe.bin "$2/gbe.bin"
|
2023-01-10 21:29:22 -05:00
|
|
|
rm ./*.bin
|
|
|
|
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
echo "ERROR: You must supply a path to the original ROM."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|