NAND read/write.jffs2 fix
Subsystems (2)
PATCH v2 1/1 NAND read/write.jffs2 fix
patch for branch mtd-2.6.22.1 on git://git.denx.de/u-boot-nand-flash.git
nand read(.jffs2|.e|.i) skips bad blocks during read. write(.jffs2|.e|.i) skips bad blocks during write nand read will read 0xff for bad block. Update documentation.
--- common/cmd_nand.c | 73 ++--- doc/README.nand | 16 +- drivers/mtd/nand/nand_util.c | 814 ++++++++++++------------------------------ include/nand.h | 9 +- 4 files changed, 278 insertions(+), 634 deletions(-)
common/cmd_nand.c +31 -42
@@ -73,9 +73,10 @@ static int nand_dump(nand_info_t *nand, ulong off, int only_oob)while (i--) {if (!only_oob) {printf ("\t%02x %02x %02x %02x %02x %02x %02x %02x" -" %02x %02x %02x %02x %02x %02x %02x %02x\n" , - p[0 ], p[1 ], p[2 ], p[3 ], p[4 ], p[5 ], p[6 ], p[7 ], - p[8 ], p[9 ], p[10 ], p[11 ], p[12 ], p[13 ], p[14 ], p[15 ]); +" %02x %02x %02x %02x %02x %02x %02x %02x\n" , + p[0 ], p[1 ], p[2 ], p[3 ], p[4 ], p[5 ], p[6 ], p[7 ], + p[8 ], p[9 ], p[10 ], p[11 ], p[12 ], p[13 ], p[14 ], + p[15 ]); } p +=16 ; }
@@ -319,7 +320,6 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } -/* read write */ if (strncmp (cmd,"read" ,4 ) ==0 ||strncmp (cmd,"write" ,5 ) ==0 ) {int read;
@@ -334,33 +334,13 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])return 1 ; s =strchr (cmd,'.' ); -if (s !=NULL && - (!strcmp (s,".jffs2" ) || !strcmp (s,".e" ) || !strcmp (s,".i" ))) { -if (read) { -/* read */ -nand_read_options_t opts; -memset (&opts,0 ,sizeof (opts)); - opts.buffer = (u_char *) addr; - opts.length = size; - opts.offset = off; - opts.quiet = quiet; -/* -* ! BROKEN ! -* -* TODO: Function must be implemented -* -* ret = nand_read_opts(nand, &opts); -*/ - }else { -/* write */ -mtd_oob_ops_t opts; -memset (&opts,0 ,sizeof (opts)); - opts.datbuf = (u_char *) addr; - opts.len = size; - opts.ooblen =64 ; - opts.mode =MTD_OOB_AUTO ; - ret =nand_write_opts (nand, off, &opts); - } +if (s !=NULL && (!strcmp (s,".jffs2" ) || + !strcmp (s,".e" ) || !strcmp (s,".i" ))) { +if (read) + ret =nand_read_skip_bad (nand, off, &size, (u_char *)addr); +else + ret =nand_write_skip_bad (nand, off, &size, (u_char *)addr); + }else if (s !=NULL && !strcmp (s,".oob" )) {struct mtd_oob_ops ops;
@@ -374,7 +354,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ret = nand->write_oob (nand, off, &ops); }else {if (read) - ret =nand_read (nand, off, &size, (u_char *)addr); + ret =nand_read_ff_upon_bad (nand, off, &size, (u_char *)addr);else ret =nand_write (nand, off, &size, (u_char *)addr); }
@@ -399,6 +379,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) }return 1 ; } +if (strcmp (cmd,"biterr" ) ==0 ) {/* todo */ return 1 ;
@@ -489,23 +470,31 @@ usage:return 1 ; } -U_BOOT_CMD (nand,5 ,1 , do_nand, -"nand - NAND sub-system\n" , -"info - show available NAND devices\n" -"nand device [dev] - show or set current device\n" -"nand read[.jffs2] - addr off|partition size\n" -"nand write[.jffs2] - addr off|partition size - read/write `size' bytes starting\n" -" at offset `off' to/from memory address `addr'\n" -"nand erase [clean] [off size] - erase `size' bytes from\n" -" offset `off' (entire device if not specified)\n" +U_BOOT_CMD ( +nand,5 ,1 , do_nand, +"nand - NAND sub-system\n" , +"info - show available NAND devices\n" +"nand device [dev] - show or set current device\n" +"nand read[.jffs2|.i|.e] addr off|partition size - read `size' bytes\n" +" starting at offset `off' to memory address `addr'. Using one of the\n" +" `.' options bad blocks are skipped, otherwise they are read as 0xff\n" +"nand write[.jffs2|.i|.e] addr off|partition size - write `size'\n" +" bytes starting at offset `off' from memory address `addr'. Using\n" +" one of `.' options bad blocks is skipped otherwise write fails\n" +"nand erase [clean] [off size] - erase `size' bytes from offset\n" +" `off' (entire device if not specified)\n" "nand bad - show bad blocks\n" "nand dump[.oob] off - dump page\n" "nand scrub - really clean NAND erasing bad blocks (UNSAFE)\n" "nand markbad off - mark bad block at offset (UNSAFE)\n" "nand biterr off - make a bit error at offset (UNSAFE)\n" -"nand lock [tight] [status] - bring nand to lock state or display locked pages\n" +"nand lock [tight] [status] - bring nand to lock state or display\n" +" locked pages\n" "nand unlock [offset] [size] - unlock section\n" ); + + +static int nand_load_image (cmd_tbl_t *cmdtp,nand_info_t *nand,ulong offset,ulong addr,char *cmd) {
doc/README.nand +8 -8
@@ -57,14 +57,14 @@ Commands: Print information about all of the NAND devices found. nand read addr ofs|partition size - Read `size' bytes from `ofs' in NAND flash to `addr'. If a page - cannot be read because it is marked bad or an uncorrectable data - error is found the command stops with an error. + Read `size' bytes from `ofs' in NAND flash to `addr'. Data for + blocks that are marked bad is read as 0xff. If an uncorrectable + data error is found the command stops with an error. - nand read.jffs2 addr ofs|partition size - Like `read', but the data for blocks that are marked bad is read as - 0xff. This gives a readable JFFS2 image that can be processed by - the JFFS2 commands such as ls and fsload. + nand read.jffs2|.i addr ofs|partition size + Like `read', but the data for blocks that are marked bad are skipped + and it read the next block instead. This gives a readable JFFS2 image + that can be processed by the JFFS2 commands such as ls and fsload. nand read.oob addr ofs|partition size Read `size' bytes from the out-of-band data area corresponding to
@@ -77,7 +77,7 @@ Commands: cannot be written because it is marked bad or the write fails the command stops with an error. - nand write.jffs2 addr ofs|partition size + nand write.jffs2|.i addr ofs|partition size Like `write', but blocks that are marked bad are skipped and the data is written to the next block instead. This allows writing a JFFS2 image, as long as the image is short enough to fit even
drivers/mtd/nand/nand_util.c +233 -581
823 lines not on this page · raw message
include/nand.h +6 -3
@@ -106,9 +106,12 @@ struct nand_erase_options {typedef struct nand_erase_options nand_erase_options_t ; -int nand_write_opts (nand_info_t *mtd,loff_t to,mtd_oob_ops_t *ops); - -int nand_read_opts (nand_info_t *meminfo,const nand_read_options_t *opts); +int nand_read_ff_upon_bad (nand_info_t *nand,ulong offset,ulong *length, +u_char *buffer); +int nand_read_skip_bad (nand_info_t *nand,ulong offset,ulong *length, +u_char *buffer); +int nand_write_skip_bad (nand_info_t *nand,ulong offset,ulong *length, +u_char *buffer);int nand_erase_opts (nand_info_t *meminfo,const nand_erase_options_t *opts);#define NAND_LOCK_STATUS_TIGHT 0x01
Signature · 1 line
1.5.2.5
PATCH v2 1/1 NAND read/write.jffs2 fix
Quoted 7 lines · Morten Ebbell Hestens
patch for branch mtd-2.6.22.1 on
git://git.denx.de/u-boot-nand-flash.gitnand read(.jffs2|.e|.i) skips bad blocks during read. write(.jffs2|.e|.i) skips bad blocks during write nand read will read
0xfffor bad block. Update documentation.
---
Can I get a Signed-off-by?
-Scott
PATCH v2 1/1 NAND read/write.jffs2 fix
Quoted 8 lines
Quoted 7 lines
patch for branch mtd-2.6.22.1 on
git://git.denx.de/u-boot-nand-flash.gitnand read(.jffs2|.e|.i) skips bad blocks during read. write(.jffs2|.e|.i) skips bad blocks during write nand read will read
0xfffor bad block. Update documentation.
---
Quoted 4 lines
Can I get a Signed-off-by?
-Scott
Sorry, here it is.
Morten