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() { function usage() {
echo -n \ echo -n \
"Usage: $(basename "$0") "Usage: $(basename "$0") path_to_output_directory
Obtain mrc.bin from a Haswell Chromebook firmware image. Obtain mrc.bin from a Haswell Chromebook firmware image.
" "
} }
@ -15,9 +15,12 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
if [[ "${1:-}" == "--help" ]]; then if [[ "${1:-}" == "--help" ]]; then
usage usage
else else
BLOB_DIR="$(cd "$(dirname "$0")" && pwd)" if [[ -z "${COREBOOT_DIR}" ]]; then
COREBOOT_DIR="$(find "${BLOB_DIR}/../../build/x86/" -maxdepth 1 -type d -name 'coreboot-*')" echo "ERROR: No COREBOOT_DIR variable defined."
exit 1
fi
if [[ ! -f "$1/mrc.bin" ]]; then
pushd "${COREBOOT_DIR}" pushd "${COREBOOT_DIR}"
# https://doc.coreboot.org/northbridge/intel/haswell/mrc.bin.html#obtaining-mrc-bin # 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 ./crosfirmware.sh peppy
../cbfstool/cbfstool coreboot-*.bin extract -f mrc.bin -n mrc.bin -r RO_SECTION ../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 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
fi fi

View File

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

View File

@ -4,7 +4,7 @@ set -e
function usage() { function usage() {
echo -n \ 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. Extract Intel firmware from the original ROM.
" "
} }
@ -13,19 +13,22 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
if [[ "${1:-}" == "--help" ]]; then if [[ "${1:-}" == "--help" ]]; then
usage usage
else else
if [[ -n "$1" ]]; then if [[ -z "${COREBOOT_DIR}" ]]; then
BLOB_DIR="$(cd "$(dirname "$0")" && pwd)" echo "ERROR: No COREBOOT_DIR variable defined."
COREBOOT_DIR="$(find "${BLOB_DIR}/../../build/x86/" -maxdepth 1 -type d -name 'coreboot-*')" exit 1
fi
if [[ -n "$1" ]]; then
pushd "${COREBOOT_DIR}" pushd "${COREBOOT_DIR}"
cd util/me_cleaner cd util/me_cleaner
# Neutralize and shrink Intel ME. # Neutralize and shrink Intel ME.
# https://github.com/corna/me_cleaner/wiki/External-flashing#neutralize-and-shrink-intel-me-useful-only-for-coreboot # 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" 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 ifd_shrinked.bin "$2/ifd.bin"
mv me_shrinked.bin "${BLOB_DIR}/me.bin" mv me_shrinked.bin "$2/me.bin"
rm ./*.bin rm ./*.bin
cd ../ifdtool cd ../ifdtool
@ -35,11 +38,10 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
# original ROM. # original ROM.
./ifdtool -x "$1" ./ifdtool -x "$1"
mv flashregion_3_gbe.bin "${BLOB_DIR}/gbe.bin" mv flashregion_3_gbe.bin "$2/gbe.bin"
rm ./*.bin rm ./*.bin
popd popd
else else
echo "ERROR: You must supply a path to the original ROM." echo "ERROR: You must supply a path to the original ROM."
exit 1 exit 1