diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-11-16 15:22:09 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-11-29 12:11:03 -0800 |
commit | e9022668702c87c7403a0548a9236cc68b763df7 (patch) | |
tree | 3a3253c34a84eae37a9a1dbc652e73ca4fb87d20 /util/cbi-util.c | |
parent | a44c0c1e92b60a992c6b3add46016557d0343ed7 (diff) | |
download | chrome-ec-e9022668702c87c7403a0548a9236cc68b763df7.tar.gz |
CBI: Add MODEL_ID field
MODEL_ID is an optional field containing a numeric value identifying
models. Model IDs are unique within each OEM and <OEM_ID, MODEL_ID>
should form a unique ID within the family.
$ cbi-util create --file ~/cbi_image --board_version 0 --oem_id 6
--sku_id 255 --dram_part_num "012345679abcdef" --model_id 127 --size 256
$ hexdump -C /tmp/cbi.bin
0000 43 42 49 fa 00 00 26 00 00 01 00 01 01 06 02 01 |CBI...&.........|
0010 ff 05 01 7f 03 10 30 31 32 33 34 35 36 37 39 61 |......012345679a|
0020 62 63 64 65 66 00 ff ff ff ff ff ff ff ff ff ff |bcdef...........|
$ cbi-util show --file /tmp/cbi.bin
CBI image: /tmp/cbi.bin
TOTAL_SIZE: 38
Data Field: name: value (hex, tag, size)
BOARD_VERSION: 0 (0x0, 0, 1)
OEM_ID: 6 (0x6, 1, 1)
SKU_ID: 255 (0xff, 2, 1)
MODEL_ID: 127 (0x7f, 5, 1)
DRAM_PART_NUM: 012345679abcdef (3, 16)
Data validated successfully
localhost # ectool cbi set 5 127 1
localhost # ectool cbi get 5
As integer: 127 (0x7f)
As binary: 7f
> cbi
[1289.860454 CBI Reading board info]
CBI_VERSION: 0x0000
TOTAL_SIZE: 22
BOARD_VERSION: 513 (0x201)
OEM_ID: 3 (0x3)
MODEL_ID: 127 (0x7f)
SKU_ID: 14951 (0x3a67)
43 42 49 b0 00 00 16 00 00 02 01 02 01 01 03 02
02 67 3a 05 01 7f ff ff ff ff ff ff ff ff ff ff
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=b:119522898,b:120105950
BRANCH=none
TEST=See above.
Change-Id: Ifd6f3087f5422bcf4c36d3d981b262653d0c89dc
Reviewed-on: https://chromium-review.googlesource.com/1341099
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'util/cbi-util.c')
-rw-r--r-- | util/cbi-util.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/util/cbi-util.c b/util/cbi-util.c index cc4fda8ba5..2ea86b14cf 100644 --- a/util/cbi-util.c +++ b/util/cbi-util.c @@ -37,6 +37,7 @@ enum { OPT_SKU_ID, OPT_DRAM_PART_NUM, OPT_OEM_NAME, + OPT_MODEL_ID, OPT_SIZE, OPT_ERASE_BYTE, OPT_SHOW_ALL, @@ -50,6 +51,7 @@ static const struct option opts_create[] = { {"sku_id", 1, 0, OPT_SKU_ID}, {"dram_part_num", 1, 0, OPT_DRAM_PART_NUM}, {"oem_name", 1, 0, OPT_OEM_NAME}, + {"model_id", 1, 0, OPT_MODEL_ID}, {"size", 1, 0, OPT_SIZE}, {"erase_byte", 1, 0, OPT_ERASE_BYTE}, {NULL, 0, 0, 0} @@ -67,7 +69,8 @@ static const char *field_name[] = { "OEM_ID", "SKU_ID", "DRAM_PART_NUM", - "OEM_NAME" + "OEM_NAME", + "MODEL_ID", }; BUILD_ASSERT(ARRAY_SIZE(field_name) == CBI_TAG_COUNT); @@ -75,11 +78,11 @@ const char help_create[] = "\n" "'%s create [ARGS]' creates an EEPROM image file.\n" "Required ARGS are:\n" - " --file <file> Path to output file\n" - " --board_version <value> Board version\n" - " --oem_id <value> OEM ID\n" - " --sku_id <value> SKU ID\n" - " --size <size> Size of output file in bytes\n" + " --file <file> Path to output file\n" + " --board_version <value> Board version\n" + " --oem_id <value> OEM ID\n" + " --sku_id <value> SKU ID\n" + " --size <size> Size of output file in bytes\n" "<value> must be a positive integer <= 0XFFFFFFFF and field size can\n" "be optionally specified by <value:size> notation: e.g. 0xabcd:4.\n" "<size> must be a positive integer <= 0XFFFF.\n" @@ -88,6 +91,7 @@ const char help_create[] = " --oem_name <string> OEM NAME\n" " --erase_byte <uint8> Byte used for empty space. Default:0xff\n" " --format_version <uint16> Data format version\n" + " --model_id <value> Model ID\n" "<string> is a string\n" "\n"; @@ -240,6 +244,7 @@ static int cmd_create(int argc, char **argv) struct integer_field ver; struct integer_field oem; struct integer_field sku; + struct integer_field model; const char *dram_part_num; const char *oem_name; } bi; @@ -305,6 +310,10 @@ static int cmd_create(int argc, char **argv) case OPT_OEM_NAME: bi.oem_name = optarg; break; + case OPT_MODEL_ID: + if (parse_integer_field(optarg, &bi.model)) + return -1; + break; } } @@ -330,6 +339,7 @@ static int cmd_create(int argc, char **argv) p = cbi_set_data(p, CBI_TAG_BOARD_VERSION, &bi.ver.val, bi.ver.size); p = cbi_set_data(p, CBI_TAG_OEM_ID, &bi.oem.val, bi.oem.size); p = cbi_set_data(p, CBI_TAG_SKU_ID, &bi.sku.val, bi.sku.size); + p = cbi_set_data(p, CBI_TAG_MODEL_ID, &bi.model.val, bi.model.size); if (bi.dram_part_num != NULL) { p = cbi_set_data(p, CBI_TAG_DRAM_PART_NUM, bi.dram_part_num, strlen(bi.dram_part_num) + 1); @@ -458,6 +468,7 @@ static int cmd_show(int argc, char **argv) print_integer(buf, CBI_TAG_BOARD_VERSION); print_integer(buf, CBI_TAG_OEM_ID); print_integer(buf, CBI_TAG_SKU_ID); + print_integer(buf, CBI_TAG_MODEL_ID); print_string(buf, CBI_TAG_DRAM_PART_NUM); print_string(buf, CBI_TAG_OEM_NAME); |