heads/blobs/t440p/extract
Rocky Breslow 144f9c147e
Make T440p scripts use Coreboot from environment
Before, the T440p blob scripts would look for Coreboot using the find
command. Now, we require the user to specify the path to Coreboot in the
COREBOOT_DIR environment variable. Also, add an output directory
argument to each script.

These changes will make it easier to integrate with the Heads build
system and CI.
2023-02-25 19:53:47 -05:00

51 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
function usage() {
echo -n \
"Usage: $(basename "$0") path_to_original_rom path_to_output_directory
Extract Intel firmware from the original ROM.
"
}
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
if [[ "${1:-}" == "--help" ]]; then
usage
else
if [[ -z "${COREBOOT_DIR}" ]]; then
echo "ERROR: No COREBOOT_DIR variable defined."
exit 1
fi
if [[ -n "$1" ]]; then
pushd "${COREBOOT_DIR}"
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"
mv ifd_shrinked.bin "$2/ifd.bin"
mv me_shrinked.bin "$2/me.bin"
rm ./*.bin
cd ../ifdtool
make
# Extract the Intel Gigabit Ethernet (GbE) firmware from the
# original ROM.
./ifdtool -x "$1"
mv flashregion_3_gbe.bin "$2/gbe.bin"
rm ./*.bin
popd
else
echo "ERROR: You must supply a path to the original ROM."
exit 1
fi
fi
fi