summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c18
-rwxr-xr-xutil/getversion.sh31
2 files changed, 47 insertions, 2 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 8d2badaa2f..4f983e24f1 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -1071,9 +1071,17 @@ int cmd_version(int argc, char *argv[])
{
struct ec_response_get_version r;
char *build_string = (char *)ec_inbuf;
+ int cmdver = 1;
int rv;
- rv = ec_command(EC_CMD_GET_VERSION, 0, NULL, 0, &r, sizeof(r));
+ if (!ec_cmd_version_supported(EC_CMD_GET_VERSION, 1)) {
+ cmdver = 0;
+ /* CrOS FWID is not supported. Set it to empty string. */
+ r.cros_fwid_ro[0] = '\0';
+ r.cros_fwid_rw[0] = '\0';
+ }
+
+ rv = ec_command(EC_CMD_GET_VERSION, cmdver, NULL, 0, &r, sizeof(r));
if (rv < 0) {
fprintf(stderr, "ERROR: EC_CMD_GET_VERSION failed: %d\n", rv);
goto exit;
@@ -1085,16 +1093,22 @@ int cmd_version(int argc, char *argv[])
rv);
goto exit;
}
+
rv = 0;
/* Ensure versions are null-terminated before we print them */
r.version_string_ro[sizeof(r.version_string_ro) - 1] = '\0';
r.version_string_rw[sizeof(r.version_string_rw) - 1] = '\0';
build_string[ec_max_insize - 1] = '\0';
-
+ r.cros_fwid_ro[sizeof(r.cros_fwid_ro) - 1] = '\0';
+ r.cros_fwid_rw[sizeof(r.cros_fwid_rw) - 1] = '\0';
/* Print versions */
printf("RO version: %s\n", r.version_string_ro);
+ if (cmdver > 0 && strlen(r.cros_fwid_ro))
+ printf("RO cros fwid: %s\n", r.cros_fwid_ro);
printf("RW version: %s\n", r.version_string_rw);
+ if (cmdver > 0 && strlen(r.cros_fwid_rw))
+ printf("RW cros fwid: %s\n", r.cros_fwid_rw);
printf("Firmware copy: %s\n",
(r.current_image < ARRAY_SIZE(image_names) ?
image_names[r.current_image] : "?"));
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