public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] nand: Add torture feature
Date: Mon, 5 Nov 2012 18:03:11 -0600	[thread overview]
Message-ID: <1352160191.28279.12@snotra> (raw)
In-Reply-To: <1330941635.587470.1352146590666.JavaMail.root@advansee.com> (from benoit.thebaudeau@advansee.com on Mon Nov  5 14:16:30 2012)

On 11/05/2012 02:16:30 PM, Beno?t Th?baudeau wrote:
> This patch adds a NAND Flash torture feature, which is useful as a  
> block stress
> test to determine if a block is still good and reliable (or should be  
> marked as
> bad), e.g. after a write error.
> 
> This code is ported from mtd-utils' lib/libmtd.c.
> 
> Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau@advansee.com>
> Cc: Scott Wood <scottwood@freescale.com>
> ---
>  .../common/cmd_nand.c                              |   18 ++++
>  .../doc/README.nand                                |    3 +
>  .../drivers/mtd/nand/nand_util.c                   |  107  
> ++++++++++++++++++++
>  .../include/nand.h                                 |    1 +
>  4 files changed, 129 insertions(+)

Please define and document a CONFIG symbol to selectively enable this  
feature.

> diff --git u-boot-nand-flash-9c60e75.orig/common/cmd_nand.c  
> u-boot-nand-flash-9c60e75/common/cmd_nand.c
> index 9c6dabe..fe5c28c 100644
> --- u-boot-nand-flash-9c60e75.orig/common/cmd_nand.c
> +++ u-boot-nand-flash-9c60e75/common/cmd_nand.c
> @@ -701,6 +701,23 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int  
> argc, char * const argv[])
>  		return ret == 0 ? 0 : 1;
>  	}
> 
> +	if (strcmp(cmd, "torture") == 0) {
> +		if (argc < 3)
> +			goto usage;
> +
> +		if (!str2off(argv[2], &off)) {
> +			puts("Offset is not a valid number\n");
> +			return 1;
> +		}
> +
> +		printf("\nNAND torture: device %d offset 0x%llx size  
> 0x%x\n",
> +			dev, off, nand->erasesize);
> +		ret = nand_torture(nand, off);
> +		printf(" %s\n", ret ? "Failed" : "Passed");
> +
> +		return ret == 0 ? 0 : 1;
> +	}
> +
>  	if (strcmp(cmd, "markbad") == 0) {
>  		argc -= 2;
>  		argv += 2;
> @@ -812,6 +829,7 @@ U_BOOT_CMD(
>  	"nand erase.chip [clean] - erase entire chip'\n"
>  	"nand bad - show bad blocks\n"
>  	"nand dump[.oob] off - dump page\n"
> +	"nand torture off - torture block at offset\n"
>  	"nand scrub [-y] off size | scrub.part partition | scrub.chip\n"
>  	"    really clean NAND erasing bad blocks (UNSAFE)\n"
>  	"nand markbad off [...] - mark bad block(s) at offset  
> (UNSAFE)\n"
> diff --git u-boot-nand-flash-9c60e75.orig/doc/README.nand  
> u-boot-nand-flash-9c60e75/doc/README.nand
> index c130189..8a17d11 100644
> --- u-boot-nand-flash-9c60e75.orig/doc/README.nand
> +++ u-boot-nand-flash-9c60e75/doc/README.nand
> @@ -213,6 +213,9 @@ Miscellaneous and testing commands:
>    DANGEROUS!!! Factory set bad blocks will be lost. Use only
>    to remove artificial bad blocks created with the "markbad" command.
> 
> +  "torture offset"
> +  torture block to determine if it is still reliable

Please elaborate -- for example, what is the return code in the case
where it is reliable versus when it is not?  Does the block  
automatically
get marked bad if it is unreliable?  How many erase cycles does this put
the block through?

What's the intended use of this?  Manual inquiries by a curious user, or
something automated?

> +		/* Make sure the block contains only 0xff bytes */
> +		res = nand->read(nand, offset, nand->erasesize,  
> &retlen, buf);
> +		if ((res && res != -EUCLEAN) || retlen !=  
> nand->erasesize)
> +			goto out;
> +
> +		res = check_pattern(buf, 0xff, nand->erasesize);
> +		if (!res) {
> +			printf("Erased block at 0x%llx, but a non-0xff  
> byte "
> +					"was found\n", offset);
> +			ret = -EIO;
> +			goto out;
> +		}
> +
> +		/* Write a pattern and check it */
> +		memset(buf, patterns[i], nand->erasesize);
> +		ret = nand->write(nand, offset, nand->erasesize,  
> &retlen, buf);
> +		if (ret || retlen != nand->erasesize)
> +			goto out;
> +
> +		res = nand->read(nand, offset, nand->erasesize,  
> &retlen, buf);
> +		if ((res && res != -EUCLEAN) || retlen !=  
> nand->erasesize)
> +			goto out;

Shouldn't you print an error message if the read, write, or erase fails?

-Scott

  reply	other threads:[~2012-11-06  0:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05 20:15 [U-Boot] [PATCH 1/3] nand: Clean up nand_util Benoît Thébaudeau
2012-11-05 20:16 ` [U-Boot] [PATCH 2/3] nand: Fix nand_erase_opts() offset check Benoît Thébaudeau
2012-11-16  0:23   ` [U-Boot] [U-Boot,2/3] " Scott Wood
2012-11-19 20:40     ` Benoît Thébaudeau
2012-11-19 20:51       ` Scott Wood
2012-11-05 20:16 ` [U-Boot] [PATCH 3/3] nand: Add torture feature Benoît Thébaudeau
2012-11-06  0:03   ` Scott Wood [this message]
2012-11-16 19:20   ` [U-Boot] [PATCH v2] " Benoît Thébaudeau
2012-11-16 23:54     ` Scott Wood
2012-11-16  0:22 ` [U-Boot] [U-Boot,1/3] nand: Clean up nand_util Scott Wood
2012-11-16  0:29   ` Scott Wood
2012-11-16  7:20     ` Andreas Bießmann
2012-11-19 20:54       ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1352160191.28279.12@snotra \
    --to=scottwood@freescale.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox