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 <matt.devillier@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61615
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Matt DeVillier 2022-02-03 19:18:29 -06:00 committed by Felix Held
parent b8258bd2b9
commit e42731603e
1 changed files with 22 additions and 6 deletions

View File

@ -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"