From patchwork Tue Jan 17 11:54:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Crowe X-Patchwork-Id: 716136 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v2pV21vvVz9sD5 for ; Tue, 17 Jan 2017 22:56:26 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cTSMA-00007k-Kc; Tue, 17 Jan 2017 11:55:18 +0000 Received: from relay101a.appriver.com ([207.97.230.14] helo=relay.appriver.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cTSLu-0006zk-Hp for linux-mtd@lists.infradead.org; Tue, 17 Jan 2017 11:55:09 +0000 X-Note-AR-ScanTimeLocal: 01/17/2017 6:52:14 AM X-Policy: brightsign.biz - brightsign.biz X-Policy: brightsign.biz - brightsign.biz X-Policy: brightsign.biz - brightsign.biz X-Policy: brightsign.biz - brightsign.biz X-Primary: mcrowe@brightsign.biz X-Note: This Email was scanned by AppRiver SecureTide X-Note: SecureTide Build: 12/13/2016 5:18:17 PM UTC (2.6.9.19) X-Virus-Scan: V- X-Note-SnifferID: 0 X-Note: TCH-CT/SI:0-31/SG:1 1/17/2017 6:51:49 AM X-GBUdb-Analysis: 0, 213.210.30.29, Ugly c=0.521048 p=-1 Source White X-Signature-Violations: 0-0-0-6062-c X-Note: Spam Tests Failed: X-Country-Path: ->PRIVATE->United Kingdom->United States X-Note-Sending-IP: 213.210.30.29 X-Note-Reverse-DNS: elite.brightsigndigital.co.uk X-Note-Return-Path: mcrowe@brightsign.biz X-Note: User Rule Hits: X-Note: Global Rule Hits: G273 G274 G275 G276 G280 G281 G408 X-Note: Encrypt Rule Hits: X-Note: Mail Class: VALID X-Note: Headers Injected Received: from [213.210.30.29] (HELO elite.brightsign6) by relay.appriver.com (CommuniGate Pro SMTP 6.1.7) with ESMTPS id 105019599; Tue, 17 Jan 2017 06:52:14 -0500 Received: from chuckie.brightsign ([172.30.1.25] helo=chuckie) by elite.brightsign6 with esmtp (Exim 4.84_2) (envelope-from ) id 1cTSLW-0009qU-Kd; Tue, 17 Jan 2017 11:54:38 +0000 Received: from mac by chuckie with local (Exim 4.84_2) (envelope-from ) id 1cTSLW-0004cx-Jp; Tue, 17 Jan 2017 11:54:38 +0000 From: Mike Crowe To: linux-mtd@lists.infradead.org Subject: [PATCH 2/2] nanddump: Add --skip-bad-blocks-to-start option Date: Tue, 17 Jan 2017 11:54:04 +0000 Message-Id: <1484654044-17722-3-git-send-email-mac@mcrowe.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1484654044-17722-1-git-send-email-mac@mcrowe.com> References: <1484654044-17722-1-git-send-email-mac@mcrowe.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170117_035502_816971_DBF51BF7 X-CRM114-Status: GOOD ( 11.42 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [207.97.230.14 listed in list.dnswl.org] 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: richard@nod.at, Mike Crowe , David Oberhollenzer MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The --skip-bad-blocks-to-start option will increase the start address by the size of each bad block encountered between the start of the partition and the specified start address. This can be useful if other readers of the partition will be reading using a simple bad-block-skipping algorithm. Signed-off-by: Mike Crowe --- nand-utils/nanddump.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nand-utils/nanddump.c b/nand-utils/nanddump.c index a8ad334..bebb48e 100644 --- a/nand-utils/nanddump.c +++ b/nand-utils/nanddump.c @@ -52,6 +52,8 @@ static void display_help(int status) "-p --prettyprint Print nice (hexdump)\n" "-q --quiet Don't display progress and status messages\n" "-s addr --startaddress=addr Start address\n" +" --skip-bad-blocks-to-start\n" +" Skip bad blocks when seeking to the start address\n" "\n" "--bb=METHOD, where METHOD can be `padbad', `dumpbad', or `skipbad':\n" " padbad: dump flash data, substituting 0xFF for any bad blocks\n" @@ -86,6 +88,7 @@ static const char *dumpfile; // dump file name static bool quiet = false; // suppress diagnostic output static bool canonical = false; // print nice + ascii static bool forcebinary = false; // force printing binary to tty +static bool skip_bad_blocks_to_start = false; static enum { padbad, // dump flash data, substituting 0xFF for any bad blocks @@ -105,6 +108,7 @@ static void process_options(int argc, char * const argv[]) {"version", no_argument, 0, 'V'}, {"bb", required_argument, 0, 0}, {"omitoob", no_argument, 0, 0}, + {"skip-bad-blocks-to-start", no_argument, 0, 0 }, {"help", no_argument, 0, 'h'}, {"forcebinary", no_argument, 0, 'a'}, {"canonicalprint", no_argument, 0, 'c'}, @@ -146,6 +150,9 @@ static void process_options(int argc, char * const argv[]) errmsg_die("--oob and --oomitoob are mutually exclusive"); } break; + case 3: /* --skip-bad-blocks-to-start */ + skip_bad_blocks_to_start = true; + break; } break; case 'V': @@ -397,6 +404,22 @@ int main(int argc, char * const argv[]) mtd.min_io_size); goto closeall; } + if (skip_bad_blocks_to_start) { + long long bbs_offset = 0; + while (bbs_offset < start_addr) { + err = mtd_is_bad(&mtd, fd, bbs_offset / mtd.eb_size); + if (err < 0) { + sys_errmsg("%s: MTD get bad block failed", mtddev); + goto closeall; + } else if (err == 1) { + if (!quiet) + fprintf(stderr, "Bad block at %llx\n", bbs_offset); + start_addr += mtd.eb_size; + } + bbs_offset += mtd.eb_size; + } + } + if (length) end_addr = start_addr + length; if (!length || end_addr > mtd.size)