summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWisley Chen <wisley.chen@quanta.corp-partner.google.com>2018-11-06 11:59:50 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-11-13 03:32:51 -0800
commit2e5d1744a9b4bef51f5d5333a7bd5b77b68f1925 (patch)
tree318a0308207da6ed65e12e0841c5731d47ba6622
parent12eacd182f5fba9cc744037c04c8e6317752b9fa (diff)
downloadchrome-ec-2e5d1744a9b4bef51f5d5333a7bd5b77b68f1925.tar.gz
Add OEM name support to CBI
Allow to set/get the OEM name in CBI. $ cbi-util create --file ./cbi_image.bin --board_version 1 --oem_id 6 --sku_id 255 --dram_part_num "0123456789abcdef" --oem_name "ABC" --size 256 CBI image is created successfully $hexdump -C cbi_image.bin 00000000 43 42 49 ed 00 00 2a 00 00 01 01 01 01 06 02 01 |CBI...*.........| 00000010 ff 03 11 30 31 32 33 34 35 36 37 38 39 61 62 63 |...0123456789abc| 00000020 64 65 66 00 04 04 41 42 43 00 ff ff ff ff ff ff |def...ABC.......| 00000030 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 00000100 $ ./build/meep/util/cbi-util show --file ./cbi_image.bin CBI image: ./cbi_image.bin TOTAL_SIZE: 42 Data Field: name: value (hex, tag, size) BOARD_VERSION: 1 (0x1, 0, 1) OEM_ID: 6 (0x6, 1, 1) SKU_ID: 255 (0xff, 2, 1) DRAM_PART_NUM: 0123456789abcdef (3, 17) OEM_NAME: ABC (4, 4) Data validated successfully localhost /usr/local # ./ectool cbi set 0 1 1 2 localhost /usr/local # ./ectool cbi set 1 6 1 1 localhost /usr/local # ./ectool cbi set 2 255 1 1 localhost /usr/local # ./ectool cbi set 3 K4F6E304HB-MGCJ 0 0 localhost /usr/local # ./ectool cbi set 4 ABC 0 0 localhost /usr/local # ./ectool cbi get 0 As integer: 1 (0x1) As binary: 01 localhost /usr/local # ./ectool cbi get 1 As integer: 6 (0x6) As binary: 06 localhost /usr/local # ./ectool cbi get 2 As integer: 255 (0xff) As binary: ff localhost /usr/local # ./ectool cbi get 3 K4F6E304HB-MGCJ localhost /usr/local # ./ectool cbi get 4 ABC BRANCH=none BUG=b:118798180 TEST=executed command as above. Signed-off-by: Wisley Chen <wisley.chen@quantatw.com> Change-Id: Ie933900ffd6c1317136c88a72ab8d5afc3976cc0 Reviewed-on: https://chromium-review.googlesource.com/1319394 Commit-Ready: Chen Wisley <wisley.chen@quantatw.com> Tested-by: Chen Wisley <wisley.chen@quantatw.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--include/ec_commands.h1
-rw-r--r--util/cbi-util.c18
-rw-r--r--util/ectool.c7
3 files changed, 21 insertions, 5 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 7e37a2ad94..cb0bc9f62f 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -4778,6 +4778,7 @@ enum cbi_data_tag {
CBI_TAG_OEM_ID = 1, /* uint8_t */
CBI_TAG_SKU_ID = 2, /* uint8_t */
CBI_TAG_DRAM_PART_NUM = 3, /* variable length ascii, nul terminated. */
+ CBI_TAG_OEM_NAME = 4, /* variable length ascii, nul terminated. */
CBI_TAG_COUNT,
};
diff --git a/util/cbi-util.c b/util/cbi-util.c
index f62db3d819..aa8e5dd325 100644
--- a/util/cbi-util.c
+++ b/util/cbi-util.c
@@ -36,6 +36,7 @@ enum {
OPT_OEM_ID,
OPT_SKU_ID,
OPT_DRAM_PART_NUM,
+ OPT_OEM_NAME,
OPT_SIZE,
OPT_ERASE_BYTE,
OPT_SHOW_ALL,
@@ -48,6 +49,7 @@ static const struct option opts_create[] = {
{"oem_id", 1, 0, OPT_OEM_ID},
{"sku_id", 1, 0, OPT_SKU_ID},
{"dram_part_num", 1, 0, OPT_DRAM_PART_NUM},
+ {"oem_name", 1, 0, OPT_OEM_NAME},
{"size", 1, 0, OPT_SIZE},
{"erase_byte", 1, 0, OPT_ERASE_BYTE},
{NULL, 0, 0, 0}
@@ -64,7 +66,8 @@ static const char *field_name[] = {
"BOARD_VERSION",
"OEM_ID",
"SKU_ID",
- "DRAM_PART_NUM"
+ "DRAM_PART_NUM",
+ "OEM_NAME"
};
BUILD_ASSERT(ARRAY_SIZE(field_name) == CBI_TAG_COUNT);
@@ -79,10 +82,11 @@ const char help_create[] =
" --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"
- "<value> can be a string for DRAM PART NUM.\n"
+ "<value> can be a string for DRAM PART NUM/OEM NAME.\n"
"<size> must be a positive integer <= 0XFFFF.\n"
"Optional ARGS are:\n"
" --dram_part_num <value> DRAM PART NUM\n"
+ " --oem_name <value> OEM NAME\n"
" --erase_byte <uint8> Byte used for empty space. Default:0xff\n"
" --format_version <uint16> Data format version\n"
"\n";
@@ -237,6 +241,7 @@ static int cmd_create(int argc, char **argv)
struct integer_field oem;
struct integer_field sku;
const char *dram_part_num;
+ const char *oem_name;
} bi;
struct cbi_header *h;
int rv;
@@ -297,6 +302,9 @@ static int cmd_create(int argc, char **argv)
case OPT_DRAM_PART_NUM:
bi.dram_part_num = optarg;
break;
+ case OPT_OEM_NAME:
+ bi.oem_name = optarg;
+ break;
}
}
@@ -326,6 +334,11 @@ static int cmd_create(int argc, char **argv)
p = cbi_set_data(p, CBI_TAG_DRAM_PART_NUM, bi.dram_part_num,
strlen(bi.dram_part_num) + 1);
}
+ if (bi.oem_name != NULL) {
+ p = cbi_set_data(p, CBI_TAG_OEM_NAME, bi.oem_name,
+ strlen(bi.oem_name) + 1);
+ }
+
h->total_size = p - cbi;
h->crc = cbi_crc8(h);
@@ -446,6 +459,7 @@ static int cmd_show(int argc, char **argv)
print_integer(buf, CBI_TAG_OEM_ID);
print_integer(buf, CBI_TAG_SKU_ID);
print_string(buf, CBI_TAG_DRAM_PART_NUM);
+ print_string(buf, CBI_TAG_OEM_NAME);
free(buf);
diff --git a/util/ectool.c b/util/ectool.c
index b78331f638..ece78749c6 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -6749,8 +6749,9 @@ static void cmd_cbi_help(char *cmd)
" 1: OEM_ID\n"
" 2: SKU_ID\n"
" 3: DRAM_PART_NUM\n"
+ " 4: OEM_NAME\n"
" <size> is the size of the data in byte\n"
- " <value> is integer to be set, string for DRAM_PART_NUM\n"
+ " <value> is integer to be set, string for DRAM_PART_NUM/OEM_NAME\n"
" [get_flag] is combination of:\n"
" 01b: Invalidate cache and reload data from EEPROM\n"
" [set_flag] is combination of:\n"
@@ -6805,7 +6806,7 @@ static int cmd_cbi(int argc, char *argv[])
return -1;
}
r = ec_inbuf;
- if (tag != CBI_TAG_DRAM_PART_NUM) {
+ if (tag != CBI_TAG_DRAM_PART_NUM && tag != CBI_TAG_OEM_NAME) {
if (rv <= sizeof(uint32_t))
printf("As integer: %u (0x%x)\n", r[0], r[0]);
printf("As binary:");
@@ -6833,7 +6834,7 @@ static int cmd_cbi(int argc, char *argv[])
memset(p, 0, ec_max_outsize);
p->tag = tag;
- if (tag != CBI_TAG_DRAM_PART_NUM) {
+ if (tag != CBI_TAG_DRAM_PART_NUM && tag != CBI_TAG_OEM_NAME) {
val = strtol(argv[3], &e, 0);
if (e && *e) {
fprintf(stderr, "Bad value\n");