summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeer Chen <pchen@nvidia.com>2012-04-16 16:51:27 +0800
committerGerrit <chrome-bot@google.com>2012-04-19 14:42:05 -0700
commitde7ab55eb1e5da2580ef07ee77073bc872c383d7 (patch)
treea07d9340bf24790323f0f88fbe834b7542869a80
parent6f2cbc73840678445a3986c520d81f5ea44e85f5 (diff)
downloadnvidia-cbootimage-de7ab55eb1e5da2580ef07ee77073bc872c383d7.tar.gz
CHROMIUM: cbootimage: Specify the ODM_DATA
Add the ODM_DATA argument, u-boot remove the hardcode ODM_DATA, need to use the ODM_DATA from BCT. BUG=None TEST=Done Change-Id: I215ed99f42d02b82450130129badef2b36e6d370 Signed-off-by: Peer Chen <pchen@nvidia.com> Reviewed-on: https://gerrit.chromium.org/gerrit/20306 Reviewed-by: Tom Warren <twarren@nvidia.com> Reviewed-by: Jimmy Zhang <jimmzhang@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--cbootimage.c36
-rw-r--r--cbootimage.h1
-rw-r--r--data_layout.c6
-rw-r--r--parse.h1
-rw-r--r--t20/nvbctlib_t20.c2
-rw-r--r--t20/nvboot_bct_t20.h11
-rw-r--r--t30/nvbctlib_t30.c2
-rw-r--r--t30/nvboot_bct_t30.h10
8 files changed, 41 insertions, 28 deletions
diff --git a/cbootimage.c b/cbootimage.c
index 0356ecf..363caa4 100644
--- a/cbootimage.c
+++ b/cbootimage.c
@@ -50,6 +50,7 @@ struct option cbootcmd[] = {
{"debug", 0, NULL, 'd'},
{"generate", 1, NULL, 'g'},
{"tegra", 1, NULL, 't'},
+ {"odmdata", 1, NULL, 'o'},
{0, 0, 0, 0},
};
@@ -69,6 +70,7 @@ usage(void)
printf(" -h, --help, -? Display this message.\n");
printf(" -d, --debug Output debugging information.\n");
printf(" -gbct Generate the new bct file.\n");
+ printf(" -o<ODM_DATA> Specify the odm_data(in hex).\n");
printf(" [-t20|-t25|-t30] Select one of the possible\n");
printf(" target devices, -t20 if unspecified\n");
printf(" configfile File with configuration information\n");
@@ -78,7 +80,6 @@ usage(void)
static int
process_command_line(int argc, char *argv[], build_image_context *context)
{
- int arg = 1;
int c;
context->generate_bct = 0;
@@ -92,7 +93,7 @@ process_command_line(int argc, char *argv[], build_image_context *context)
t20_get_cbootimage_interf(g_bct_parse_interf);
context->boot_data_version = NVBOOT_BOOTDATA_VERSION(2, 1);
- while ((c = getopt_long(argc, argv, "hdg:t:", cbootcmd, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "hdg:t:o:", cbootcmd, NULL)) != -1) {
switch (c) {
case 'h':
help_only = 1;
@@ -100,12 +101,10 @@ process_command_line(int argc, char *argv[], build_image_context *context)
return 0;
case 'd':
enable_debug = 1;
- arg++;
break;
case 'g':
if (!strcasecmp("bct", optarg)) {
context->generate_bct = 1;
- arg++;
} else {
printf("Invalid argument!\n");
usage();
@@ -119,51 +118,36 @@ process_command_line(int argc, char *argv[], build_image_context *context)
t20_get_cbootimage_interf(g_bct_parse_interf);
context->boot_data_version =
NVBOOT_BOOTDATA_VERSION(2, 1);
- arg++;
} else if (!(strcasecmp("30", optarg))) {
t30_get_cbootimage_interf(g_bct_parse_interf);
context->boot_data_version =
NVBOOT_BOOTDATA_VERSION(3, 1);
- arg++;
} else {
printf("Unsupported chipname!\n");
usage();
return -EINVAL;
}
break;
+ case 'o':
+ context->odm_data = strtoul(optarg, NULL, 16);
+ break;
}
}
- /* Handle file specification errors. */
- switch (argc - arg) {
- case 0:
- printf("Missing configuration and image file names.\n");
- usage();
- return -EINVAL;
-
- case 1:
- printf("Missing configuration or image file name.\n");
- usage();
- return -EINVAL;
- case 2:
- /* Correct args, so break from the switch statement. */
- break;
-
- default:
- printf("Too many arguments.\n");
+ if (argc - optind != 2) {
+ printf("Missing configuration and/or image file name.\n");
usage();
return -EINVAL;
}
-
/* Open the configuration file. */
- context->config_file = fopen(argv[arg], "r");
+ context->config_file = fopen(argv[optind], "r");
if (context->config_file == NULL) {
printf("Error opening config file.\n");
return -ENODATA;
}
/* Record the output filename */
- context->image_filename = argv[arg + 1];
+ context->image_filename = argv[optind + 1];
return 0;
}
diff --git a/cbootimage.h b/cbootimage.h
index 5f9166e..783d82c 100644
--- a/cbootimage.h
+++ b/cbootimage.h
@@ -85,6 +85,7 @@ typedef struct build_image_context_rec
u_int32_t bct_size; /* The BCT file size */
u_int32_t boot_data_version; /* The boot data version of BCT */
u_int8_t bct_init; /* The flag for the memory allocation of bct */
+ u_int32_t odm_data; /* The odm data value */
} build_image_context;
/* Function prototypes */
diff --git a/data_layout.c b/data_layout.c
index d5c5732..be54169 100644
--- a/data_layout.c
+++ b/data_layout.c
@@ -628,6 +628,9 @@ update_context(struct build_image_context_rec *context)
g_bct_parse_interf->get_value(token_block_size_log2,
&context->block_size_log2,
context->bct);
+ g_bct_parse_interf->get_value(token_odm_data,
+ &context->odm_data,
+ context->bct);
context->page_size = 1 << context->page_size_log2;
context->block_size = 1 << context->block_size_log2;
@@ -768,6 +771,9 @@ begin_update(build_image_context *context)
&reserved_size, context->bct);
g_bct_parse_interf->get_value(token_reserved_offset,
&reserved_offset, context->bct);
+ /* Set the odm data */
+ g_bct_parse_interf->set_value(token_odm_data,
+ context->odm_data, context->bct);
pages_per_bct = iceil_log2(context->bct_size, context->page_size_log2);
pages_per_blk = (1 << (context->block_size_log2
diff --git a/parse.h b/parse.h
index 859ffc0..fd87427 100644
--- a/parse.h
+++ b/parse.h
@@ -51,6 +51,7 @@ typedef enum
token_dev_param,
token_redundancy,
token_version,
+ token_odm_data,
token_bct_file,
token_bct_copy,
token_bct_size,
diff --git a/t20/nvbctlib_t20.c b/t20/nvbctlib_t20.c
index ec2fd3d..cd09399 100644
--- a/t20/nvbctlib_t20.c
+++ b/t20/nvbctlib_t20.c
@@ -516,6 +516,7 @@ t20_bct_get_value(parse_token id, u_int32_t *data, u_int8_t *bct)
CASE_GET_NVU32(num_param_sets);
CASE_GET_NVU32(num_sdram_sets);
CASE_GET_NVU32(bootloader_used);
+ CASE_GET_NVU32(odm_data);
/*
* Constants.
@@ -589,6 +590,7 @@ t20_bct_set_value(parse_token id, u_int32_t data, u_int8_t *bct)
CASE_SET_NVU32(num_param_sets);
CASE_SET_NVU32(num_sdram_sets);
CASE_SET_NVU32(bootloader_used);
+ CASE_SET_NVU32(odm_data);
default:
return -ENODATA;
diff --git a/t20/nvboot_bct_t20.h b/t20/nvboot_bct_t20.h
index 5102629..61a877c 100644
--- a/t20/nvboot_bct_t20.h
+++ b/t20/nvboot_bct_t20.h
@@ -29,7 +29,7 @@
/**
* Defines the number of 32-bit words in the customer_data area of the BCT.
*/
-#define NVBOOT_BCT_CUSTOMER_DATA_WORDS 298
+#define NVBOOT_BCT_CUSTOMER_DATA_WORDS 296
/**
* Defines the number of bytes in the customer_data area of the BCT.
@@ -304,6 +304,15 @@ typedef struct nvboot_config_table_rec {
u_int32_t bootloader_used;
nv_bootloader_info bootloader[NVBOOT_MAX_BOOTLOADERS];
u_int8_t customer_data[NVBOOT_BCT_CUSTOMER_DATA_SIZE];
+
+ /*
+ * ODMDATA is stored in the BCT in IRAM by the BootROM.
+ * Read the data @ bct_start + (bct_size - 12). This works
+ * on T20 and T30 BCTs, which are locked down. If this changes
+ * in new chips, we can revisit this algorithm.
+ */
+ u_int32_t odm_data;
+ u_int32_t reserved1;
u_int8_t enable_fail_back;
u_int8_t reserved[NVBOOT_BCT_RESERVED_SIZE];
} nvboot_config_table;
diff --git a/t30/nvbctlib_t30.c b/t30/nvbctlib_t30.c
index da05ede..b19cfd9 100644
--- a/t30/nvbctlib_t30.c
+++ b/t30/nvbctlib_t30.c
@@ -723,6 +723,7 @@ t30_bct_get_value(parse_token id, u_int32_t *data, u_int8_t *bct)
CASE_GET_NVU32(num_param_sets);
CASE_GET_NVU32(num_sdram_sets);
CASE_GET_NVU32(bootloader_used);
+ CASE_GET_NVU32(odm_data);
/*
* Constants.
@@ -796,6 +797,7 @@ t30_bct_set_value(parse_token id, u_int32_t data, u_int8_t *bct)
CASE_SET_NVU32(num_param_sets);
CASE_SET_NVU32(num_sdram_sets);
CASE_SET_NVU32(bootloader_used);
+ CASE_SET_NVU32(odm_data);
default:
return -ENODATA;
diff --git a/t30/nvboot_bct_t30.h b/t30/nvboot_bct_t30.h
index e2cf1c0..32a9fdd 100644
--- a/t30/nvboot_bct_t30.h
+++ b/t30/nvboot_bct_t30.h
@@ -29,7 +29,7 @@
/**
* Defines the number of 32-bit words in the customer_data area of the BCT.
*/
-#define NVBOOT_BCT_CUSTOMER_DATA_WORDS 506
+#define NVBOOT_BCT_CUSTOMER_DATA_WORDS 504
/**
* Defines the number of bytes in the customer_data area of the BCT.
@@ -368,6 +368,14 @@ typedef struct nvboot_config_table_rec {
u_int32_t bootloader_used;
nv_bootloader_info bootloader[NVBOOT_MAX_BOOTLOADERS];
u_int8_t customer_data[NVBOOT_BCT_CUSTOMER_DATA_SIZE];
+ /*
+ * ODMDATA is stored in the BCT in IRAM by the BootROM.
+ * Read the data @ bct_start + (bct_size - 12). This works
+ * on T20 and T30 BCTs, which are locked down. If this changes
+ * in new chips, we can revisit this algorithm.
+ */
+ u_int32_t odm_data;
+ u_int32_t reserved1;
u_int8_t enable_fail_back;
u_int8_t reserved[NVBOOT_BCT_RESERVED_SIZE];
} nvboot_config_table;