From 144f9c147ed9b409ff6ec2b5a8e466b58a1fcf0f Mon Sep 17 00:00:00 2001 From: Rocky Breslow <1774125+rbreslow@users.noreply.github.com> Date: Sat, 25 Feb 2023 19:39:18 -0500 Subject: [PATCH] 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. --- blobs/haswell/obtain-mrc | 36 +++++++++++++++------------- blobs/t440p/download-clean-me | 44 +++++++++++++++++++---------------- blobs/t440p/extract | 18 +++++++------- 3 files changed, 54 insertions(+), 44 deletions(-) diff --git a/blobs/haswell/obtain-mrc b/blobs/haswell/obtain-mrc index 90ef568c..c7cf8d97 100755 --- a/blobs/haswell/obtain-mrc +++ b/blobs/haswell/obtain-mrc @@ -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,24 +15,28 @@ 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-*')" - - pushd "${COREBOOT_DIR}" - - # https://doc.coreboot.org/northbridge/intel/haswell/mrc.bin.html#obtaining-mrc-bin - make -C util/cbfstool - cd util/chromeos - ./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." + if [[ -z "${COREBOOT_DIR}" ]]; then + echo "ERROR: No COREBOOT_DIR variable defined." exit 1 fi - popd + if [[ ! -f "$1/mrc.bin" ]]; then + pushd "${COREBOOT_DIR}" - mv "${COREBOOT_DIR}/util/chromeos/mrc.bin" "$(dirname "$0")/mrc.bin" + # https://doc.coreboot.org/northbridge/intel/haswell/mrc.bin.html#obtaining-mrc-bin + make -C util/cbfstool + cd util/chromeos + ./crosfirmware.sh peppy + ../cbfstool/cbfstool coreboot-*.bin extract -f mrc.bin -n mrc.bin -r RO_SECTION + + popd + + 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 diff --git a/blobs/t440p/download-clean-me b/blobs/t440p/download-clean-me index 38e272fa..111b690c 100755 --- a/blobs/t440p/download-clean-me +++ b/blobs/t440p/download-clean-me @@ -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,34 +15,38 @@ 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 - pushd "$(mktemp -d)" + if [[ ! -f "$1/me.bin" ]]; then + pushd "$(mktemp -d)" - curl -O https://download.lenovo.com/pccbbs/mobiles/glrg22ww.exe - innoextract glrg22ww.exe + curl -O https://download.lenovo.com/pccbbs/mobiles/glrg22ww.exe + innoextract glrg22ww.exe - mv app/ME9.1_5M_Production.bin "${COREBOOT_DIR}/util/me_cleaner" + mv app/ME9.1_5M_Production.bin "${COREBOOT_DIR}/util/me_cleaner" - popd + popd - pushd "${COREBOOT_DIR}/util/me_cleaner" + pushd "${COREBOOT_DIR}/util/me_cleaner" - # Neutralize and shrink Intel ME. Note that this doesn't include - # --soft-disable to set the "ME Disable" or "ME Disable B" (e.g., High - # Assurance Program) bits, as they are defined within the Flash - # Descriptor. - # 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 + # Neutralize and shrink Intel ME. Note that this doesn't include + # --soft-disable to set the "ME Disable" or "ME Disable B" (e.g., High + # Assurance Program) bits, as they are defined within the Flash + # Descriptor. + # 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 - popd + 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} ${BLOB_DIR}/me.bin" | sha256sum --check; then - echo "SHA256 checksum for me.bin doesn't match." + 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 diff --git a/blobs/t440p/extract b/blobs/t440p/extract index aba59c49..cccb286b 100755 --- a/blobs/t440p/extract +++ b/blobs/t440p/extract @@ -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