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>
This commit is contained in:
Vadim Bendebury
2016-08-15 22:14:04 -07:00
committed by chrome-bot
parent 65ba93af93
commit 8a2fbe288b
2 changed files with 33 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -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;