2023-06-07 19:49:13 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-01-11 02:29:22 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
echo -n \
|
2023-02-26 00:39:18 +00:00
|
|
|
"Usage: $(basename "$0") path_to_original_rom path_to_output_directory
|
2023-01-11 02:29:22 +00:00
|
|
|
Extract Intel firmware from the original ROM.
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
|
|
|
if [[ "${1:-}" == "--help" ]]; then
|
|
|
|
usage
|
|
|
|
else
|
2023-02-26 00:39:18 +00:00
|
|
|
if [[ -z "${COREBOOT_DIR}" ]]; then
|
|
|
|
echo "ERROR: No COREBOOT_DIR variable defined."
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-01-11 02:29:22 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
original_rom="$(realpath "$1")"
|
|
|
|
output_dir="$(realpath "${2:-./}")"
|
2023-02-26 00:39:18 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
# Neutralize Intel ME and resize the Intel Flash Descriptor (IFD)
|
|
|
|
# layout.
|
|
|
|
# https://github.com/corna/me_cleaner/wiki/External-flashing#neutralize-and-shrink-intel-me-useful-only-for-coreboot
|
|
|
|
pushd "${COREBOOT_DIR}/util/me_cleaner"
|
2023-01-11 02:29:22 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
python me_cleaner.py -S -r -t -d -O out.bin -D ifd_shrinked.bin -M me_shrinked.bin "${original_rom}"
|
2023-01-11 02:29:22 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
mv ifd_shrinked.bin "${output_dir}/ifd.bin"
|
|
|
|
mv me_shrinked.bin "${output_dir}/me.bin"
|
|
|
|
rm ./*.bin
|
2023-01-11 02:29:22 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
popd
|
2023-01-11 02:29:22 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
# Extract the Intel Gigabit Ethernet (GbE) firmware.
|
|
|
|
pushd "${COREBOOT_DIR}/util/ifdtool"
|
2023-01-11 02:29:22 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
make
|
|
|
|
./ifdtool -x "${original_rom}"
|
2023-01-11 02:29:22 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
mv flashregion_3_gbe.bin "${output_dir}/gbe.bin"
|
|
|
|
rm ./*.bin
|
|
|
|
|
|
|
|
popd
|
2023-01-11 02:29:22 +00:00
|
|
|
fi
|
|
|
|
fi
|