@ -340,7 +340,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
opts . length = size ;
opts . offset = off ;
opts . quiet = quiet ;
// ret = nand_read_opts(nand, &opts);
/* ret = nand_read_opts(nand, &opts); */
} else {
/* write */
mtd_oob_ops_t opts ;
@ -406,44 +406,48 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
}
if ( status ) {
// ulong block_start = 0;
ulong off ;
// int last_status = -1;
/* ulong block_start = 0;
int last_status = - 1 ;
*/
struct nand_chip * nand_chip = nand - > priv ;
/* check the WP bit */
nand_chip - > cmdfunc ( nand , NAND_CMD_STATUS , - 1 , - 1 ) ;
printf ( " device is %swrite protected \n " ,
( nand_chip - > read_byte ( nand ) & 0x80 ?
" NOT " : " " ) ) ;
" NOT " : " " ) ) ;
for ( off = 0 ; off < nand - > size ; off + = nand - > writesize ) {
// int s = nand_get_lock_status(nand, off);
//
// /* print message only if status has changed
// * or at end of chip
// */
// if (off == nand->size - nand->writesize
// || (s != last_status && off != 0)) {
//
// printf("%08lx - %08lx: %8d pages %s%s%s\n",
// block_start,
// off-1,
// (off-block_start)/nand->writesize,
// ((last_status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""),
// ((last_status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""),
// ((last_status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : ""));
// }
//
// last_status = s;
#if 0 /* must be fixed */
int s = nand_get_lock_status ( nand , off ) ;
/* print message only if status has changed
* or at end of chip
*/
if ( off = = nand - > size - nand - > writesize
| | ( s ! = last_status & & off ! = 0 ) ) {
printf ( " %08lx - %08lx: %8d pages %s%s%s \n " ,
block_start ,
off - 1 ,
( off - block_start ) / nand - > writesize ,
( ( last_status & NAND_LOCK_STATUS_TIGHT ) ? " TIGHT " : " " ) ,
( ( last_status & NAND_LOCK_STATUS_LOCK ) ? " LOCK " : " " ) ,
( ( last_status & NAND_LOCK_STATUS_UNLOCK ) ? " UNLOCK " : " " ) ) ;
}
last_status = s ;
# endif
}
} else {
#if 0 /* must be fixed */
if ( ! nand_lock ( nand , tight ) ) {
puts ( " NAND flash successfully locked \n " ) ;
} else {
// if (!nand_lock(nand, tight)) {
// puts("NAND flash successfully locked\n");
// } else {
// puts("Error locking NAND flash\n");
// return 1;
// }
puts ( " Error locking NAND flash \n " ) ;
return 1 ;
}
# endif
}
return 0 ;
}
@ -452,13 +456,15 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
if ( arg_off_size ( argc - 2 , argv + 2 , nand , & off , & size ) < 0 )
return 1 ;
// if (!nand_unlock(nand, off, size)) {
// puts("NAND flash successfully unlocked\n");
// } else {
// puts("Error unlocking NAND flash, "
// "write and erase will probably fail\n");
// return 1;
// }
#if 0 /* must be fixed */
if ( ! nand_unlock ( nand , off , size ) ) {
puts ( " NAND flash successfully unlocked \n " ) ;
} else {
puts ( " Error unlocking NAND flash, "
" write and erase will probably fail \n " ) ;
return 1 ;
}
# endif
return 0 ;
}