mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-24 15:16:42 +00:00
63eab714e5
Because we're using pushd/popd to make the Coreboot util invocation cleaner, we need to use realpath so that the scripts will work with any user input.
49 lines
1.3 KiB
Bash
Executable File
49 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
|
|
|
|
original_rom="$(realpath "$1")"
|
|
output_dir="$(realpath "${2:-./}")"
|
|
|
|
# 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"
|
|
|
|
python me_cleaner.py -S -r -t -d -O out.bin -D ifd_shrinked.bin -M me_shrinked.bin "${original_rom}"
|
|
|
|
mv ifd_shrinked.bin "${output_dir}/ifd.bin"
|
|
mv me_shrinked.bin "${output_dir}/me.bin"
|
|
rm ./*.bin
|
|
|
|
popd
|
|
|
|
# Extract the Intel Gigabit Ethernet (GbE) firmware.
|
|
pushd "${COREBOOT_DIR}/util/ifdtool"
|
|
|
|
make
|
|
./ifdtool -x "${original_rom}"
|
|
|
|
mv flashregion_3_gbe.bin "${output_dir}/gbe.bin"
|
|
rm ./*.bin
|
|
|
|
popd
|
|
fi
|
|
fi
|