diff options
author | Peer Chen <pchen@nvidia.com> | 2011-03-03 10:12:58 -0800 |
---|---|---|
committer | Anton Staaf <robotboy@chromium.org> | 2011-03-03 10:12:58 -0800 |
commit | 053d578f2b3de3f9674dab89525fe22e03ee4e8a (patch) | |
tree | 67cdb085a2d87f838d6d15c768c64846972ce341 | |
parent | 8f49024db8c55d8da550ef776bf13a385a700829 (diff) | |
download | nvidia-cbootimage-053d578f2b3de3f9674dab89525fe22e03ee4e8a.tar.gz |
Add the nand device support for cbootimage tool.
Change-Id: Ic24dd4c971c16d00742d90830be168b41483be7a
BUG=None.
TEST=Test with the config file.
Review URL: http://codereview.chromium.org/6611009
Patch from Peer Chen <pchen@nvidia.com>.
-rw-r--r-- | cbootimage.c | 2 | ||||
-rw-r--r-- | cbootimage.h | 4 | ||||
-rw-r--r-- | data_layout.c | 4 | ||||
-rw-r--r-- | data_layout.h | 3 | ||||
-rw-r--r-- | nvbctlib.h | 6 | ||||
-rw-r--r-- | nvbctlib_ap20.c | 13 | ||||
-rw-r--r-- | parse.c | 41 | ||||
-rw-r--r-- | parse.h | 5 | ||||
-rw-r--r-- | set.c | 26 | ||||
-rw-r--r-- | set.h | 6 |
10 files changed, 93 insertions, 17 deletions
diff --git a/cbootimage.c b/cbootimage.c index 1df6238..a4263aa 100644 --- a/cbootimage.c +++ b/cbootimage.c @@ -176,6 +176,8 @@ main(int argc, char *argv[]) /* Generate the new bct file */ if (context.generate_bct != 0) { + /* Update the BCT */ + begin_update(&context); /* Signing the bct. */ e = sign_bct(&context, context.bct); if (e != 0) diff --git a/cbootimage.h b/cbootimage.h index 173e76a..f99c926 100644 --- a/cbootimage.h +++ b/cbootimage.h @@ -35,12 +35,10 @@ #include <errno.h> #define NVBOOT_AES_BLOCK_SIZE_LOG2 4 - -#define KEY_LENGTH (128/8) - #define MAX_BUFFER 200 #define MAX_STR_LEN 20 #define MAX_BOOTLOADER_SIZE (16 * 1024 * 1024) +#define NVBOOT_BOOTDATA_VERSION(a, b) ((((a)&0xffff) << 16) | ((b)&0xffff)) /* * Enumerations diff --git a/data_layout.c b/data_layout.c index 139e537..53e9274 100644 --- a/data_layout.c +++ b/data_layout.c @@ -79,7 +79,6 @@ set_bl_data(build_image_context *context, static int write_bootloaders(build_image_context *context); static void find_new_journal_blk(build_image_context *context); -static int begin_update (build_image_context *context); static int finish_update(build_image_context *context); static u_int32_t iceil_log2(u_int32_t a, u_int32_t b) @@ -871,7 +870,7 @@ find_new_journal_blk(build_image_context *context) * - Write the good BCT to slot 0 of the journal block. * - Erase block 0 */ -static int +int begin_update(build_image_context *context) { u_int32_t pages_per_bct; @@ -896,6 +895,7 @@ begin_update(build_image_context *context) block_size_log2, page_size_log2); } + SET_VALUE(boot_data_version, NVBOOT_BOOTDATA_VERSION(2, 1)); GET_VALUE(bct_size, &bct_size); GET_VALUE(hash_size, &hash_size); GET_VALUE(reserved_size, &reserved_size); diff --git a/data_layout.h b/data_layout.h index 58ed9c0..1513183 100644 --- a/data_layout.h +++ b/data_layout.h @@ -53,4 +53,7 @@ update_addon_item(struct build_image_context_rec *context); int write_block_raw(struct build_image_context_rec *context); +int +begin_update(build_image_context *context); + #endif /* #ifndef INCLUDED_DATA_LAYOUT_H */ @@ -62,9 +62,15 @@ typedef enum { nvbct_lib_id_crypto_length, nvbct_lib_id_max_bct_search_blks, nvbct_lib_id_num_param_sets, + nvbct_lib_id_dev_type_nand, nvbct_lib_id_dev_type_sdmmc, nvbct_lib_id_dev_type_spi, + nvbct_lib_id_nand_clock_divider, + nvbct_lib_id_nand_nand_timing, + nvbct_lib_id_nand_nand_timing2, + nvbct_lib_id_nand_block_size_log2, + nvbct_lib_id_nand_page_size_log2, nvbct_lib_id_sdmmc_clock_divider, nvbct_lib_id_sdmmc_data_width, nvbct_lib_id_sdmmc_max_power_class_supported, diff --git a/nvbctlib_ap20.c b/nvbctlib_ap20.c index 2f803b5..b1a9024 100644 --- a/nvbctlib_ap20.c +++ b/nvbctlib_ap20.c @@ -94,6 +94,12 @@ getdev_param(u_int32_t set, return -ENODATA; switch (id) { + CASE_GET_DEV_PARAM(nand, clock_divider); + CASE_GET_DEV_PARAM(nand, nand_timing); + CASE_GET_DEV_PARAM(nand, nand_timing2); + CASE_GET_DEV_PARAM(nand, block_size_log2); + CASE_GET_DEV_PARAM(nand, page_size_log2); + CASE_GET_DEV_PARAM(sdmmc, clock_divider); CASE_GET_DEV_PARAM(sdmmc, data_width); CASE_GET_DEV_PARAM(sdmmc, max_power_class_supported); @@ -125,6 +131,12 @@ setdev_param(u_int32_t set, return -ENODATA; switch (id) { + CASE_SET_DEV_PARAM(nand, clock_divider); + CASE_SET_DEV_PARAM(nand, nand_timing); + CASE_SET_DEV_PARAM(nand, nand_timing2); + CASE_SET_DEV_PARAM(nand, block_size_log2); + CASE_SET_DEV_PARAM(nand, page_size_log2); + CASE_SET_DEV_PARAM(sdmmc, clock_divider); CASE_SET_DEV_PARAM(sdmmc, data_width); CASE_SET_DEV_PARAM(sdmmc, max_power_class_supported); @@ -272,6 +284,7 @@ bct_get_value(nvbct_lib_id id, u_int32_t *data, u_int8_t *bct) CASE_GET_CONST(max_bct_search_blks, NVBOOT_MAX_BCT_SEARCH_BLOCKS); + CASE_GET_CONST_PREFIX(dev_type_nand, nvboot); CASE_GET_CONST_PREFIX(dev_type_sdmmc, nvboot); CASE_GET_CONST_PREFIX(dev_type_spi, nvboot); CASE_GET_CONST_PREFIX(sdmmc_data_width_4bit, nvboot); @@ -87,8 +87,10 @@ static enum_item s_devtype_table[] = { { "NvBootDevType_Sdmmc", nvbct_lib_id_dev_type_sdmmc }, { "NvBootDevType_Spi", nvbct_lib_id_dev_type_spi }, + { "NvBootDevType_Nand", nvbct_lib_id_dev_type_nand }, { "Sdmmc", nvbct_lib_id_dev_type_sdmmc }, { "Spi", nvbct_lib_id_dev_type_spi }, + { "Nand", nvbct_lib_id_dev_type_nand }, { NULL, 0 } }; @@ -141,6 +143,19 @@ static enum_item s_spi_clock_source_table[] = { NULL, 0 } }; +static field_item s_nand_table[] = +{ + { "ClockDivider", token_clock_divider, field_type_u32, NULL }, + /* Note: NandTiming2 must appear before NandTiming, because NandTiming + * is a prefix of NandTiming2 and would otherwise match first. + */ + { "NandTiming2", token_nand_timing2, field_type_u32, NULL }, + { "NandTiming", token_nand_timing, field_type_u32, NULL }, + { "BlockSizeLog2", token_block_size_log2, field_type_u32, NULL }, + { "PageSizeLog2", token_page_size_log2, field_type_u32, NULL }, + { NULL, 0, 0, NULL } +}; + static field_item s_sdmmc_table[] = { { "ClockDivider", token_clock_divider, field_type_u32, NULL }, @@ -165,6 +180,8 @@ static field_item s_spiflash_table[] = static parse_subfield_item s_device_type_table[] = { + { "NandParams.", token_nand_params, + s_nand_table, set_nand_param }, { "SdmmcParams.", token_sdmmc_params, s_sdmmc_table, set_sdmmc_param }, { "SpiFlashParams.", token_spiflash_params, @@ -175,18 +192,18 @@ static parse_subfield_item s_device_type_table[] = static parse_item s_top_level_items[] = { - { "Bctfile=", token_bct_file, parse_bct_file }, - { "Attribute=", token_attribute, parse_value_u32 }, - { "Attribute[", token_attribute, parse_array }, - { "PageSize=", token_page_size, parse_value_u32 }, - { "BlockSize=", token_block_size, parse_value_u32 }, - { "PartitionSize=", token_partition_size, parse_value_u32 }, - { "DevType[", token_dev_type, parse_array }, - { "DeviceParam[", token_dev_param, parse_dev_param }, - { "BootLoader=", token_bootloader, parse_bootloader }, - { "Redundancy=", token_redundancy, parse_value_u32 }, - { "Version=", token_version, parse_value_u32 }, - { "AddOn[", token_addon, parse_addon }, + { "Bctfile=", token_bct_file, parse_bct_file }, + { "Attribute=", token_attribute, parse_value_u32 }, + { "Attribute[", token_attribute, parse_array }, + { "PageSize=", token_page_size, parse_value_u32 }, + { "BlockSize=", token_block_size, parse_value_u32 }, + { "PartitionSize=", token_partition_size, parse_value_u32 }, + { "DevType[", token_dev_type, parse_array }, + { "DeviceParam[", token_dev_param, parse_dev_param }, + { "BootLoader=", token_bootloader, parse_bootloader }, + { "Redundancy=", token_redundancy, parse_value_u32 }, + { "Version=", token_version, parse_value_u32 }, + { "AddOn[", token_addon, parse_addon }, { NULL, 0, NULL } /* Must be last */ }; @@ -53,6 +53,7 @@ typedef enum token_version, token_bct_file, token_addon, + token_nand_params, token_sdmmc_params, token_spiflash_params, token_data_width, @@ -60,6 +61,10 @@ typedef enum token_clock_source, token_read_command_type_fast, token_max_power_class_supported, + token_nand_timing2, + token_nand_timing, + token_block_size_log2, + token_page_size_log2, token_force32 = 0x7fffffff } parse_token; @@ -372,6 +372,32 @@ update_num_param_sets(build_image_context *context, u_int32_t index) } /* + * set_nand_param(): Processes commands to set Nand parameters. + */ +int +set_nand_param(build_image_context *context, + u_int32_t index, + parse_token token, + u_int32_t value) +{ + assert(context != NULL); + assert(context->bct != NULL); + + update_num_param_sets(context, index); + + switch (token) { + CASE_DEVICE_VALUE(nand, clock_divider); + CASE_DEVICE_VALUE(nand, nand_timing); + CASE_DEVICE_VALUE(nand, nand_timing2); + CASE_DEVICE_VALUE(nand, block_size_log2); + CASE_DEVICE_VALUE(nand, page_size_log2); + DEFAULT(); + } + + return 0; +} + +/* * set_sdmmc_param(): Processes commands to set MoviNand parameters. */ int @@ -71,6 +71,12 @@ set_other_field(build_image_context *context, int index); int +set_nand_param(build_image_context *context, + u_int32_t index, + parse_token token, + u_int32_t value); + +int set_sdmmc_param(build_image_context *context, u_int32_t index, parse_token token, |