summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-09-06 15:51:46 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-02-09 20:36:07 +0000
commit87d50d265d98f3e1f483e2e62b83639e752dd7fb (patch)
tree37ab9efc81504cbe56b5357dceaf1261affb69e3
parent06eae4e50863fad7870b27c97501b81d7f2cbc51 (diff)
downloadchrome-ec-87d50d265d98f3e1f483e2e62b83639e752dd7fb.tar.gz
g: rename usb_updater into gsctool
The usb_updater utility has long been not just an updater, and has long been using other interfaces in addition to USB. gsctool is a much more suitable name. CQ-DEPEND=CL:709776 BRANCH=cr50,eve BUG=b:67007500,chromium:810784 TEST=verified that make -C ./extra/usb_updater generates ./extra/usb_updater/gsctool: $ ./extra/usb_updater/gsctool --help Usage: gsctool [options] <binary image> This updates the Cr50 RW firmware over USB. The required argument is the full RO+RW image. Options: [...] $ TEST=emerge-eve works in factory branch after revert. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/709738 Reviewed-by: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit a08f61506cc71b690858e51da905c7dcb2d7ef10) Conflicts: Accept all changes in util/signer/create_released_image.sh Change-Id: I3ab70c28acf3664ddefaa923a87ba1fd5c3c437b Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/894342
-rw-r--r--extra/usb_updater/.gitignore2
-rw-r--r--extra/usb_updater/Makefile4
-rw-r--r--extra/usb_updater/gsctool.c (renamed from extra/usb_updater/usb_updater.c)0
-rw-r--r--extra/usb_updater/usb_updater2.c2
-rw-r--r--include/rwsig.h4
-rw-r--r--include/tpm_vendor_cmds.h2
-rwxr-xr-xutil/signer/create_released_image.sh46
7 files changed, 48 insertions, 12 deletions
diff --git a/extra/usb_updater/.gitignore b/extra/usb_updater/.gitignore
index 5f2aa1f17b..e356628d7d 100644
--- a/extra/usb_updater/.gitignore
+++ b/extra/usb_updater/.gitignore
@@ -1,2 +1,2 @@
-usb_updater
+gsctool
usb_updater2
diff --git a/extra/usb_updater/Makefile b/extra/usb_updater/Makefile
index f7b74a6f94..49b8a1af2c 100644
--- a/extra/usb_updater/Makefile
+++ b/extra/usb_updater/Makefile
@@ -4,7 +4,7 @@
CC ?= gcc
PKG_CONFIG ?= pkg-config
-PROGRAMS := usb_updater usb_updater2
+PROGRAMS := gsctool usb_updater2
LIBS :=
LFLAGS :=
CFLAGS := -std=gnu99 \
@@ -42,7 +42,7 @@ LIBS_common = -lfmap
all: $(PROGRAMS)
# chip/g updater
-usb_updater: usb_updater.c Makefile
+gsctool: gsctool.c Makefile
$(CC) $(CFLAGS) $(CFLAGS_g) $< $(LFLAGS) $(LIBS) $(LIBS_g) -o $@
# common EC code USB updater
diff --git a/extra/usb_updater/usb_updater.c b/extra/usb_updater/gsctool.c
index 669bac3b97..669bac3b97 100644
--- a/extra/usb_updater/usb_updater.c
+++ b/extra/usb_updater/gsctool.c
diff --git a/extra/usb_updater/usb_updater2.c b/extra/usb_updater/usb_updater2.c
index 3e676c0334..9e6dac9090 100644
--- a/extra/usb_updater/usb_updater2.c
+++ b/extra/usb_updater/usb_updater2.c
@@ -36,7 +36,7 @@
/*
* This file contains the source code of a Linux application used to update
- * EC device firmware (common code only, usb_updater takes care of cr50).
+ * EC device firmware (common code only, gsctool takes care of cr50).
*/
#define VID USB_VID_GOOGLE
diff --git a/include/rwsig.h b/include/rwsig.h
index bb70077732..257e893f1d 100644
--- a/include/rwsig.h
+++ b/include/rwsig.h
@@ -28,14 +28,14 @@ enum rwsig_status rwsig_get_status(void);
/*
* Aborts current verification, also prevents RWSIG task from automatically
* jumping to RW.
- * This is used by usb_updater when a RW update is required, giving it enough
+ * This is used by usb_updater2 when a RW update is required, giving it enough
* time to actually perform the update.
*/
void rwsig_abort(void);
/*
* Tells RWSIG task to jump to RW immediately, if the signature is correct.
- * This is used by usb_updater when no RW update is required, to speed up
+ * This is used by usb_updater2 when no RW update is required, to speed up
* boot time.
*/
void rwsig_continue(void);
diff --git a/include/tpm_vendor_cmds.h b/include/tpm_vendor_cmds.h
index 1f9e552aaa..aabbca18d8 100644
--- a/include/tpm_vendor_cmds.h
+++ b/include/tpm_vendor_cmds.h
@@ -9,7 +9,7 @@
/*
* This file includes definitions of extended/vendor TPM2 commands and their
* return codes. The definitions are shared between the embedded code and the
- * usb_updater utility running on the host.
+ * gsctool utility running on the host.
*/
/* Extension and vendor commands. */
diff --git a/util/signer/create_released_image.sh b/util/signer/create_released_image.sh
index 6b8190fdf6..7d3cb72048 100755
--- a/util/signer/create_released_image.sh
+++ b/util/signer/create_released_image.sh
@@ -89,9 +89,44 @@ prepare_image() {
dd if="${TMPD}/0.bin" of="${RESULT_FILE}" conv=notrunc
dd if="${TMPD}/1.bin" of="${RESULT_FILE}" seek=262144 bs=1 conv=notrunc
- version="$(usb_updater -b "${RESULT_FILE}" |\
- awk '/^RO_A:/ {gsub(/R[OW]_A:/, ""); print "r" $1 ".w" $2}')"
-
+ # A typical Cr50 version reported by gsctool looks as follows:
+ # RO_A:0.0.10 RW_A:0.0.22[ABCD:00000013:00000012] ...(the same for R[OW]_B).
+ #
+ # In case Board ID field is not set in the image, it is reported as
+ # [00000000:00000000:00000000]
+ #
+ # We want the generated tarball file name to include all relevant version
+ # fields. Let's retrieve the version string and process it using awk to
+ # generate the proper file name. Only the RO_A and RW_A version numbers are
+ # used, this script trusts the user to submit for processing a proper image
+ # where both ROs and both RWs are of the same version respectively.
+ #
+ # As a result, blob versions are converted as follows:
+ # RO_A:0.0.10 RW_A:0.0.22[ABCD:00000013:00000012] into
+ # r0.0.10.w0.0.22_ABCD_00000013_00000012
+ #
+ # RO_A:0.0.10 RW_A:0.0.22[00000000:00000000:00000000] into
+ # r0.0.10.w0.0.22
+ #
+ # The below awk program accomplishes this preprocessing.
+ awk_prog='/^RO_A:/ {
+ # drop the RO_A/RW_A strings
+ gsub(/R[OW]_A:/, "")
+ # Drop default mask value completely.
+ gsub(/\[00000000:00000000:00000000\]/, "")
+ # If there is a non-default mask:
+ # - replace opening brackets and colons with underscores.
+ gsub(/[\[\:]/, "_")
+ # - drop the trailing bracket.
+ gsub(/\]/, "")
+ # Print filtered out RO_A and RW_A values
+ print "r" $1 ".w" $2
+}'
+
+ raw_version="$("${GSCTOOL}" -b "${RESULT_FILE}")" ||
+ ( echo "${ME}: Failed to retrieve blob version" >&2 && exit 1 )
+
+ version="$(awk "${awk_prog}" <<< "${raw_version}" )"
if [ -z "${dest_dir}" ]; then
# Note that this is a global variable
dest_dir="cr50.${version}"
@@ -119,8 +154,9 @@ dest_dir=
IMAGE_SIZE='524288'
export RESULT_FILE
-if [ -z "${CROS_WORKON_SRCROOT}" ]; then
- echo "$(basename $0): This script must run inside Chrome OS chroot" >&2
+GSCTOOL="${EC_ROOT}/extra/usb_updater/gsctool"
+if [[ ! -x "${GSCTOOL}" ]]; then
+ echo "${ME}: gsctool not found, run \"make -C extra/usb_updater\"" >&2
exit 1
fi