NAND: Make page, erase, oob size available via cmd_nand
PATCH 1/2 NAND: Make page, erase, oob size available via cmd_nand
The "nand info" and "nand device" now set shell/environment variables:
nand_writesize ... nand page size
nand_oobsize ..... nand oob area size nand_erasesize ... nand erase block size
The shell variables are only set if HUSH is enabled.
Also, the "nand info" command now displays this info.
Signed-off-by Marek Vasut <[email protected]>
--- common/cmd_nand.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 files changed, 39 insertions(+), 3 deletions(-)
common/cmd_nand.c +39 -3
@@ -27,6 +27,9 @@#include <asm/byteorder.h> #include <jffs2/jffs2.h> #include <nand.h> +#ifdef CONFIG_SYS_HUSH_PARSER +#include <hush.h> +#endif #if defined(CONFIG_CMD_MTDPARTS )
@@ -362,15 +365,48 @@ usage:#endif -static void nand_print_info (int idx) +static void nand_print_and_set_info (int idx) {nand_info_t *nand = &nand_info[idx];struct nand_chip *chip = nand->priv; +const int bufsz =32 ; +char buf[bufsz]; +printf ("Device %d: " , idx);if (chip->numchips >1 )printf ("%dx " , chip->numchips);printf ("%s, sector size %u KiB\n" , nand->name, nand->erasesize >>10 ); +printf (" Page size %8d b\n" , nand->writesize); +printf (" OOB size %8d b\n" , nand->oobsize); +printf (" Erase size %8d b\n" , nand->erasesize); + +/* Set geometry info */ +#ifdef CONFIG_SYS_HUSH_PARSER +memset (buf,0 , bufsz); +sprintf (buf,"nand_writesize=%x" , nand->writesize); +set_local_var (buf,0 ); + +memset (buf,0 , bufsz); +sprintf (buf,"nand_oobsize=%x" , nand->oobsize); +set_local_var (buf,0 ); + +memset (buf,0 , bufsz); +sprintf (buf,"nand_erasesize=%x" , nand->erasesize); +set_local_var (buf,0 ); +#else +memset (buf,0 , bufsz); +sprintf (buf,"%x" , nand->writesize); +setenv ("nand_writesize" , buf); + +memset (buf,0 , bufsz); +sprintf (buf,"%x" , nand->oobsize); +setenv ("nand_oobsize" , buf); + +memset (buf,0 , bufsz); +sprintf (buf,"%x" , nand->erasesize); +setenv ("nand_erasesize" , buf); +#endif }int do_nand (cmd_tbl_t * cmdtp,int flag,int argc,char *const argv[])
@@ -407,7 +443,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])putc ('\n' );for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) {if (nand_info[i].name) -nand_print_info (i); +nand_print_and_set_info (i); }return 0 ; }
@@ -418,7 +454,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])if (dev <0 || dev >=CONFIG_SYS_MAX_NAND_DEVICE )puts ("no devices available\n" );else -nand_print_info (dev); +nand_print_and_set_info (dev);return 0 ; }
Signature · 1 line
1.7.5.4
PATCH 2/2 NAND: Add scrub.quiet command option
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 <[email protected]>
--- common/cmd_nand.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-)
common/cmd_nand.c +13 -1
@@ -502,11 +502,19 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])int clean = argc >2 && !strcmp ("clean" , argv[2 ]);int o = clean ?3 :2 ;int scrub = !strncmp (cmd,"scrub" ,5 ); +int scrub_quiet = !strncmp (cmd,"scrub.quiet" ,11 );int part =0 ;int chip =0 ;int spread =0 ;int args =2 ; +/* +* Quiet scrub is a special option only for the scrub command, +* ignore it in the following construction. +*/ +if (scrub_quiet) + cmd[5 ] =0 ; +if (cmd[5 ] !=0 ) {if (!strcmp (&cmd[5 ],".spread" )) { spread =1 ;
@@ -543,7 +551,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) opts.quiet = quiet; opts.spread = spread; -if (scrub) { +if (scrub && !scrub_quiet) {puts ("Warning: " "scrub option will erase all factory set " "bad blocks!\n"
@@ -569,6 +577,10 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])return -1 ; } } + +if (scrub_quiet) + opts.scrub =1 ; + ret =nand_erase_opts (nand, &opts);printf ("%s\n" , ret ?"ERROR" :"OK" );
Signature · 1 line
1.7.5.4