Commit 6089981663f2abb065ac852b844215a2ceced65f

Authored by Marek Vasut
Committed by Scott Wood
1 parent fb3659ac42

NAND: Add -y option to nand scrub command

This allows the scrub command to scrub without asking the user if he really
wants to scrub the area. Useful in scripts.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Scott Wood <scottwood@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Scott Wood <scottwood@freescale.com>

Showing 1 changed file with 19 additions and 15 deletions Side-by-side Diff

... ... @@ -464,10 +464,21 @@
464 464 nand_erase_options_t opts;
465 465 /* "clean" at index 2 means request to write cleanmarker */
466 466 int clean = argc > 2 && !strcmp("clean", argv[2]);
467   - int o = clean ? 3 : 2;
  467 + int scrub_yes = argc > 2 && !strcmp("-y", argv[2]);
  468 + int o = (clean || scrub_yes) ? 3 : 2;
468 469 int scrub = !strncmp(cmd, "scrub", 5);
469 470 int spread = 0;
470 471 int args = 2;
  472 + const char *scrub_warn =
  473 + "Warning: "
  474 + "scrub option will erase all factory set bad blocks!\n"
  475 + " "
  476 + "There is no reliable way to recover them.\n"
  477 + " "
  478 + "Use this command only for testing purposes if you\n"
  479 + " "
  480 + "are sure of what you are doing!\n"
  481 + "\nReally scrub this NAND flash? <y/N>\n";
471 482  
472 483 if (cmd[5] != 0) {
473 484 if (!strcmp(&cmd[5], ".spread")) {
474 485  
... ... @@ -504,19 +515,12 @@
504 515 opts.spread = spread;
505 516  
506 517 if (scrub) {
507   - puts("Warning: "
508   - "scrub option will erase all factory set "
509   - "bad blocks!\n"
510   - " "
511   - "There is no reliable way to recover them.\n"
512   - " "
513   - "Use this command only for testing purposes "
514   - "if you\n"
515   - " "
516   - "are sure of what you are doing!\n"
517   - "\nReally scrub this NAND flash? <y/N>\n");
  518 + if (!scrub_yes)
  519 + puts(scrub_warn);
518 520  
519   - if (getc() == 'y') {
  521 + if (scrub_yes)
  522 + opts.scrub = 1;
  523 + else if (getc() == 'y') {
520 524 puts("y");
521 525 if (getc() == '\r')
522 526 opts.scrub = 1;
... ... @@ -733,7 +737,7 @@
733 737 "nand erase.chip [clean] - erase entire chip'\n"
734 738 "nand bad - show bad blocks\n"
735 739 "nand dump[.oob] off - dump page\n"
736   - "nand scrub off size | scrub.part partition | scrub.chip\n"
  740 + "nand scrub [-y] off size | scrub.part partition | scrub.chip\n"
737 741 " really clean NAND erasing bad blocks (UNSAFE)\n"
738 742 "nand markbad off [...] - mark bad block(s) at offset (UNSAFE)\n"
739 743 "nand biterr off - make a bit error at offset (UNSAFE)"