From e42731603e683c614ba67b8fd46d7f98ed7cbc9e Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Thu, 3 Feb 2022 19:18:29 -0600 Subject: [PATCH] util/chromeos/crosfirmware: Fix handling of newer boards Wile historically there was a unique recovery image for each Chrome OS board/HWID (with matching names), this is no longer the case. Now, multiple boards share a single recovery image, so adjust how the proper recovery image is determined, and how the coreboot image is extracted from it. Test: successfully extract coreboot images for older 1:1 boards (e.g. CAVE) and newer 1:N boards (e.g. DROBIT) Change-Id: If478aa6eadea3acf3ee9d4c5fa266acd72c99b7a Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/61615 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- util/chromeos/crosfirmware.sh | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/util/chromeos/crosfirmware.sh b/util/chromeos/crosfirmware.sh index 25c88fa346..92018e9d24 100755 --- a/util/chromeos/crosfirmware.sh +++ b/util/chromeos/crosfirmware.sh @@ -84,13 +84,29 @@ extract_coreboot() _unpacked=$( mktemp -d ) echo "Extracting coreboot image" - sh $_shellball --sb_extract $_unpacked > /dev/null + if ! sh $_shellball --unpack $_unpacked > /dev/null 2>&1; then + sh $_shellball --sb_extract $_unpacked > /dev/null 2>&1 + fi - _version=$( cat $_unpacked/VERSION | grep BIOS\ version: | \ + if [ -d $_unpacked/models/ ]; then + _version=$( cat $_unpacked/VERSION | grep -m 1 -e Model.*$_board -A5 \ + | grep "BIOS (RW) version:" | cut -f2 -d: | tr -d \ ) + if [ "$_version" == "" ]; then + _version=$( cat $_unpacked/VERSION | grep -m 1 -e Model.*$_board -A5 \ + | grep "BIOS version:" | cut -f2 -d: | tr -d \ ) + fi + _bios_image=$(grep "IMAGE_MAIN" $_unpacked/models/$_board/setvars.sh \ + | cut -f2 -d\") + else + _version=$( cat $_unpacked/VERSION | grep BIOS\ version: | \ cut -f2 -d: | tr -d \ ) - - cp $_unpacked/bios.bin coreboot-$_version.bin - rm -r "$_unpacked" + _bios_image=bios.bin + fi + if cp $_unpacked/$_bios_image coreboot-$_version.bin; then + echo "Extracted coreboot-$_version.bin" + fi + rm -rf "$_unpacked" + rm $_shellball } do_one_board() @@ -135,7 +151,7 @@ elif [ "$BOARD" != "" ]; then get_inventory $CONF echo Processing board $BOARD - eval $( grep $BOARD $CONF | grep '\(url=\|file=\)' ) + eval $( grep -i $BOARD -A8 $CONF | grep '\(url=\|file=\)' ) do_one_board $BOARD $url $file rm "$CONF"