diff options
author | Bill Richardson <wfrichar@chromium.org> | 2016-07-24 23:58:05 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-07-26 12:27:33 -0700 |
commit | 20a6d75aee99c50a1646b73e11e7bb84276439c6 (patch) | |
tree | 9588552acafe7f29da2f3c3622c0207337d42659 /test | |
parent | 0564276033dd2615b95fa3f85152b9cc56c166d3 (diff) | |
download | chrome-ec-20a6d75aee99c50a1646b73e11e7bb84276439c6.tar.gz |
g: Improve version info for dual RO & RW images
The SoC looks for two RO images at reset, and is typically
configured for two RW images as well. This CL reports version
strings for all those images, as well as identifying the active
RO and RW copies.
Since the RO image doesn't contain a version string, we create
one using the epoch_, major_, minor_, and img_chk_ members of its
signed header.
BUG=chrome-os-partner:55558
BRANCH=none
TEST=make buildall; run on Cr50 hardware
The "version" command now includes information like this:
RO_A: * 0.0.2/a3c3d5ea
RO_B: 0.0.2/8895c9eb
RW_A: cr50_v1.1.4965-a6c1c73-dirty
RW_B: * cr50_v1.1.4959-2f49d5c
The '*' indicates the active image.
The test/tpm_test/tpmtest.py program has been updated to request
the version information at startup, and it also now reports
similar information, just all on one line:
RO_A:* 0.0.2/a3c3d5ea RO_B: 0.0.2/8895c9eb RW_A: cr50_v1.1 ...
The active images are marked with a '*' following the ':', so
that the same regexp can match either format:
($ro, $rw) = m/RO_[AB]:\s*\*\s+(\S+).*RW_[AB]:\s*\*\s+(\S+)/s;
Change-Id: Ic27e295d9122045b2ec5a638933924b65ecc8e43
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362861
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/tpm_test/ftdi_spi_tpm.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/tpm_test/ftdi_spi_tpm.c b/test/tpm_test/ftdi_spi_tpm.c index 69b6cf57da..43ca83e3aa 100644 --- a/test/tpm_test/ftdi_spi_tpm.c +++ b/test/tpm_test/ftdi_spi_tpm.c @@ -25,6 +25,7 @@ static int ftdi_trace_enabled; #define TPM_DATA_FIFO_REG (TPM_LOCALITY_0_SPI_BASE + 0x24) #define TPM_DID_VID_REG (TPM_LOCALITY_0_SPI_BASE + 0xf00) #define TPM_RID_REG (TPM_LOCALITY_0_SPI_BASE + 0xf04) +#define TPM_FW_VER (TPM_LOCALITY_0_SPI_BASE + 0xf90) static struct swig_string_data empty_string_data = (struct swig_string_data){ .size = 0, .data = NULL @@ -203,6 +204,35 @@ static uint32_t GetBurstCount(void) return (status >> burstCountShift) & burstCountMask; } +static void GetVersion(void) +{ + int chunk_count = 0; + uint32_t chunk = 0; + char vstr[sizeof(chunk) + 1]; /* room for 4 chars + zero */ + + /* + * Does not really matter what's written, this just makes sure + * the version is reported from the beginning. + */ + FtdiWriteReg(TPM_FW_VER, sizeof(chunk), &chunk); + + /* Print it out in 4 byte chunks. */ + vstr[sizeof(vstr) - 1] = 0; + do { + FtdiReadReg(TPM_FW_VER, sizeof(chunk), vstr); + printf("%s", vstr); + + /* + * While string is not over, and no more than 200 + * characters. + * This is likely result in one extra printk() + * invocation with an empty string, not a big deal. + */ + } while (vstr[0] && (chunk_count++ < (200 / sizeof(chunk)))); + + printf("\n"); +} + int FtdiSpiInit(uint32_t freq, int enable_debug) { uint32_t did_vid, status; @@ -271,6 +301,8 @@ int FtdiSpiInit(uint32_t freq, int enable_debug) printf("Connected to device vid:did:rid of %4.4x:%4.4x:%2.2x\n", did_vid & 0xffff, did_vid >> 16, cmd); + GetVersion(); + return true; } |