diff options
author | Stephen Warren <swarren@nvidia.com> | 2012-05-16 14:56:55 -0600 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-05-23 07:56:07 -0700 |
commit | f13abb05cef8608f732e469b478512c771a10bd8 (patch) | |
tree | dcaeb93b6ac0f63b3f7b76b19c6da6495a63f518 | |
parent | 56bbad5511c39c3c3b6cd0852e814c9fcd2313bf (diff) | |
download | nvidia-cbootimage-f13abb05cef8608f732e469b478512c771a10bd8.tar.gz |
Add PreBctPadBlocks config file option
This allows the BCT to be offset within the memory device. This is a port
of commit 883a7d0 "Add suport for MMC boot image preparation" from
git://gitorious.org/cbootimage/cbootimage.git's trimslice branch. The
description there is:
Add suport for MMC boot image preparation
In order to allow the MBR to be placed at offset 0,
BCT is copied to 128K offset.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Change-Id: Icde53082f5a4645fefb70deb408a42f9920aed1f
Reviewed-on: https://gerrit.chromium.org/gerrit/22935
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | cbootimage.h | 7 | ||||
-rw-r--r-- | data_layout.c | 16 | ||||
-rw-r--r-- | parse.c | 1 | ||||
-rw-r--r-- | parse.h | 1 | ||||
-rw-r--r-- | set.c | 8 |
5 files changed, 28 insertions, 5 deletions
diff --git a/cbootimage.h b/cbootimage.h index 783d82c..f901605 100644 --- a/cbootimage.h +++ b/cbootimage.h @@ -68,6 +68,13 @@ typedef struct build_image_context_rec u_int32_t redundancy; u_int32_t version; u_int32_t bct_copy; + /* + * Number of blocks at start of device to skip before the BCT. + * This may be used to reserve space for a partition table, for + * example, in order to write the resultant boot image to e.g. an + * SD card while using the remaining space for a user filesystem. + */ + u_int32_t pre_bct_pad_blocks; /* Allocation data. */ struct blk_data_rec *memory; /* Representation of memory */ /* block number for the BCT block */ diff --git a/data_layout.c b/data_layout.c index d70f3b4..23fa830 100644 --- a/data_layout.c +++ b/data_layout.c @@ -783,13 +783,20 @@ begin_update(build_image_context *context) /* Fill the reserved data w/the padding pattern. */ write_padding(context->bct + reserved_offset, reserved_size); - /* Find the next bct block starting at block 1. */ - for (i = 0; i < context->bct_copy; i++) { + /* Create the pad before the BCT starting at block 1 */ + for (i = 0; i < context->pre_bct_pad_blocks; i++) { find_new_bct_blk(context); err = erase_block(context, i); if (err != 0) goto fail; } + /* Find the next bct block starting at block pre_bct_pad_blocks. */ + for (i = 0; i < context->bct_copy; i++) { + find_new_bct_blk(context); + err = erase_block(context, i + context->pre_bct_pad_blocks); + if (err != 0) + goto fail; + } return 0; fail: printf("Erase block failed, error: %d.\n", err); @@ -797,8 +804,7 @@ fail: } /* - * Write the new BCT to the next available of the journal block. - * Write the new BCT to slot 0 of block 0. + * Write the BCT(s) starting at slot 0 of block context->pre_bct_pad_blocks. * * @param context The main context pointer * @return 0 for success @@ -810,7 +816,7 @@ finish_update(build_image_context *context) int i; for (i = 0; i < context->bct_copy; i++) { - err = write_bct(context, i, 0); + err = write_bct(context, i + context->pre_bct_pad_blocks, 0); if (err != 0) goto fail; } @@ -86,6 +86,7 @@ static parse_item parse_simple_items[] = { "Redundancy=", token_redundancy, parse_value_u32 }, { "Bctcopy=", token_bct_copy, parse_value_u32 }, { "Version=", token_version, parse_value_u32 }, + { "PreBctPadBlocks=", token_pre_bct_pad_blocks, parse_value_u32 }, { NULL, 0, NULL } /* Must be last */ }; @@ -110,6 +110,7 @@ typedef enum token_dev_type_sdmmc, token_dev_type_spi, token_num_sdram_sets, + token_pre_bct_pad_blocks, token_nand_clock_divider, token_nand_nand_timing, @@ -194,6 +194,14 @@ int context_set_value(build_image_context *context, context->odm_data = value; break; + case token_pre_bct_pad_blocks: + if (context->bct_init != NULL) { + printf("Error: Too late to pre-BCT pad.\n"); + return 1; + } + context->pre_bct_pad_blocks = value; + break; + DEFAULT(); } |