From a67cc37e698107ebe7fc89a9046105f31802972e Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Mon, 24 Jun 2013 18:50:40 +0200 Subject: dfu, nand: before write a buffer to nand, erase the nand sectors 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 Using the nand erase option "spread", maybe overwrite blocks on, for example another mtd partition, if the erasing range contains bad blocks. So a limit option is added to nand_erase_opts() Signed-off-by: Heiko Schocher Cc: Scott Wood Cc: Pantelis Antoniou Cc: Lukasz Majewski Cc: Kyungmin Park Cc: Marek Vasut Cc: Tom Rini Signed-off-by: Scott Wood --- drivers/mtd/nand/nand_util.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/mtd/nand/nand_util.c') diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index d81972ca2..1d22b5240 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -120,6 +120,10 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts) WATCHDOG_RESET(); + if (opts->lim && (erase.addr >= (opts->offset + opts->lim))) { + puts("Size of erase exceeds limit\n"); + return -EFBIG; + } if (!opts->scrub && bbtest) { int ret = mtd_block_isbad(meminfo, erase.addr); if (ret > 0) { -- cgit v1.2.3-70-g09d2