From patchwork Thu Sep 22 18:36:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 115997 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 40B72B6F80 for ; Fri, 23 Sep 2011 04:36:27 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 416FB283C3; Thu, 22 Sep 2011 20:36:24 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 iGMkr2eKGHzc; Thu, 22 Sep 2011 20:36:24 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B6EC328380; Thu, 22 Sep 2011 20:36:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 50D3428380 for ; Thu, 22 Sep 2011 20:36:19 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 SDscDLPjeRJA for ; Thu, 22 Sep 2011 20:36:18 +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-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by theia.denx.de (Postfix) with ESMTPS id 48B8C28363 for ; Thu, 22 Sep 2011 20:36:17 +0200 (CEST) Received: by fxd18 with SMTP id 18so2844920fxd.3 for ; Thu, 22 Sep 2011 11:36:16 -0700 (PDT) Received: by 10.223.26.20 with SMTP id b20mr3486140fac.50.1316716576610; Thu, 22 Sep 2011 11:36:16 -0700 (PDT) Received: from mashiro.ms.mff.cuni.cz (eduroam113.ms.mff.cuni.cz. [195.113.21.113]) by mx.google.com with ESMTPS id f10sm8309964fac.14.2011.09.22.11.36.15 (version=SSLv3 cipher=OTHER); Thu, 22 Sep 2011 11:36:16 -0700 (PDT) From: Marek Vasut To: u-boot@lists.denx.de Date: Thu, 22 Sep 2011 20:36:11 +0200 Message-Id: <1316716571-2876-1-git-send-email-marek.vasut@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1316656529-8252-1-git-send-email-marek.vasut@gmail.com> References: <1316656529-8252-1-git-send-email-marek.vasut@gmail.com> Cc: Scott Wood Subject: [U-Boot] [PATCH 2/5 V3] NAND: Add nand read.raw and write.raw commands X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de These commands should work around various "hardware" ECC and BCH methods. Signed-off-by: Marek Vasut Cc: Scott Wood Cc: Stefano Babic Cc: Wolfgang Denk Cc: Detlev Zundel --- common/cmd_nand.c | 21 +++++++++++++++++++-- doc/README.nand | 9 +++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) V2: Add documentation. V3: Drop size param. diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 66e06a5..92b6280 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -606,6 +606,22 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) ret = nand->read_oob(nand, off, &ops); else ret = nand->write_oob(nand, off, &ops); + } else if (!strcmp(s, ".raw")) { + /* Raw access */ + mtd_oob_ops_t ops = { + .datbuf = (u8 *)addr, + .oobbuf = ((u8 *)addr) + nand->writesize, + .len = nand->writesize, + .ooblen = nand->oobsize, + .mode = MTD_OOB_RAW + }; + + rwsize = nand->writesize + nand->oobsize; + + if (read) + ret = nand->read_oob(nand, off, &ops); + else + ret = nand->write_oob(nand, off, &ops); } else { printf("Unknown nand command suffix '%s'.\n", s); return 1; @@ -695,10 +711,11 @@ U_BOOT_CMD( "NAND sub-system", "info - show available NAND devices\n" "nand device [dev] - show or set current device\n" - "nand read - addr off|partition size\n" - "nand write - addr off|partition size\n" + "nand read[.raw] - addr off|partition\n" + "nand write[.raw] - addr off|partition\n" " read/write 'size' bytes starting at offset 'off'\n" " to/from memory address 'addr', skipping bad blocks.\n" + " Use read.raw/write.raw to avoid ECC and write the block as-is.\n" #ifdef CONFIG_CMD_NAND_TRIMFFS "nand write.trimffs - addr off|partition size\n" " write 'size' bytes starting at offset 'off' from memory address\n" diff --git a/doc/README.nand b/doc/README.nand index 751b693..62c077e 100644 --- a/doc/README.nand +++ b/doc/README.nand @@ -94,6 +94,15 @@ Commands: of data for one 512-byte page or 2 256-byte pages. There is no check for bad blocks. + nand read.raw addr ofs|partition + Read block from `ofs' in NAND flash to `addr'. This reads the raw block, + so ECC is avoided and the OOB area is read as well. + + nand write.raw addr ofs|partition + Write block from `addr' to `ofs' in NAND flash. This writes the raw block, + so ECC is avoided and the OOB area is written as well, making the whole + block written as-is. + Configuration Options: CONFIG_CMD_NAND