improve nandtest command
cover improve nandtest command
Small Summary:
- The old nandtest do a ecc statistic per eraseblock, it's better to do this per page. I don't know how this works with subpages.
- Add a progressbar instead of prints of current flash offset.
- Rename command argument 'passes' to 'iterations', which makes more sense.
- use builtin function 'get_random_bytes' to generate random buffer.
- use loff_t instead of off_t. To handle flash >4GB.
- add another constraints check for writesize.
Alexander Aring (8):
nandtest: stat ecc per page not per eraseblock
nandtest: add progressbar instead of offset print
nandtest: rename command argument p to i
nandtest: change flash length variable type
nandtest: use get_random_bytes instead of for loop
nandtest: clean up code
nandtest: use loff_t instead off_t
nandtest: add another constraints check
commands/nandtest.c | 190 ++++++++++++++++++++++++++++------------------------ 1 file changed, 103 insertions(+), 87 deletions(-)
Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/8 nandtest: stat ecc per page not per eraseblock
Collect ecc statistics per page not per eraseblock.
--- commands/nandtest.c | 70 +++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 31 deletions(-)
commands/nandtest.c +39 -31
@@ -96,7 +96,8 @@ static ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)static int erase_and_write (off_t ofs,unsigned char *data,unsigned char *rbuf) {struct erase_info_user er; -int i, ret; +unsigned int i; +int ret;printf ("\r0x%08x: erasing... " , (unsigned )(ofs + memregion.offset));
@@ -111,43 +112,50 @@ static int erase_and_write(off_t ofs, unsigned char *data, unsigned char *rbuf)return ret; } -printf ("\r0x%08x: writing..." , (unsigned )(ofs + memregion.offset)); +for (i =0 ; i < meminfo.erasesize; + i += meminfo.writesize) { +printf ("\r0x%08x: writing..." , (unsigned ) + (ofs + i + memregion.offset)); -/* Write data to given offset */ -pwrite (fd, data, meminfo.erasesize, ofs); +/* Write data to given offset */ +pwrite (fd, data + i, meminfo.writesize, ofs + i); -printf ("\r0x%08x: reading..." , (unsigned )(ofs + memregion.offset)); +printf ("\r0x%08x: reading..." , (unsigned ) + (ofs + i + memregion.offset)); -/* Read data from offset */ -pread (fd, rbuf, meminfo.erasesize, ofs); +/* Read data from offset */ +pread (fd, rbuf + i, meminfo.writesize, ofs + i); - ret =ioctl (fd,ECCGETSTATS , &newstats); -if (ret <0 ) { -perror ("ECCGETSTATS" ); -return ret; - } + ret =ioctl (fd,ECCGETSTATS , &newstats); +if (ret <0 ) { +perror ("ECCGETSTATS" ); +return ret; + } -if (newstats.corrected > oldstats.corrected) { -printf ("\n %d bit(s) ECC corrected at 0x%08x\n" , - newstats.corrected - oldstats.corrected, - (unsigned )(ofs + memregion.offset)); -if ((newstats.corrected-oldstats.corrected) >=MAX_ECC_BITS ) { -/* Increment ECC stats that are over MAX_ECC_BITS */ - ecc_stats_over++; - }else { -/* Increment ECC stat value */ - ecc_stats[(newstats.corrected-oldstats.corrected)-1 ]++; +if (newstats.corrected > oldstats.corrected) { +printf ("\n %d bit(s) ECC corrected at page 0x%08x\n" , + newstats.corrected - oldstats.corrected, + (unsigned )(ofs + memregion.offset + i)); +if ((newstats.corrected-oldstats.corrected) >= +MAX_ECC_BITS ) { +/* Increment ECC stats that +* are over MAX_ECC_BITS */ + ecc_stats_over++; + }else { +/* Increment ECC stat value */ + ecc_stats[(newstats.corrected- + oldstats.corrected)-1 ]++; + } +/* Set oldstats to newstats */ + oldstats.corrected = newstats.corrected; + } +if (newstats.failed > oldstats.failed) { +printf ("\nECC failed at page 0x%08x\n" , + (unsigned )(ofs + memregion.offset + i)); + oldstats.failed = newstats.failed; + ecc_failed_cnt++; } -/* Set oldstats to newstats */ - oldstats.corrected = newstats.corrected; - } -if (newstats.failed > oldstats.failed) { -printf ("\nECC failed at 0x%08x\n" , - (unsigned )(ofs + memregion.offset)); - oldstats.failed = newstats.failed; - ecc_failed_cnt++; } -printf ("\r0x%08x: checking..." , (unsigned )(ofs + memregion.offset));/* Compared written data with read data.
Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/8 nandtest: add progressbar instead of offset print
In reply to Alexander AringAdd progressbar and remove other outputs of current flash offset.
--- commands/nandtest.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-)
commands/nandtest.c +25 -17
@@ -21,6 +21,7 @@#include <linux/mtd/mtd-abi.h> #include <fcntl.h> #include <stdlib.h> +#include <progress.h> /* Max ECC Bits that can be corrected */ #define MAX_ECC_BITS 8
@@ -64,7 +65,8 @@ static ssize_t pread(int fd, void *buf, size_t count, off_t offset)/* * Implementation of pwrite with lseek and write. */ -static ssize_t pwrite (int fd,const void *buf,size_t count,off_t offset) +static ssize_t pwrite (int fd,const void *buf, +size_t count,off_t offset,off_t length) {int ret;
@@ -77,9 +79,11 @@ static ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)if (ret <0 ) {perror ("write" );if (markbad) { -printf ("Mark block bad at 0x%08x\n" , +printf ("\nMark block bad at 0x%08x\n" , (unsigned )(offset + memregion.offset));ioctl (fd,MEMSETBADBLOCK , &offset); +init_progression_bar (length); +show_progress (offset); } }
@@ -92,21 +96,21 @@ static ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)* Param ofs: offset on flash_device. * Param data: data to write on flash. * Param rbuf: pointer to allocated buffer to copy readed data. +* Param length: length of testing area */ -static int erase_and_write (off_t ofs,unsigned char *data,unsigned char *rbuf) +static int erase_and_write (off_t ofs,unsigned char *data, +unsigned char *rbuf,off_t length) {struct erase_info_user er;unsigned int i;int ret; -printf ("\r0x%08x: erasing... " , (unsigned )(ofs + memregion.offset)); - er.start = ofs; er.length = meminfo.erasesize; ret =erase (fd, er.length, er.start);if (ret <0 ) { -perror ("erase" ); +perror ("\nerase" );printf ("Could't not erase flash at 0x%08x length 0x%08x.\n" , er.start, er.length);return ret;
@@ -114,21 +118,16 @@ static int erase_and_write(off_t ofs, unsigned char *data, unsigned char *rbuf)for (i =0 ; i < meminfo.erasesize; i += meminfo.writesize) { -printf ("\r0x%08x: writing..." , (unsigned ) - (ofs + i + memregion.offset)); -/* Write data to given offset */ -pwrite (fd, data + i, meminfo.writesize, ofs + i); - -printf ("\r0x%08x: reading..." , (unsigned ) - (ofs + i + memregion.offset)); +pwrite (fd, data + i, meminfo.writesize, + ofs + i, length);/* Read data from offset */ pread (fd, rbuf + i, meminfo.writesize, ofs + i); ret =ioctl (fd,ECCGETSTATS , &newstats);if (ret <0 ) { -perror ("ECCGETSTATS" ); +perror ("\nECCGETSTATS" );return ret; }
@@ -136,6 +135,8 @@ static int erase_and_write(off_t ofs, unsigned char *data, unsigned char *rbuf)printf ("\n %d bit(s) ECC corrected at page 0x%08x\n" , newstats.corrected - oldstats.corrected, (unsigned )(ofs + memregion.offset + i)); +init_progression_bar (length); +show_progress (ofs);if ((newstats.corrected-oldstats.corrected) >=MAX_ECC_BITS ) {/* Increment ECC stats that
@@ -152,11 +153,12 @@ static int erase_and_write(off_t ofs, unsigned char *data, unsigned char *rbuf)if (newstats.failed > oldstats.failed) {printf ("\nECC failed at page 0x%08x\n" , (unsigned )(ofs + memregion.offset + i)); +init_progression_bar (length); +show_progress (ofs); oldstats.failed = newstats.failed; ecc_failed_cnt++; } } -printf ("\r0x%08x: checking..." , (unsigned )(ofs + memregion.offset));/* Compared written data with read data. * If data is not identical, display a detailed
@@ -309,27 +311,33 @@ static int do_nandtest(int argc, char *argv[]) rbuf = wbuf + meminfo.erasesize;for (pass =0 ; pass < nr_passes; pass++) { +init_progression_bar (length);for (test_ofs = flash_offset; test_ofs < flash_offset+length; test_ofs += meminfo.erasesize) {loff_t __test_ofs = test_ofs; +show_progress (test_ofs);srand (seed); seed =rand ();if (ioctl (fd,MEMGETBADBLOCK , &__test_ofs)) { -printf ("\rBad block at 0x%08x\n" , +printf ("\nBad block at 0x%08x\n" , (unsigned )(test_ofs + memregion.offset)); +init_progression_bar (length); +show_progress (test_ofs);continue ; }for (i =0 ; i < meminfo.erasesize; i++) wbuf[i] =rand (); - ret =erase_and_write (test_ofs, wbuf, rbuf); + ret =erase_and_write (test_ofs, wbuf, + rbuf, length);if (ret <0 ) goto err2; } +show_progress (test_ofs);printf ("\nFinished pass %d successfully\n" , pass+1 ); }
Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/8 nandtest: rename command argument p to i
In reply to Alexander AringRename command argument p for 'passes' to 'i' iteration.
--- commands/nandtest.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
commands/nandtest.c +8 -8
@@ -198,7 +198,7 @@ static int do_nandtest(int argc, char *argv[])int opt, length =-1 , do_nandtest_dev =-1 ;off_t flash_offset =0 ;off_t test_ofs; -unsigned int nr_passes =1 , pass; +unsigned int nr_iterations =1 , iter;int i;int ret =-1 ;unsigned char *wbuf, *rbuf;
@@ -210,7 +210,7 @@ static int do_nandtest(int argc, char *argv[])memset (ecc_stats,0 ,MAX_ECC_BITS ); -while ((opt =getopt (argc, argv,"ms:p:o:l:t" )) >0 ) { +while ((opt =getopt (argc, argv,"ms:i:o:l:t" )) >0 ) {switch (opt) {case 'm' : markbad =1 ;
@@ -218,8 +218,8 @@ static int do_nandtest(int argc, char *argv[])case 's' : seed =simple_strtoul (optarg,NULL ,0 );break ; -case 'p' : - nr_passes =simple_strtoul (optarg,NULL ,0 ); +case 'i' : + nr_iterations =simple_strtoul (optarg,NULL ,0 );break ;case 'o' : flash_offset =simple_strtoul (optarg,NULL ,0 );
@@ -310,7 +310,7 @@ static int do_nandtest(int argc, char *argv[]) } rbuf = wbuf + meminfo.erasesize; -for (pass =0 ; pass < nr_passes; pass++) { +for (iter =0 ; iter < nr_iterations; iter++) {init_progression_bar (length); for (test_ofs = flash_offset; test_ofs < flash_offset+length;
@@ -338,10 +338,10 @@ static int do_nandtest(int argc, char *argv[]) goto err2; }show_progress (test_ofs); -printf ("\nFinished pass %d successfully\n" , pass+1 ); +printf ("\nFinished pass %d successfully\n" , iter+1 ); } -print_stats (nr_passes, length); +print_stats (nr_iterations, length); ret =close (fd);if (ret <0 ) {
@@ -366,7 +366,7 @@ static const __maybe_unused char cmd_nandtest_help[] =" -t, Really do a nandtest on device.\n" " -m, Mark blocks bad if they appear so.\n" " -s <seed>, Supply random seed.\n" -" -p <passes>, Number of passes.\n" +" -i <iterations>, Number of iterations.\n" " -o <offset>, Start offset on flash.\n" " -l <length>, Length of flash to test.\n" ;
Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/8 nandtest: change flash length variable type
In reply to Alexander AringChange flash 'length' variable type to off_t instead of int.
--- commands/nandtest.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
commands/nandtest.c +6 -7
@@ -195,9 +195,8 @@ static void print_stats(int nr_passes, int length)/* Main program. */ static int do_nandtest (int argc,char *argv[]) { -int opt, length =-1 , do_nandtest_dev =-1 ; -off_t flash_offset =0 ; -off_t test_ofs; +int opt, do_nandtest_dev =-1 ; +off_t flash_offset =0 , test_ofs, length =0 ;unsigned int nr_iterations =1 , iter;int i;int ret =-1 ;
@@ -272,7 +271,7 @@ static int do_nandtest(int argc, char *argv[]) goto err; } -if (length ==-1 ) { +if (!length) { length = meminfo.size; length -= flash_offset; }
@@ -292,13 +291,13 @@ static int do_nandtest(int argc, char *argv[]) }if (length % meminfo.erasesize) {printf ("Length 0x%08x not multiple of erase size 0x%08x\n" , - length, meminfo.erasesize); + (unsigned )length, meminfo.erasesize); goto err; }if (length + flash_offset > meminfo.size) {printf ("Length 0x%08x + offset 0x%08x exceeds " -"device size 0x%08x\n" , - length, (unsigned )flash_offset, meminfo.size); +"device size 0x%08x\n" , (unsigned )length, + (unsigned )flash_offset, meminfo.size); goto err; }
Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/8 nandtest: use get_random_bytes instead of for loop
In reply to Alexander AringUse already builtin get_random_bytes instead of for loop.
--- commands/nandtest.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
commands/nandtest.c +1 -4
@@ -198,7 +198,6 @@ static int do_nandtest(int argc, char *argv[])int opt, do_nandtest_dev =-1 ;off_t flash_offset =0 , test_ofs, length =0 ;unsigned int nr_iterations =1 , iter; -int i;int ret =-1 ;unsigned char *wbuf, *rbuf;
@@ -328,9 +327,7 @@ static int do_nandtest(int argc, char *argv[])continue ; } -for (i =0 ; i < meminfo.erasesize; i++) - wbuf[i] =rand (); - +get_random_bytes (wbuf, meminfo.erasesize); ret =erase_and_write (test_ofs, wbuf, rbuf, length);if (ret <0 )
Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 6/8 nandtest: clean up code
In reply to Alexander AringClean up code:
- change 'i+i' to 'i + i'.
- change counter variable to unsigned int.
- use spaces instead of tabs in help text.
- remove __test_ofs variable.
--- commands/nandtest.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-)
commands/nandtest.c +16 -18
@@ -144,8 +144,8 @@ static int erase_and_write(off_t ofs, unsigned char *data, ecc_stats_over++; }else {/* Increment ECC stat value */ - ecc_stats[(newstats.corrected- - oldstats.corrected)-1 ]++; + ecc_stats[(newstats.corrected - + oldstats.corrected) -1 ]++; }/* Set oldstats to newstats */ oldstats.corrected = newstats.corrected;
@@ -179,13 +179,13 @@ static int erase_and_write(off_t ofs, unsigned char *data,/* Print stats of nandtest. */ static void print_stats (int nr_passes,int length) { -int i; +unsigned int i;printf ("-------- Summary --------\n" );printf ("Tested blocks : %d\n" , (length/meminfo.erasesize) * nr_passes);for (i =0 ; i <MAX_ECC_BITS ; i++) -printf ("ECC %d bit error(s) : %d\n" , i+1 , ecc_stats[i]); +printf ("ECC %d bit error(s) : %d\n" , i +1 , ecc_stats[i]);printf ("ECC >%d bit error(s) : %d\n" ,MAX_ECC_BITS , ecc_stats_over);printf ("ECC corrections failed : %d\n" , ecc_failed_cnt);
@@ -195,10 +195,9 @@ static void print_stats(int nr_passes, int length)/* Main program. */ static int do_nandtest (int argc,char *argv[]) { -int opt, do_nandtest_dev =-1 ; +int opt, do_nandtest_dev =-1 , ret =-1 ;off_t flash_offset =0 , test_ofs, length =0 ;unsigned int nr_iterations =1 , iter; -int ret =-1 ;unsigned char *wbuf, *rbuf; ecc_failed_cnt =0 ;
@@ -276,10 +275,10 @@ static int do_nandtest(int argc, char *argv[]) }printf ("Flash offset: 0x%08x\n" , - (unsigned )(flash_offset+memregion.offset)); + (unsigned )(flash_offset + memregion.offset));printf ("Length: 0x%08x\n" , (unsigned )length);printf ("End address: 0x%08x\n" , - (unsigned )(flash_offset+length+memregion.offset)); + (unsigned )(flash_offset + length + memregion.offset));printf ("Erasesize: 0x%08x\n" , (unsigned )(meminfo.erasesize));printf ("Starting nandtest...\n" );
@@ -311,14 +310,13 @@ static int do_nandtest(int argc, char *argv[])for (iter =0 ; iter < nr_iterations; iter++) {init_progression_bar (length);for (test_ofs = flash_offset; - test_ofs < flash_offset+length; + test_ofs < flash_offset + length; test_ofs += meminfo.erasesize) { -loff_t __test_ofs = test_ofs;show_progress (test_ofs);srand (seed); seed =rand (); -if (ioctl (fd,MEMGETBADBLOCK , &__test_ofs)) { +if (ioctl (fd,MEMGETBADBLOCK , &test_ofs)) {printf ("\nBad block at 0x%08x\n" , (unsigned )(test_ofs + memregion.offset));
@@ -334,7 +332,7 @@ static int do_nandtest(int argc, char *argv[]) goto err2; }show_progress (test_ofs); -printf ("\nFinished pass %d successfully\n" , iter+1 ); +printf ("\nFinished pass %d successfully\n" , iter +1 ); }print_stats (nr_iterations, length);
@@ -359,12 +357,12 @@ err:/* String for usage of nandtest */ static const __maybe_unused char cmd_nandtest_help[] ="Usage: nandtest [OPTION] <device>\n" -" -t, Really do a nandtest on device.\n" -" -m, Mark blocks bad if they appear so.\n" -" -s <seed>, Supply random seed.\n" -" -i <iterations>, Number of iterations.\n" -" -o <offset>, Start offset on flash.\n" -" -l <length>, Length of flash to test.\n" ; +" -t, Really do a nandtest on device.\n" +" -m, Mark blocks bad if they appear so.\n" +" -s <seed>, Supply random seed.\n" +" -i <iterations>, Number of iterations.\n" +" -o <offset>, Start offset on flash.\n" +" -l <length>, Length of flash to test.\n" ;BAREBOX_CMD_START (nandtest) .cmd = do_nandtest,
Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 7/8 nandtest: use loff_t instead off_t
In reply to Alexander AringUse the same offset type like mtd interface.
Replace modulo operation with IS_ALIGNED macro.
--- commands/nandtest.c | 57 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 29 deletions(-)
commands/nandtest.c +28 -29
@@ -45,7 +45,7 @@ static unsigned int ecc_failed_cnt;/* * Implementation of pread with lseek and read. */ -static ssize_t pread (int fd,void *buf,size_t count,off_t offset) +static ssize_t pread (int fd,void *buf,size_t count,loff_t offset) {int ret;
@@ -66,7 +66,7 @@ static ssize_t pread(int fd, void *buf, size_t count, off_t offset)* Implementation of pwrite with lseek and write. */ static ssize_t pwrite (int fd,const void *buf, -size_t count,off_t offset,off_t length) +size_t count,loff_t offset,loff_t length) {int ret;
@@ -79,8 +79,8 @@ static ssize_t pwrite(int fd, const void *buf,if (ret <0 ) {perror ("write" );if (markbad) { -printf ("\nMark block bad at 0x%08x\n" , - (unsigned )(offset + memregion.offset)); +printf ("\nMark block bad at 0x%08llx\n" , + offset + memregion.offset);ioctl (fd,MEMSETBADBLOCK , &offset);init_progression_bar (length);show_progress (offset);
@@ -98,8 +98,8 @@ static ssize_t pwrite(int fd, const void *buf,* Param rbuf: pointer to allocated buffer to copy readed data. * Param length: length of testing area */ -static int erase_and_write (off_t ofs,unsigned char *data, -unsigned char *rbuf,off_t length) +static int erase_and_write (loff_t ofs,unsigned char *data, +unsigned char *rbuf,loff_t length) {struct erase_info_user er;unsigned int i;
@@ -132,9 +132,9 @@ static int erase_and_write(off_t ofs, unsigned char *data, }if (newstats.corrected > oldstats.corrected) { -printf ("\n %d bit(s) ECC corrected at page 0x%08x\n" , +printf ("\n %d bit(s) ECC corrected at page 0x%08llx\n" , newstats.corrected - oldstats.corrected, - (unsigned )(ofs + memregion.offset + i)); + ofs + memregion.offset + i);init_progression_bar (length);show_progress (ofs); if ((newstats.corrected-oldstats.corrected) >=
@@ -151,8 +151,8 @@ static int erase_and_write(off_t ofs, unsigned char *data, oldstats.corrected = newstats.corrected; }if (newstats.failed > oldstats.failed) { -printf ("\nECC failed at page 0x%08x\n" , - (unsigned )(ofs + memregion.offset + i)); +printf ("\nECC failed at page 0x%08llx\n" , + ofs + memregion.offset + i);init_progression_bar (length);show_progress (ofs); oldstats.failed = newstats.failed;
@@ -196,7 +196,7 @@ static void print_stats(int nr_passes, int length)static int do_nandtest (int argc,char *argv[]) {int opt, do_nandtest_dev =-1 , ret =-1 ; -off_t flash_offset =0 , test_ofs, length =0 ; +loff_t flash_offset =0 , test_ofs, length =0 ;unsigned int nr_iterations =1 , iter;unsigned char *wbuf, *rbuf;
@@ -274,28 +274,28 @@ static int do_nandtest(int argc, char *argv[]) length -= flash_offset; } -printf ("Flash offset: 0x%08x\n" , - (unsigned )(flash_offset + memregion.offset)); -printf ("Length: 0x%08x\n" , (unsigned )length); -printf ("End address: 0x%08x\n" , - (unsigned )(flash_offset + length + memregion.offset)); -printf ("Erasesize: 0x%08x\n" , (unsigned )(meminfo.erasesize)); +printf ("Flash offset: 0x%08llx\n" , + flash_offset + memregion.offset); +printf ("Length: 0x%08llx\n" , length); +printf ("End address: 0x%08llx\n" , + flash_offset + length + memregion.offset); +printf ("Erasesize: 0x%08x\n" , meminfo.erasesize);printf ("Starting nandtest...\n" ); -if (flash_offset % meminfo.erasesize) { -printf ("Offset 0x%08x not multiple of erase size 0x%08x\n" , - (unsigned )flash_offset, meminfo.erasesize); +if (!IS_ALIGNED (flash_offset, meminfo.erasesize)) { +printf ("Offset 0x%08llx not multiple of erase size 0x%08x\n" , + flash_offset, meminfo.erasesize); goto err; } -if (length % meminfo.erasesize) { -printf ("Length 0x%08x not multiple of erase size 0x%08x\n" , - (unsigned )length, meminfo.erasesize); +if (!IS_ALIGNED (length, meminfo.erasesize)) { +printf ("Length 0x%08llx not multiple of erase size 0x%08x\n" , + length, meminfo.erasesize); goto err; }if (length + flash_offset > meminfo.size) { -printf ("Length 0x%08x + offset 0x%08x exceeds " -"device size 0x%08x\n" , (unsigned )length, - (unsigned )flash_offset, meminfo.size); +printf ("Length 0x%08llx + offset 0x%08llx exceeds " +"device size 0x%08x\n" , length, + flash_offset, meminfo.size); goto err; }
@@ -317,9 +317,8 @@ static int do_nandtest(int argc, char *argv[]) seed =rand ();if (ioctl (fd,MEMGETBADBLOCK , &test_ofs)) { -printf ("\nBad block at 0x%08x\n" , - (unsigned )(test_ofs + - memregion.offset)); +printf ("\nBad block at 0x%08llx\n" , + test_ofs + memregion.offset);init_progression_bar (length);show_progress (test_ofs);continue ;
Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 8/8 nandtest: add another constraints check
In reply to Alexander AringAdd check if writesize is a multiple of erasesize.
--- commands/nandtest.c | 7 +++++++ 1 file changed, 7 insertions(+)
commands/nandtest.c +7 -0
@@ -282,6 +282,13 @@ static int do_nandtest(int argc, char *argv[])printf ("Erasesize: 0x%08x\n" , meminfo.erasesize);printf ("Starting nandtest...\n" ); +if (!IS_ALIGNED (meminfo.erasesize, meminfo.writesize)) { +printf ("Erasesize 0x%08x is not a multiple " +"of writesize 0x%08x.\n" +"Please check driver implementation\n" , + meminfo.erasesize, meminfo.writesize); + goto err; + }if (!IS_ALIGNED (flash_offset, meminfo.erasesize)) {printf ("Offset 0x%08llx not multiple of erase size 0x%08x\n" , flash_offset, meminfo.erasesize);
Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 6 lines · Alexander Aring
Small Summary:
- The old nandtest do a ecc statistic per eraseblock, it's better to do this per page. I don't know how this works with subpages.- Add a progressbar instead of prints of current flash offset.
Quoted 8 lines
- Rename command argument 'passes' to 'iterations', which makes more sense.
- use builtin function '
get_random_bytes' to generate random buffer.- use
loff_tinstead ofoff_t. To handle flash >4GB.- add another constraints check for writesize.
Applied, thanks
Sascha
Quoted 23 lines
Alexander Aring (8):
nandtest: stat ecc per page not per eraseblock
nandtest: add progressbar instead of offset print
nandtest: rename command argument p to i
nandtest: change flash length variable type
nandtest: useget_random_bytesinstead of for loop
nandtest: clean up code
nandtest: useloff_tinsteadoff_t
nandtest: add another constraints checkcommands/nandtest.c | 190 ++++++++++++++++++++++++++++------------------------ 1 file changed, 103 insertions(+), 87 deletions(-)Signature · 7 lines
1.7.12.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox