From patchwork Wed Jun 15 08:42:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 635753 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rV0QC6TWwz9t1P for ; Wed, 15 Jun 2016 18:42:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 06C76A753B; Wed, 15 Jun 2016 10:42:40 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wass9e2zKFHu; Wed, 15 Jun 2016 10:42:39 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3A6A7A74DB; Wed, 15 Jun 2016 10:42:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 53542A74DB for ; Wed, 15 Jun 2016 10:42:36 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mUdZjWx9t5E5 for ; Wed, 15 Jun 2016 10:42:36 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.free-electrons.com (down.free-electrons.com [37.187.137.238]) by theia.denx.de (Postfix) with ESMTP id 2410EA74D0 for ; Wed, 15 Jun 2016 10:42:31 +0200 (CEST) Received: by mail.free-electrons.com (Postfix, from userid 110) id 042111C8; Wed, 15 Jun 2016 10:42:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon.home (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 4315D143; Wed, 15 Jun 2016 10:42:20 +0200 (CEST) From: Boris Brezillon To: Hans de Goede , Scott Wood Date: Wed, 15 Jun 2016 10:42:18 +0200 Message-Id: <1465980138-18496-1-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.7.4 Cc: Tom Rini , u-boot@lists.denx.de, linux-sunxi@googlegroups.com Subject: [U-Boot] [PATCH] cmd, nand: add an option to disable the verification when writing in raw mode X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Modern NANDs do not guarantee that data written in raw mode will not contain bitflips just after writing them. This is fine since the number of bitflips should be rather low and thus fixable by the ECC engine, but since we are reading data in raw mode to verify if they match the input data we cannot prevent failures if some bits are flipped. The option of using standard mode to verify the data is not acceptable either, since one of the usage of raw mode is to allow flashing images that do not respect the standard NAND page layout or the default ECC config (this is the case on Allwinner platforms, where the ROM code tests several hardcoded configs, which are not necessarily matching the NAND characteristics). Add an extension to the nand write.raw command allowing one to disable the verification step. Signed-off-by: Boris Brezillon Reviewed-by: Tom Rini --- cmd/nand.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/nand.c b/cmd/nand.c index 583a18f..3a5e3a0 100644 --- a/cmd/nand.c +++ b/cmd/nand.c @@ -306,7 +306,7 @@ static void nand_print_and_set_info(int idx) } static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off, - ulong count, int read) + ulong count, int read, int noverify) { int ret = 0; @@ -324,7 +324,7 @@ static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off, ret = mtd_read_oob(mtd, off, &ops); } else { ret = mtd_write_oob(mtd, off, &ops); - if (!ret) + if (!ret && !no_verify) ret = nand_verify_page_oob(mtd, &ops, off); } @@ -546,6 +546,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong pagecount = 1; int read; int raw = 0; + int no_verify = 0; if (argc < 4) goto usage; @@ -557,9 +558,12 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) s = strchr(cmd, '.'); - if (s && !strcmp(s, ".raw")) { + if (s && !strncmp(s, ".raw", 4)) { raw = 1; + if (!strcmp(s, ".raw.noverify")) + no_verify = 1; + if (mtd_arg_off(argv[3], &dev, &off, &size, &maxsize, MTD_DEV_TYPE_NAND, nand_info[dev]->size)) @@ -633,7 +637,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) else ret = mtd_write_oob(mtd, off, &ops); } else if (raw) { - ret = raw_access(mtd, addr, off, pagecount, read); + ret = raw_access(mtd, addr, off, pagecount, read, + no_verify); } else { printf("Unknown nand command suffix '%s'.\n", s); return 1; @@ -758,7 +763,7 @@ static char nand_help_text[] = " read/write 'size' bytes starting at offset 'off'\n" " to/from memory address 'addr', skipping bad blocks.\n" "nand read.raw - addr off|partition [count]\n" - "nand write.raw - addr off|partition [count]\n" + "nand write.raw[.noverify] - addr off|partition [count]\n" " Use read.raw/write.raw to avoid ECC and access the flash as-is.\n" #ifdef CONFIG_CMD_NAND_TRIMFFS "nand write.trimffs - addr off|partition size\n"