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.
This commit is contained in:
Rocky Breslow 2023-02-25 19:39:18 -05:00
parent e6c34bda55
commit 144f9c147e
No known key found for this signature in database
GPG Key ID: 5401F9FC55CD2EA4
3 changed files with 54 additions and 44 deletions

View File

@ -4,7 +4,7 @@ set -e
function usage() {
echo -n \
"Usage: $(basename "$0")
"Usage: $(basename "$0") path_to_output_directory
Obtain mrc.bin from a Haswell Chromebook firmware image.
"
}
@ -15,9 +15,12 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
if [[ "${1:-}" == "--help" ]]; then
usage
else
BLOB_DIR="$(cd "$(dirname "$0")" && pwd)"
COREBOOT_DIR="$(find "${BLOB_DIR}/../../build/x86/" -maxdepth 1 -type d -name 'coreboot-*')"
if [[ -z "${COREBOOT_DIR}" ]]; then
echo "ERROR: No COREBOOT_DIR variable defined."
exit 1
fi
if [[ ! -f "$1/mrc.bin" ]]; then
pushd "${COREBOOT_DIR}"
# https://doc.coreboot.org/northbridge/intel/haswell/mrc.bin.html#obtaining-mrc-bin
@ -26,13 +29,14 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
./crosfirmware.sh peppy
../cbfstool/cbfstool coreboot-*.bin extract -f mrc.bin -n mrc.bin -r RO_SECTION
if ! echo "${MRC_BIN_HASH} mrc.bin" | sha256sum --check; then
echo "SHA256 checksum for mrc.bin doesn't match."
exit 1
fi
popd
mv "${COREBOOT_DIR}/util/chromeos/mrc.bin" "$(dirname "$0")/mrc.bin"
mv "${COREBOOT_DIR}/util/chromeos/mrc.bin" "$1/mrc.bin"
fi
if ! echo "${MRC_BIN_HASH} $1/mrc.bin" | sha256sum --check; then
echo "ERROR: SHA256 checksum for mrc.bin doesn't match."
exit 1
fi
fi
fi

View File

@ -4,7 +4,7 @@ set -e
function usage() {
echo -n \
"Usage: $(basename "$0")
"Usage: $(basename "$0") path_to_output_directory
Download Intel ME firmware from Lenovo, neutralize, and shrink.
"
}
@ -15,9 +15,12 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
if [[ "${1:-}" == "--help" ]]; then
usage
else
BLOB_DIR="$(cd "$(dirname "$0")" && pwd)"
COREBOOT_DIR="$(find "${BLOB_DIR}/../../build/x86/" -maxdepth 1 -type d -name 'coreboot-*')"
if [[ -z "${COREBOOT_DIR}" ]]; then
echo "ERROR: No COREBOOT_DIR variable defined."
exit 1
fi
if [[ ! -f "$1/me.bin" ]]; then
pushd "$(mktemp -d)"
curl -O https://download.lenovo.com/pccbbs/mobiles/glrg22ww.exe
@ -36,13 +39,14 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
# https://github.com/corna/me_cleaner/wiki/External-flashing#neutralize-and-shrink-intel-me-useful-only-for-coreboot
python me_cleaner.py -r -t -O me_shrinked.bin ME9.1_5M_Production.bin
mv me_shrinked.bin "${BLOB_DIR}/me.bin"
rm ./*.bin
popd
if ! echo "${ME_BIN_HASH} ${BLOB_DIR}/me.bin" | sha256sum --check; then
echo "SHA256 checksum for me.bin doesn't match."
mv "${COREBOOT_DIR}/util/me_cleaner/me_shrinked.bin" "$1/me.bin"
rm "${COREBOOT_DIR}/util/me_cleaner/"*.bin
fi
if ! echo "${ME_BIN_HASH} $1/me.bin" | sha256sum --check; then
echo "ERROR: SHA256 checksum for me.bin doesn't match."
exit 1
fi
fi

View File

@ -4,7 +4,7 @@ set -e
function usage() {
echo -n \
"Usage: $(basename "$0") path_to_original_rom
"Usage: $(basename "$0") path_to_original_rom path_to_output_directory
Extract Intel firmware from the original ROM.
"
}
@ -13,19 +13,22 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
if [[ "${1:-}" == "--help" ]]; then
usage
else
if [[ -n "$1" ]]; then
BLOB_DIR="$(cd "$(dirname "$0")" && pwd)"
COREBOOT_DIR="$(find "${BLOB_DIR}/../../build/x86/" -maxdepth 1 -type d -name 'coreboot-*')"
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 "${BLOB_DIR}/ifd.bin"
mv me_shrinked.bin "${BLOB_DIR}/me.bin"
mv ifd_shrinked.bin "$2/ifd.bin"
mv me_shrinked.bin "$2/me.bin"
rm ./*.bin
cd ../ifdtool
@ -35,11 +38,10 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
# original ROM.
./ifdtool -x "$1"
mv flashregion_3_gbe.bin "${BLOB_DIR}/gbe.bin"
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