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>
This commit is contained in:
parent
fb3659ac42
commit
6089981663
@ -464,10 +464,21 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
|||||||
nand_erase_options_t opts;
|
nand_erase_options_t opts;
|
||||||
/* "clean" at index 2 means request to write cleanmarker */
|
/* "clean" at index 2 means request to write cleanmarker */
|
||||||
int clean = argc > 2 && !strcmp("clean", argv[2]);
|
int clean = argc > 2 && !strcmp("clean", argv[2]);
|
||||||
int o = clean ? 3 : 2;
|
int scrub_yes = argc > 2 && !strcmp("-y", argv[2]);
|
||||||
|
int o = (clean || scrub_yes) ? 3 : 2;
|
||||||
int scrub = !strncmp(cmd, "scrub", 5);
|
int scrub = !strncmp(cmd, "scrub", 5);
|
||||||
int spread = 0;
|
int spread = 0;
|
||||||
int args = 2;
|
int args = 2;
|
||||||
|
const char *scrub_warn =
|
||||||
|
"Warning: "
|
||||||
|
"scrub option will erase all factory set bad blocks!\n"
|
||||||
|
" "
|
||||||
|
"There is no reliable way to recover them.\n"
|
||||||
|
" "
|
||||||
|
"Use this command only for testing purposes if you\n"
|
||||||
|
" "
|
||||||
|
"are sure of what you are doing!\n"
|
||||||
|
"\nReally scrub this NAND flash? <y/N>\n";
|
||||||
|
|
||||||
if (cmd[5] != 0) {
|
if (cmd[5] != 0) {
|
||||||
if (!strcmp(&cmd[5], ".spread")) {
|
if (!strcmp(&cmd[5], ".spread")) {
|
||||||
@ -504,19 +515,12 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
|||||||
opts.spread = spread;
|
opts.spread = spread;
|
||||||
|
|
||||||
if (scrub) {
|
if (scrub) {
|
||||||
puts("Warning: "
|
if (!scrub_yes)
|
||||||
"scrub option will erase all factory set "
|
puts(scrub_warn);
|
||||||
"bad blocks!\n"
|
|
||||||
" "
|
|
||||||
"There is no reliable way to recover them.\n"
|
|
||||||
" "
|
|
||||||
"Use this command only for testing purposes "
|
|
||||||
"if you\n"
|
|
||||||
" "
|
|
||||||
"are sure of what you are doing!\n"
|
|
||||||
"\nReally scrub this NAND flash? <y/N>\n");
|
|
||||||
|
|
||||||
if (getc() == 'y') {
|
if (scrub_yes)
|
||||||
|
opts.scrub = 1;
|
||||||
|
else if (getc() == 'y') {
|
||||||
puts("y");
|
puts("y");
|
||||||
if (getc() == '\r')
|
if (getc() == '\r')
|
||||||
opts.scrub = 1;
|
opts.scrub = 1;
|
||||||
@ -733,7 +737,7 @@ U_BOOT_CMD(
|
|||||||
"nand erase.chip [clean] - erase entire chip'\n"
|
"nand erase.chip [clean] - erase entire chip'\n"
|
||||||
"nand bad - show bad blocks\n"
|
"nand bad - show bad blocks\n"
|
||||||
"nand dump[.oob] off - dump page\n"
|
"nand dump[.oob] off - dump page\n"
|
||||||
"nand scrub off size | scrub.part partition | scrub.chip\n"
|
"nand scrub [-y] off size | scrub.part partition | scrub.chip\n"
|
||||||
" really clean NAND erasing bad blocks (UNSAFE)\n"
|
" really clean NAND erasing bad blocks (UNSAFE)\n"
|
||||||
"nand markbad off [...] - mark bad block(s) at offset (UNSAFE)\n"
|
"nand markbad off [...] - mark bad block(s) at offset (UNSAFE)\n"
|
||||||
"nand biterr off - make a bit error at offset (UNSAFE)"
|
"nand biterr off - make a bit error at offset (UNSAFE)"
|
||||||
|
Loading…
Reference in New Issue
Block a user