From: Heiko Schocher Date: Mon, 17 Jun 2013 07:01:01 +0200 Subject: [U-Boot] =?utf-8?q?=5BPATCH_v2=5D_dfu=2C_nand=3A_before_write_a_b?= =?utf-8?q?uffer_to_nand=2C_erase_the_nand_sectors?= In-Reply-To: <1371205443-27690-1-git-send-email-hs@denx.de> References: <1371205443-27690-1-git-send-email-hs@denx.de> Message-ID: <1371445261-3785-1-git-send-email-hs@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de before writing the received buffer to nand, erase the nand sectors. If not doing this, nand write fails. See for more info here: http://lists.denx.de/pipermail/u-boot/2013-June/156361.html Signed-off-by: Heiko Schocher Cc: Scott Wood Cc: Pantelis Antoniou Cc: Lukasz Majewski Cc: Kyungmin Park Cc: Marek Vasut Cc: Tom Rini --- - changes for v2: - use opts.spread as Scott Wood suggested drivers/dfu/dfu_nand.c | 17 +++++++++++++++-- 1 Datei ge?ndert, 15 Zeilen hinzugef?gt(+), 2 Zeilen entfernt(-) diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c index 7dc89b2..93db9bd 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; + opts.spread = 1; + opts.quiet = 1; + /* first erase */ + ret = nand_erase_opts(nand, &opts); + if (ret) + return ret; + /* then write */ ret = nand_write_skip_bad(nand, start, &count, &actual, lim, buf, 0); + } if (ret != 0) { printf("%s: nand_%s_skip_bad call failed at %llx!\n", -- 1.7.11.7