diff options
-rw-r--r-- | chip/g/system.c | 37 | ||||
-rw-r--r-- | common/system.c | 1 |
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; |