2023-06-07 19:49:13 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-01-10 19:18:37 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
echo -n \
|
2023-02-26 00:39:18 +00:00
|
|
|
"Usage: $(basename "$0") path_to_output_directory
|
2023-01-10 19:18:37 +00:00
|
|
|
Obtain mrc.bin from a Haswell Chromebook firmware image.
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
|
|
|
MRC_BIN_HASH="d368ba45096a3b5490ed27014e1f9004bc363434ffdce0c368c08a89c4746722"
|
|
|
|
|
|
|
|
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-10 19:18:37 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
output_dir="$(realpath "${1:-./}")"
|
|
|
|
|
|
|
|
# Obtain mrc.bin from a Haswell Chromebook firmware image.
|
|
|
|
# https://doc.coreboot.org/northbridge/intel/haswell/mrc.bin.html#obtaining-mrc-bin
|
|
|
|
if [[ ! -f "${output_dir}/mrc.bin" ]]; then
|
2023-02-26 00:39:18 +00:00
|
|
|
pushd "${COREBOOT_DIR}"
|
2023-01-10 19:18:37 +00:00
|
|
|
|
2023-02-26 00:39:18 +00:00
|
|
|
make -C util/cbfstool
|
|
|
|
cd util/chromeos
|
|
|
|
./crosfirmware.sh peppy
|
|
|
|
../cbfstool/cbfstool coreboot-*.bin extract -f mrc.bin -n mrc.bin -r RO_SECTION
|
2023-01-10 19:18:37 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
mv mrc.bin "${output_dir}/mrc.bin"
|
2023-01-10 19:18:37 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
popd
|
2023-02-26 00:39:18 +00:00
|
|
|
fi
|
2023-01-10 19:18:37 +00:00
|
|
|
|
2023-02-28 16:44:48 +00:00
|
|
|
if ! echo "${MRC_BIN_HASH} ${output_dir}/mrc.bin" | sha256sum --check; then
|
2023-02-26 00:39:18 +00:00
|
|
|
echo "ERROR: SHA256 checksum for mrc.bin doesn't match."
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-01-10 19:18:37 +00:00
|
|
|
fi
|
|
|
|
fi
|