顯示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");
uboot中記憶體操作: U Boot NAND FLASH驅動分析
u boot nand flash 驅動分析 西伯利亞的風 一 初始化函式呼叫關係 初始化函式呼叫關係如圖 1.1所示。1.u boot 啟動過程中呼叫 nand init 初始化nand flash。2.函式nand init 呼叫nand init chip 完成nand flash 初始化。3...
U Boot NAND FLASH驅動分析
一 初始化函式呼叫關係 初始化函式呼叫關係如圖 1.1所示。1.u boot 啟動過程中呼叫 nand init 初始化nand flash。2.函式nand init 呼叫nand init chip 完成nand flash 初始化。3.nand init chip 順序呼叫 board nan...
u boot nand flash驅動架構分析一
在移植nand flash驅動之前,我們要先熟悉u boot中nand flash驅動架構以及nand flash操作原理。在u boot啟動過程中呼叫了nand init函式,這就是nand flash驅動初始化的入口點。if defined config cmd nand puts nand n...