diff options
author | Rob Barnes <robbarnes@google.com> | 2021-05-13 12:27:56 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-14 12:18:02 +0000 |
commit | 5d157c8679880b8c86bb3944daa35ba25aece58b (patch) | |
tree | c8285384008e6ee38b16d88e13f8f258298f3808 /util/getversion.sh | |
parent | da4711d25c547f760efd1b2e8df1af2957972eae (diff) | |
download | chrome-ec-5d157c8679880b8c86bb3944daa35ba25aece58b.tar.gz |
system: Add CrOS FWID to version output
EC version does not follow the the AP and OS version. This causes
confusion during development. This change augments the EC version output
to include the CrOS FWID when available. The CrOS FWID will be missing
when the CrOS EC is built outside of cros_sdk. When CrOS FWID is missing
'CROS_FWID_MISSING' will be used.
Zephyr/zmake support will be added later, CROS_FWID32 is set to
'CROS_FWID_MISSING' in zephyr builds until then.
BUG=b:188073399
TEST=version
21-05-20 16:43:18.627 Chip: Nuvoton NPCX993F A.00160101
21-05-20 16:43:18.631 Board: 1
21-05-20 16:43:18.631 RO: guybrush_v2.0.8770+f47439f75
21-05-20 16:43:18.634 guybrush_13983.0.21_05_20
21-05-20 16:43:18.639 RW_A: * guybrush_v2.0.8770+f47439f75
21-05-20 16:43:18.641 * guybrush_13983.0.21_05_20
21-05-20 16:43:18.644 RW_B: guybrush_v2.0.8770+f47439f75
21-05-20 16:43:18.644 guybrush_13983.0.21_05_20
21-05-20 16:43:18.647 Build: guybrush_v2.0.8770+f47439f75
21-05-20 16:43:18.651 guybrush_13983.0.21_05_20 2021-05-20
21-05-20 16:43:18.657 16:31:19 robbarnes@robbarnes0
ectool version
RO version: guybrush_v2.0.8770+f47439f75
RO cros fwid: guybrush_13983.0.21_05_20
RW version: guybrush_v2.0.8770+f47439f75
RW cros fwid: guybrush_13983.0.21_05_20
Firmware copy: RO
Build info: guybrush_v2.0.8770+f47439f75
guybrush_13983.0.21_05_20 2021-05-20 16:31:19 robbarnes@robbarnes0
Tool version: 1.1.9999-f47439f @robbarnes0
BRANCH=None
Signed-off-by: Rob Barnes <robbarnes@google.com>
Change-Id: Ief0a0c6e9d35edc72ac2d4780ee203be41d7305f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2894145
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'util/getversion.sh')
-rwxr-xr-x | util/getversion.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/util/getversion.sh b/util/getversion.sh index 165383d879..3146b29c88 100755 --- a/util/getversion.sh +++ b/util/getversion.sh @@ -21,6 +21,11 @@ dc=$'\001' # Default marker to indicate 'dirty' repositories dirty_marker='+' +# Derive path to chromeos_version.sh script +CHROOT_SOURCE_ROOT="/mnt/host/source" +CHROMIUMOS_OVERLAY="${CHROOT_SOURCE_ROOT}/src/third_party/chromiumos-overlay" +CROS_VERSION_SCRIPT="${CHROMIUMOS_OVERLAY}/chromeos/config/chromeos_version.sh" + # This function examines the state of the current directory and attempts to # extract its version information: the latest tag, if any, how many patches # are there since the latest tag, the top sha1, and if there are local @@ -196,6 +201,32 @@ main() { done | sort | tail -1 | cut -d ' ' -f '2 3')" echo "#define DATE \"${gitdate}\"" fi + + # Use the chromeos_version_string when available. + # This will not work if run from a standalone CrOS EC checkout. + echo "#define CROS_FWID_MISSING_STR \"CROS_FWID_MISSING\"" + if [[ -f "${CROS_VERSION_SCRIPT}" ]]; then + cros_version_output=$("${CROS_VERSION_SCRIPT}") + CHROMEOS_BUILD=$(echo "${cros_version_output}" | \ + grep "^ *CHROMEOS_BUILD=" | cut -d= -f2) + CHROMEOS_BRANCH=$(echo "${cros_version_output}" | \ + grep "^ *CHROMEOS_BRANCH=" | cut -d= -f2) + CHROMEOS_PATCH=$(echo "${cros_version_output}" | \ + grep "^ *CHROMEOS_PATCH=" | cut -d= -f2) + # Official builds must set CHROMEOS_OFFICIAL=1. + if [ "${CHROMEOS_OFFICIAL:-0}" -ne 1 ]; then + # For developer builds, overwrite CHROMEOS_PATCH with the date. + # This date is abbreviated compared to chromeos_version.sh so + # fwid_version will more likely fit in 32 bytes. + CHROMEOS_PATCH=$(date +%y_%m_%d) + fi + fwid="${BOARD}_${CHROMEOS_BUILD}.${CHROMEOS_BRANCH}.${CHROMEOS_PATCH}" + echo "/* CrOS FWID of this build */" + echo "#define CROS_FWID32 \"${fwid:0:31}\"" + else + echo "/* CrOS FWID is not available for this build */" + echo "#define CROS_FWID32 CROS_FWID_MISSING_STR" + fi } main |