显示flash的信息:
DM365 :>nand info
Device 0: NAND 32MiB 3,3V 8-bit, sector size 16 KiB
DM365 :>nand device
Device 0: NAND 32MiB 3,3V 8-bit
不管是读取data, 使用nand read,还是读取oob,使用命令nand read.oob, 后面跟的地址addr,都是ram的地址, off指的是nand flash的地址, size:指要读取nand flash的数据大小, 但是如果是读取oob, size不能超过一个page的oob size, 如果page size为512个字节, oob size就是16个字节.
DM365 :>nand read 86000000 58000 100
NAND read: device 0 offset 0x58000, size 0x100
256 bytes read: OK
DM365 :>md 86000000 40
86000000: ea000012 e59ff014 e59ff014 e59ff014 ................
…………
860000f0: e1a0000d eb00022e 00000000 00000000 ................
DM365 :>nand read.oob 86000000 58000 10
NAND read: device 0 offset 0x58000, size 0x10
16 bytes read: OK
DM365 :>md 86000000 40
86000000: ffffffff 2707ffff 33e316ad 44b2e1a1 .......'...3...D
如果一次想读取完整的一个page 的值,包含oob, 使用下面将的命令, nand dump.
调用过程: nand dump addr size (common/cmd_nand.c)==> nand_dump() ==> nand_read_raw();
nand dump 不管你的size有多大,至少会dump出一个page的大小:
SMDK2440 # nand dump 0 100
Page 00000000 dump:
12 00 00 ea 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5
14 f0 9f e5 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5
00 02 f8 33 60 02 f8 33 c0 02 f8 33 20 03 f8 33
80 03 f8 33 e0 03 f8 33 40 04 f8 33 ef be ad de
00 00 f8 33 00 00 f8 33 58 19 fa 33 34 6d fa 33
00 00 0f e1 1f 00 c0 e3 d3 00 80 e3 00 f0 29 e1
…………
04 30 8c e5 fc 4d 00 eb 00 01 9f e5 f0 3c 00 eb
02 0d 00 eb 41 42 00 eb f4 00 9f e5 00 40 98 e5
04 02 00 eb 0d 10 a0 e1 04 00 84 e5 40 20 a0 e3
OOB:
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
69 a6 ab 3c 33 cf 66 5a
a7 cf f0 33 a6 96 97 3f
0c c3 30 30 c3 cc 33 f3
这个命令和nand read一样, 只是方向是反的, 是把ram的值写到 nand flash中, 但是这个写只能将1改为0, 不能将0写成1. 这个command会自动skipping bad blocks。
在擦之前会先check是不是坏块,如果是坏块,就不能做擦的动作了。
DM365 :>nand dump 1cc000 10
Page 001cc000 dump:
68 73 71 73 12 05 00 00 87 04 08 78 19 00 40 02
…………
df 88 5b 80 bb 11 32 11 6e e7 77 5a 3d b9 c8 bf
OOB:
ff ff ff ff ff ff ff 45
ed cc 3a e0 8e 52 f9 ad
DM365 :>nand erase 1cc000 100
NAND erase: device 0 offset 0x1cc000, size 0x100
Warning: Erase size 0x00000100 smaller than one erase block 0x00004000
Erasing 0x00004000 instead
Erasing at 0x1cc000 -- 100% complete.
OK
DM365 :>nand dump 1cc000 10
Page 001cc000 dump:
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
…………
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
OOB:
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
DM365 :>mw 86000000 00000000
DM365 :>mw 86000004 00000000
DM365 :>mw 86000008 00000000
DM365 :>mw 8600000c 00000000
DM365 :>md 86000000
86000000: 00000000 00000000 00000000 00000000 ................
DM365 :>nand write.oob 86000000 1cc000 10
NAND write: device 0 offset 0x1cc000, size 0x10
16 bytes written: OK
DM365 :>nand dump 1cc000 10
Page 001cc000 dump:
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
…………
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
OOB:
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
DM365 :>nand erase 1cc000 100
NAND erase: device 0 offset 0x1cc000, size 0x100
Warning: Erase size 0x00000100 smaller than one erase block 0x00004000
Erasing 0x00004000 instead
Skipping bad block at 0x001cc000
OK
这些命令都是测试时使用的,正常是不会使用到的。
"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]\n"
" bring nand to lock state or display locked pages\n"
"nand unlock [offset] [size] - unlock section\n");