summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2016-08-15 22:14:04 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-19 14:21:23 -0700
commit8a2fbe288bd3c9cf597f46152f1146472ba9ab2c (patch)
treea4894ff34680d6f223358b488b492c6bdf0a47a7
parent65ba93af93d5f05cc00a1acaafc2f172f578a722 (diff)
downloadchrome-ec-8a2fbe288bd3c9cf597f46152f1146472ba9ab2c.tar.gz
g: report RW header version along with code revision
Header version fields are instrumental when determining which of the available images is started by the RO. Let's include the header version when reporting the RW images' version as well as RO. BRANCH=none BUG=none TEST=verified that RW header information is now included in the version command output: > vers Chip: g cr50 B2 Board: 0 RO_A: * 0.0.8/8755904e RO_B: -1.-1.-1/ffffffff RW_A: 0.0.1/cr50_v1.1.5093-751a584+ RW_B: * 0.0.1/cr50_v1.1.5093-d27f65f Build: 0.0.1/cr50_v1.1.5093-d27f65f ... Change-Id: I675c473a277e272f55670324fafdab8a6e6edd78 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/370939 Reviewed-by: Scott Collyer <scollyer@chromium.org>
-rw-r--r--chip/g/system.c37
-rw-r--r--common/system.c1
2 files changed, 33 insertions, 5 deletions
diff --git a/chip/g/system.c b/chip/g/system.c
index 461f05a462..075068e7ba 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -217,21 +217,27 @@ const char *system_get_version(enum system_image_copy_t copy)
* we can just return our version string.
*/
this_copy = system_get_image_copy();
- if (copy == this_copy)
- return version_data.version;
+ vaddr = get_program_memory_addr(this_copy);
+ h = (const struct SignedHeader *)vaddr;
+ if (copy == this_copy) {
+ snprintf(vers_str, sizeof(vers_str), "%d.%d.%d/%s",
+ h->epoch_, h->major_, h->minor_,
+ version_data.version);
+ return vers_str;
+ }
/*
* We want the version of the other RW image. The linker script
* puts the version string right after the reset vectors, so
* it's at the same relative offset. Measure that offset here.
*/
- vaddr = get_program_memory_addr(this_copy);
delta = (uintptr_t)&version_data - vaddr;
/* Now look at that offset in the requested image */
vaddr = get_program_memory_addr(copy);
if (vaddr == INVALID_ADDR)
break;
+ h = (const struct SignedHeader *)vaddr;
vaddr += delta;
v = (const struct version_struct *)vaddr;
@@ -240,8 +246,11 @@ const char *system_get_version(enum system_image_copy_t copy)
* the version string.
*/
if (v->cookie1 == version_data.cookie1 &&
- v->cookie2 == version_data.cookie2)
- return v->version;
+ v->cookie2 == version_data.cookie2) {
+ snprintf(vers_str, sizeof(vers_str), "%d.%d.%d/%s",
+ h->epoch_, h->major_, h->minor_, v->version);
+ return vers_str;
+ }
default:
break;
}
@@ -380,3 +389,21 @@ uint32_t system_get_board_properties(void)
#endif
return properties;
}
+
+/* Prepend header version to the current image's build info. */
+const char *system_get_build_info(void)
+{
+ static char combined_build_info[150];
+
+ if (!*combined_build_info) {
+ const struct SignedHeader *me;
+
+ me = (struct SignedHeader *)
+ get_program_memory_addr(system_get_image_copy());
+ snprintf(combined_build_info, sizeof(combined_build_info),
+ "%d.%d.%d/%s",
+ me->epoch_, me->major_, me->minor_, build_info);
+ }
+
+ return combined_build_info;
+}
diff --git a/common/system.c b/common/system.c
index 3b1e0ccbc7..6ef35be808 100644
--- a/common/system.c
+++ b/common/system.c
@@ -684,6 +684,7 @@ int system_get_board_version(void)
return v;
}
+__attribute__((weak)) /* Weird chips may need their own implementations */
const char *system_get_build_info(void)
{
return build_info;