[U-Boot] [PATCH] dfu, nand: before write a buffer to nand, erase the nand sectors
Scott Wood
scottwood at freescale.com
Sat Jun 15 00:19:45 CEST 2013
On 06/14/2013 05:24:03 AM, Heiko Schocher wrote:
> diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c
> index 7dc89b2..6f9a934 100644
> --- a/drivers/dfu/dfu_nand.c
> +++ b/drivers/dfu/dfu_nand.c
> @@ -63,12 +63,25 @@ static int nand_block_op(enum dfu_nand_op op,
> struct dfu_entity *dfu,
>
> nand = &nand_info[nand_curr_device];
>
> - if (op == DFU_OP_READ)
> + if (op == DFU_OP_READ) {
> ret = nand_read_skip_bad(nand, start, &count, &actual,
> lim, buf);
> - else
> + } else {
> + nand_erase_options_t opts;
> +
> + memset(&opts, 0, sizeof(opts));
> + opts.offset = start;
> + opts.length = count;
> + adjust_size_for_badblocks(&opts.length, offset,
> + nand_curr_device);
> + /* first erase */
> + ret = nand_erase_opts(nand, &opts);
> + if (ret)
> + return ret;
You could use opts.spread instead of calling
adjust_size_for_badblocks(). If you do want to use
adjust_size_for_badblocks() -- say, to do bounds checking on the result
-- please move it to nand_util.c, and pass in a pointer to nand_info_t
instead of "int dev".
-Scott
More information about the U-Boot
mailing list