diff options
author | Peer Chen <pchen@nvidia.com> | 2011-07-27 02:59:41 -0400 |
---|---|---|
committer | Doug Anderson <dianders@chromium.org> | 2011-09-16 11:58:56 -0700 |
commit | 56f4048a7b55e60e037c06aae38c080b00c89014 (patch) | |
tree | aed113bb1311d50c7993cf8b0e41bb36431e072f | |
parent | 20379c18a25191d9197bb96fd719c99336100055 (diff) | |
download | nvidia-cbootimage-56f4048a7b55e60e037c06aae38c080b00c89014.tar.gz |
CHROMIUM: cbootimage: Add Bctcopy parameter
Add the Bctcopy parameter for the bct number in final boot image
file to save the NAND space.
In .cfg file, add "Bctcopy = n(n >= 1)" to specify the bct count.
BUG=chromium-os:17464
TEST=cfg-file
Change-Id: I873a000f9165017db9dec25fb7b18cf082e535ba
Reviewed-on: http://gerrit.chromium.org/gerrit/5207
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Tested-by: Doug Anderson <dianders@chromium.org>
-rw-r--r-- | cbootimage.h | 5 | ||||
-rw-r--r-- | context.c | 3 | ||||
-rw-r--r-- | data_layout.c | 50 | ||||
-rw-r--r-- | parse.c | 1 | ||||
-rw-r--r-- | parse.h | 1 | ||||
-rw-r--r-- | set.c | 4 |
6 files changed, 37 insertions, 27 deletions
diff --git a/cbootimage.h b/cbootimage.h index 1dfa75b..0077d66 100644 --- a/cbootimage.h +++ b/cbootimage.h @@ -103,10 +103,11 @@ typedef struct build_image_context_rec u_int32_t partition_size; u_int32_t redundancy; u_int32_t version; + u_int32_t bct_copy; /* Allocation data. */ struct blk_data_rec *memory; /* Representation of memory */ - /* block number for the (first) journal block */ - u_int32_t journal_blk; + /* block number for the BCT block */ + u_int32_t next_bct_blk; char *newbl_filename; u_int32_t newbl_load_addr; @@ -60,7 +60,7 @@ init_context(build_image_context *context) /* Set defaults */ context->memory = new_block_list(); - context->journal_blk = 1; /* Default to 1st block */ + context->next_bct_blk = 0; /* Default to block 0 */ /* Allocate space for the bct. * Note that this is different from the old code which pointed directly @@ -73,6 +73,7 @@ init_context(build_image_context *context) context_set_value(context, token_page_size, 2048); context_set_value(context, token_redundancy, 1); context_set_value(context, token_version, 1); + context_set_value(context, token_bct_copy, 2); return 0; diff --git a/data_layout.c b/data_layout.c index a0b2e11..13c5056 100644 --- a/data_layout.c +++ b/data_layout.c @@ -78,7 +78,7 @@ 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 u_int32_t find_new_bct_blk(build_image_context *context); static int finish_update(build_image_context *context); static void init_bad_block_table(build_image_context *context); @@ -489,7 +489,7 @@ write_bootloaders(build_image_context *context) pages_in_bl = iceil_log2(bl_length, context->page_size_log2); - current_blk = context->journal_blk+1; + current_blk = context->next_bct_blk; current_page = 0; for (bl_instance = 0; bl_instance < context->redundancy; bl_instance++) { @@ -847,24 +847,24 @@ void destroy_addon_list(struct addon_item_rec *addon_list) } } -static void -find_new_journal_blk(build_image_context *context) +static u_int32_t +find_new_bct_blk(build_image_context *context) { u_int32_t current_blk; u_int32_t max_bct_search_blks; assert(context); - current_blk = context->journal_blk; + current_blk = context->next_bct_blk; GET_VALUE(max_bct_search_blks, &max_bct_search_blks); - if (current_blk > max_bct_search_blks) { + if (current_blk >= max_bct_search_blks) { printf("Error: Unable to locate a journal block.\n"); exit(1); } - - context->journal_blk = current_blk; + context->next_bct_blk++; + return current_blk; } /* @@ -916,7 +916,9 @@ begin_update(build_image_context *context) u_int32_t hash_size; u_int32_t reserved_size; u_int32_t reserved_offset; + u_int32_t current_bct_blk; int e = 0; + int i; assert(context); @@ -946,16 +948,13 @@ begin_update(build_image_context *context) /* Fill the reserved data w/the padding pattern. */ write_padding(context->bct + reserved_offset, reserved_size); - /* Device is new */ - /* Find the new journal block starting at block 1. */ - find_new_journal_blk(context); - - e = erase_block(context, context->journal_blk); - if (e != 0) - goto fail; - e = erase_block(context, 0); - if (e != 0) - goto fail; + /* Find the next bct block starting at block 0. */ + for (i = 0; i < context->bct_copy; i++) { + current_bct_blk = find_new_bct_blk(context); + e = erase_block(context, current_bct_blk); + if (e != 0) + goto fail; + } return 0; fail: printf("Erase block failed, error: %d.\n", e); @@ -972,14 +971,17 @@ fail: static int finish_update(build_image_context *context) { + u_int32_t current_bct_blk; int e = 0; + int i; + + current_bct_blk = context->next_bct_blk; + for (i = 0; i < context->bct_copy; i++) { + e = write_bct(context, --current_bct_blk, 0); + if (e != 0) + goto fail; + } - e = write_bct(context, context->journal_blk, 0); - if (e != 0) - goto fail; - e = write_bct(context, 0, 0); - if (e != 0) /* Write to block 0, slot 0. */ - goto fail; return 0; fail: printf("Write BCT failed, error: %d.\n", e); @@ -347,6 +347,7 @@ static parse_item s_top_level_items[] = { "SDRAM[", token_sdram, parse_sdram_param }, { "BootLoader=", token_bootloader, parse_bootloader }, { "Redundancy=", token_redundancy, parse_value_u32 }, + { "Bctcopy=", token_bct_copy, parse_value_u32 }, { "Version=", token_version, parse_value_u32 }, { "AddOn[", token_addon, parse_addon }, { NULL, 0, NULL } /* Must be last */ @@ -52,6 +52,7 @@ typedef enum token_redundancy, token_version, token_bct_file, + token_bct_copy, token_addon, token_nand_params, token_sdmmc_params, @@ -239,6 +239,10 @@ int context_set_value(build_image_context *context, context->version = value; break; + case token_bct_copy: + context->bct_copy = value; + break; + DEFAULT(); } |