From 401c0882aaec059eab62b5ce467d3efbc1472d1f Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 7 Jan 2024 13:25:33 +0000 Subject: NEW MAINBOARD: HP EliteBook 820 G2 This is of Broadwell platform, one generation above Haswell. Of note: this uses HP Sure Start. Although the flash is 16MB, our CBFS section (and IFD configuration) assumes 12MB flash, so the final 4MB will be left unflashed on installation, after blanking the private flash. The coreboot documents have more information about this. Some minor design changes in lbmk were made, to accomodate this port: Support for extracting refcode binaries added (pulled from Google recovery images). The refcode file is an ELF that initialises the MRC and the PCH. It is also responsible for enabling or disabling the Intel GbE device, where Google does not enable it, but lbmk modifies it per the instructions on the coreboot documentation, so as to enable Intel GbE. Google's recovery image stores the refcode as a stage file, but coreboot changed the format (for CBFS files) after 4.13 so coreboot 4.13's cbfstool is used to extract refcode. This realisation made me also change the script logic to use a cbfstool and ifdtool version matching the coreboot tree, for all parts of lbmk, whereas lbmk previously used only the default tree for cbfstool/ifdtool, on insertion and deletion of vendor files - it was 81dc20e744 that broke extraction of refcode on google's recovery images, where google used an older version of cbfstool to insert the files in their coreboot ROMs. A further backported patch has been added, copying coreboot revision f22f408956 which is a build fix from Nico Huber. Iru Cai submitted an ACPI bugfix after the revision lbmk currently uses, for coreboot/default, and this fix is needed for rebooting to work on Linux 6.1 or higher. This patch has been backported to lbmk, while it still uses the same October 2023 revision of coreboot. Broadwell MRC is inserted at the same offset as Haswell, so I didn't need to tweak that. Signed-off-by: Leah Rowe --- script/vendor/download | 32 ++++++++++++++++++++++++++------ script/vendor/inject | 30 ++++++++++++++++++++++-------- 2 files changed, 48 insertions(+), 14 deletions(-) (limited to 'script') diff --git a/script/vendor/download b/script/vendor/download index 1f96c665..592c14bc 100755 --- a/script/vendor/download +++ b/script/vendor/download @@ -2,7 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-only # SPDX-FileCopyrightText: 2022 Caleb La Grange # SPDX-FileCopyrightText: 2022 Ferass El Hafidi -# SPDX-FileCopyrightText: 2023 Leah Rowe +# SPDX-FileCopyrightText: 2023-2024 Leah Rowe . "include/err.sh" . "include/option.sh" @@ -14,16 +14,15 @@ _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0" _7ztest="a" e6400_unpack="${PWD}/src/bios_extract/dell_inspiron_1100_unpacker.py" -kbc1126_ec_dump="${PWD}/${cbdir}/util/kbc1126/kbc1126_ec_dump" me7updateparser="${PWD}/util/me7_update_parser/me7_update_parser.py" -mecleaner="${PWD}/${cbdir}/util/me_cleaner/me_cleaner.py" pfs_extract="${PWD}/src/biosutilities/Dell_PFS_Extract.py" uefiextract="${PWD}/src/uefitool/uefiextract" eval "$(setvars "" _b _dl EC_url EC_url_bkup EC_hash DL_hash DL_url DL_url_bkup \ E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \ E6400_VGA_romname SCH5545EC_DL_url SCH5545EC_DL_url_bkup SCH5545EC_DL_hash \ - is_rom)" + is_rom tree mecleaner kbc1126_ec_dump MRC_refcode_cbtree cbfstoolref \ + MRC_refcode_gbe)" main() { @@ -50,6 +49,13 @@ detect_firmware() set -- "${boarddir}/config/"* . "${1}" 2>/dev/null + . "${boarddir}/target.cfg" 2>/dev/null + [ -z "$tree" ] && err "detect_firmware $boarddir: tree undefined" + cbdir="src/coreboot/$tree" + cbfstool="cbutils/$tree/cbfstool" + + mecleaner="${PWD}/${cbdir}/util/me_cleaner/me_cleaner.py" + kbc1126_ec_dump="${PWD}/${cbdir}/util/kbc1126/kbc1126_ec_dump" for c in CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN CONFIG_KBC1126_FIRMWARE \ CONFIG_VGA_BIOS_FILE CONFIG_INCLUDE_SMSC_SCH5545_EC_FW; do @@ -66,9 +72,14 @@ build_dependencies() x_ ./update trees -f "${d}" done [ -f "${uefiextract}" ] || x_ ./update trees -b uefitool - [ -f "${kbc1126_ec_dump}" ] || x_ make -C "${cbdir}/util/kbc1126" + [ ! -d "${kbc1126_ec_dump%/*}" ] || [ -f "${kbc1126_ec_dump}" ] || x_ \ + make -C "${cbdir}/util/kbc1126" + [ -n "$MRC_refcode_cbtree" ] && \ + cbfstoolref="cbutils/$MRC_refcode_cbtree/cbfstool" + [ -z "$cbfstoolref" ] || [ -f "$cbfstoolref" ] || \ + x_ ./update trees -b coreboot utils $MRC_refcode_cbtree [ -f "${cbfstool}" ] && [ -f "${ifdtool}" ] && return 0 - x_ ./update trees -b coreboot utils default + x_ ./update trees -b coreboot utils $tree } download_vendorfiles() @@ -87,6 +98,10 @@ download_vendorfiles() "$E6400_VGA_DL_hash" "$CONFIG_VGA_BIOS_FILE" [ -z "${CONFIG_HAVE_MRC}" ] && return 0 fetch "mrc" "$MRC_url" "$MRC_url_bkup" "$MRC_hash" "$CONFIG_MRC_FILE" + + # in case only mrc downloaded before, in a pair of mrc/refcode: + [ -n "$CONFIG_REFCODE_BLOB_FILE" ] && fetch "ref" "$MRC_url" \ + "$MRC_url_bkup" "$MRC_hash" "$CONFIG_REFCODE_BLOB_FILE"; return 0 } fetch() @@ -156,6 +171,9 @@ mkdirs() extract_intel_me() { + [ ! -f "$mecleaner" ] && \ + err "extract_intel_me $cbdir: me_cleaner missing" + _me="${PWD}/${_dest}" # must always be an absolute path cdir="${PWD}/${appdir}" # must always be an absolute path [ $# -gt 0 ] && _me="${1}" && cdir="${2}" @@ -198,6 +216,8 @@ extract_archive() extract_kbc1126ec() { + [ ! -f "$kbc1126_ec_dump" ] && \ + err "extract_kbc1126ec $cbdir: kbc1126_ec_dump missing" ( x_ cd "${appdir}/" mv Rompaq/68*.BIN ec.bin || : diff --git a/script/vendor/inject b/script/vendor/inject index 5734b599..2f55e166 100755 --- a/script/vendor/inject +++ b/script/vendor/inject @@ -2,14 +2,14 @@ # SPDX-License-Identifier: GPL-3.0-only # SPDX-FileCopyrightText: 2022 Caleb La Grange # SPDX-FileCopyrightText: 2022 Ferass El Hafidi -# SPDX-FileCopyrightText: 2023 Leah Rowe +# SPDX-FileCopyrightText: 2023-2024 Leah Rowe . "include/err.sh" . "include/option.sh" nvmutil="util/nvmutil/nvm" -eval "$(setvars "" archive rom modifygbe nukemode release new_mac)" +eval "$(setvars "" archive rom modifygbe nukemode release new_mac tree)" main() { @@ -51,7 +51,11 @@ check_board() fi boarddir="${cbcfgsdir}/${board}" - [ -d "$boarddir" ] || err "check_board: board $board missing"; return 0 + [ -d "$boarddir" ] || err "check_board: board $board missing" + [ -f "$boarddir/target.cfg" ] || \ + err "check_board $board: target.cfg missing" + . "$boarddir/target.cfg" 2>/dev/null + [ -z "$tree" ] && err "check_board $board: tree undefined"; return 0 } check_release() @@ -84,9 +88,12 @@ detect_board() build_dependencies() { - [ -d "${cbdir}" ] || x_ ./update trees -f coreboot default + cbdir="src/coreboot/$tree" + cbfstool="cbutils/$tree/cbfstool" + ifdtool="cbutils/$tree/ifdtool" + [ -d "${cbdir}" ] || x_ ./update trees -f coreboot $tree if [ ! -f "${cbfstool}" ] || [ ! -f "${ifdtool}" ]; then - x_ ./update trees -b coreboot utils default + x_ ./update trees -b coreboot utils $tree fi [ -z "$new_mac" ] || [ -f "$nvmutil" ] || x_ make -C util/nvmutil [ "$nukemode" = "nuke" ] || x_ ./vendor download $board; return 0 @@ -144,6 +151,8 @@ patch_rom() [ "$CONFIG_HAVE_MRC" = "y" ] && \ inject "mrc.bin" "${CONFIG_MRC_FILE}" "mrc" "0xfffa0000" + [ -n "$CONFIG_HAVE_REFCODE_BLOB" ] && \ + inject "fallback/refcode" "$CONFIG_REFCODE_BLOB_FILE" "stage" [ "${CONFIG_HAVE_ME_BIN}" = "y" ] && \ inject "IFD" "${CONFIG_ME_BIN_PATH}" "me" [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ] && \ @@ -200,9 +209,14 @@ inject() fi else if [ "${nukemode}" != "nuke" ]; then - "$cbfstool" "$rom" add -f "$_dest" \ - -n "$cbfsname" -t $_t $_offset || \ - err "inject $rom: can't insert $_t file $_dest" + if [ "$_t" = "stage" ]; then # broadwell refcode + "$cbfstool" "$rom" add-stage -f "$_dest" \ + -n "$cbfsname" -t stage -c lzma + else + "$cbfstool" "$rom" add -f "$_dest" \ + -n "$cbfsname" -t $_t $_offset || \ + err "$rom: can't insert $_t file $_dest" + fi else "$cbfstool" "$rom" remove -n "$cbfsname" || \ err "inject $rom: can't remove $cbfsname" -- cgit v1.2.1