diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-02-21 17:08:48 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-02-22 20:17:20 -0800 |
commit | 8a5a83aef357b23a274f45a4377c32b77624a5fc (patch) | |
tree | db4035703b8aa67014c0b2c07a9ea371c6ef13c6 | |
parent | 58759f5fbb21edaafab8fe212980a8cae692e686 (diff) | |
download | chrome-ec-8a5a83aef357b23a274f45a4377c32b77624a5fc.tar.gz |
CBI: Make cbi command dump EEPROM contentsfirmware-kbl-10431.B
Currently, cbi console command dumps the buffered contents. This
patch will make the command dump the entire EEPROM.
BUG=b:70294260
BRANCH=none
TEST=Run cbi command on Fizz:
CBI_VERSION: 0x0000
TOTAL_SIZE: 18
BOARD_VERSION: 514 (0x202)
OEM_ID: 2 (0x2)
SKU_ID: 0 (0x0)
43 42 49 5c 00 00 12 00 00 02 02 02 02 01 00 01
01 02 ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
...
Change-Id: I39f3335a38eb72c95d53264ddc7386dd0910e946
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/930322
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | common/cbi.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/common/cbi.c b/common/cbi.c index 1eb50d2661..935861c2a6 100644 --- a/common/cbi.c +++ b/common/cbi.c @@ -31,19 +31,21 @@ static uint8_t cbi_crc8(const struct cbi_header *h) h->total_size - sizeof(h->magic) - sizeof(h->crc)); } +static int read_eeprom(uint8_t offset, uint8_t *in, int in_size) +{ + return i2c_xfer(I2C_PORT_EEPROM, I2C_ADDR_EEPROM, + &offset, 1, in, in_size, I2C_XFER_SINGLE); +} + /* * Get board information from EEPROM */ static int do_read_board_info(void) { - uint8_t offset; - CPRINTS("Reading board info"); /* Read header */ - offset = 0; - if (i2c_xfer(I2C_PORT_EEPROM, I2C_ADDR_EEPROM, - &offset, 1, cbi, sizeof(*head), I2C_XFER_SINGLE)) { + if (read_eeprom(0, cbi, sizeof(*head))) { CPRINTS("Failed to read header"); return EC_ERROR_INVAL; } @@ -69,10 +71,8 @@ static int do_read_board_info(void) } /* Read the data */ - offset = sizeof(*head); - if (i2c_xfer(I2C_PORT_EEPROM, I2C_ADDR_EEPROM, &offset, 1, - head->data, head->total_size - sizeof(*head), - I2C_XFER_SINGLE)) { + if (read_eeprom(sizeof(*head), head->data, + head->total_size - sizeof(*head))) { CPRINTS("Failed to read body"); return EC_ERROR_INVAL; } @@ -289,16 +289,21 @@ DECLARE_HOST_COMMAND(EC_CMD_SET_CROS_BOARD_INFO, static void dump_cbi(void) { + uint8_t buf[16]; int i; - for (i = 0; i < head->total_size; i++) { - ccprintf(" %02x", cbi[i]); - if (i % 16 == 15) - ccprintf("\n"); + for (i = 0; i < CBI_EEPROM_SIZE; i += sizeof(buf)) { + int j; + if (read_eeprom(i, buf, sizeof(buf))) { + ccprintf("\nFailed to read EEPROM\n"); + return; + } + for (j = 0; j < sizeof(buf); j++) + ccprintf(" %02x", buf[j]); + ccprintf("\n"); } - ccprintf("\n"); } -static int command_dump_cbi(int argc, char **argv) +static int cc_cbi(int argc, char **argv) { uint32_t val; @@ -325,4 +330,4 @@ static int command_dump_cbi(int argc, char **argv) dump_cbi(); return EC_SUCCESS; } -DECLARE_CONSOLE_COMMAND(cbi, command_dump_cbi, NULL, NULL); +DECLARE_CONSOLE_COMMAND(cbi, cc_cbi, NULL, NULL); |