Hung-Te Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35634 )
Change subject: vboot: create board-specific test-only GBB HWID if not set ......................................................................
vboot: create board-specific test-only GBB HWID if not set
The HWID in vboot GBB is an identifier for machine model. On Chrome OS, that should be provisioned in manufacturing process (by collecting real hardware information), and will be checked in system startup.
For bring up developers, they usually prefer to generate a test-only string for HWID. However that format was not well documented and cause problems. Further more, most Chromebooks are using HWID v3+ today while the test-only HWID is usually v2. Non-Chrome OS developers may also prefer their own format.
To simplify development process, the GBB_CONFIG now defaults to empty string, and will be replaced by a board-specific test-only v2 HWID automatically. Developers can still override that in mainboard Kconfig if they prefer v3 or other arbitrary format.
BUG=b:140067412 TEST=Built 'kukui' successfully. Removed kukui GBB config and built again, still seeing correct test HWID.
Change-Id: I0cda17a374641589291ec8dfb1d66c553f7cbf35 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/security/vboot/Kconfig M src/security/vboot/Makefile.inc A src/security/vboot/gen_hwid.sh 3 files changed, 50 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/35634/1
diff --git a/src/security/vboot/Kconfig b/src/security/vboot/Kconfig index 1e372d8..d6d74ca 100644 --- a/src/security/vboot/Kconfig +++ b/src/security/vboot/Kconfig @@ -228,7 +228,12 @@
config GBB_HWID string "Hardware ID" - default "NOCONF HWID" + default "" + help + A hardware identifier for device. On Chrome OS this is used for auto + update and recovery, and will be generated when manufacturing by the + factory software, in a strictly defined format. + Leave empty to get a test-only Chrome OS HWID v2 string generated.
config GBB_BMPFV_FILE string "Path to bmpfv image" diff --git a/src/security/vboot/Makefile.inc b/src/security/vboot/Makefile.inc index 3078e30..2aa9812 100644 --- a/src/security/vboot/Makefile.inc +++ b/src/security/vboot/Makefile.inc @@ -243,7 +243,9 @@ @printf " SETUP GBB\n" cp $< $@.tmp $(FUTILITY) gbb_utility -s \ - --hwid="$(CONFIG_GBB_HWID)" \ + --hwid="$$(src/security/vboot/gen_hwid.sh \ + "$(CONFIG_MAINBOARD_PART_NUMBER)" \ + "$(CONFIG_GBB_HWID)")" \ --rootkey="$(CONFIG_VBOOT_ROOT_KEY)" \ --recoverykey="$(CONFIG_VBOOT_RECOVERY_KEY)" \ --flags=$(GBB_FLAGS) \ diff --git a/src/security/vboot/gen_hwid.sh b/src/security/vboot/gen_hwid.sh new file mode 100755 index 0000000..949e67c7 --- /dev/null +++ b/src/security/vboot/gen_hwid.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# +# This file is part of the coreboot project. +# +# Copyright 2019 Google Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +die() { + echo "$*" >&2 + exit 1 +} + +if [ "$#" != 2 ]; then + die "Usage: $0 MAINBOARD_PARTNUMBER OVERRIDE_HWID" +fi + +part_number="$1" +override="$2" + +if [ -n "${override}" ]; then + echo "${override}" + exit +fi + +# Generate a test-only Chrome OS HWID v2 string +prefix="$(echo "${part_number}" | tr a-z A-Z) TEST" + +# TODO(hungte) Use rhash or crc32 if python is not available. +# Use Python2 or python 3. +crc="$(python -c "import zlib, sys; sys.stdout.write(\ + ('%04u' % (zlib.crc32('${prefix}'.encode('utf8')) & 0xffffffffL))[-4:])")" + +echo "${prefix}" "${crc}"