支援的命令函數說明
1. nand info/nand device
功能:顯示當前nand flash晶片資訊。
函數調用關係如下(按先後順序):
static void nand_print(struct nand_chip *nand) ;
2. nand erase
功能:擦除指定塊上的數據。
函數調用關係如下(按先後順序):
int nand_erase(struct nand_chip* nand, size_t ofs, size_t len, int clean);
3. nand bad
功能:顯示壞塊。
函數調用關係如下(按先後順序):
static void nand_print_bad(struct nand_chip* nand);
int check_block (struct nand_chip *nand, unsigned long pos);
4. nand read
功能:讀取nand flash信息到SDRAM。
函數調用關係如下(按先後順序):
int nand_rw (struct nand_chip* nand, int cmd,size_t start, size_t len, size_t * retlen, u_char * buf);
static int nand_read_ecc(struct nand_chip *nand, size_t start, size_t len,
size_t * retlen, u_char *buf, u_char *ecc_code);
static void NanD_ReadBuf (struct nand_chip *nand, u_char * data_buf, int cntr);
READ_NAND(adr);
5. nand write
功能:從SDRAM寫數據到nand flash中。
函數調用關係如下(按先後順序):
int nand_rw (struct nand_chip* nand, int cmd,size_t start, size_t len, size_t * retlen, u_char * buf);
static int nand_write_ecc (struct nand_chip* nand, size_t to, size_t len,
size_t * retlen, const u_char * buf, u_char * ecc_code);
static int nand_write_page (struct nand_chip *nand, int page, int col, int last, u_char * ecc_code);
WRITE_NAND(d , adr);
4.2.32 nand info
列印nand flash資訊
CRANE2410 # nand info
Device 0: Samsung K9F1208U0B at 0x4e000000 (64 MB, 16 kB sector)
4.2.33 nand device
顯示某個nand設備
CRANE2410 # nand device 0
Device 0: Samsung K9F1208U0B at 0x4e000000 (64 MB, 16 kB sector)
... is now current device
4.2.34 nand bad
CRANE2410 # nand bad
Device 0 bad blocks:
4.2.35 nand read
nand read InAddr FlAddr size
InAddr: 從nand flash中讀到記憶體的起始位址。
FlAddr: nand flash 的起始位址。
size: 從nand flash中讀取的數據的大小。
CRANE2410 # nand read 0x30008000 0 0x100000
NAND read: device 0 offset 0, size 1048576 ...
1048576 bytes read: OK
4.2.36 nand erease
nand erase FlAddr size
FlAddr: nand flash 的起始位址
size: 從nand flash中擦除資料塊的大小
CRANE2410 # nand erase 0x100000 0x20000
NAND erase: device 0 offset 1048576, size 131072 ... OK
4.2.37 nand write
nand write InAddr FlAddr size
InAddr: 寫到Nand Flash中的資料在記憶體的起始位址
FlAddr: Nand Flash的起始位址
size: 數據的大小
CRANE2410 # nand write 0x30f00000 0x100000 0x20000
NAND write: device 0 offset 1048576, size 131072 ...
131072 bytes written: OK
4.2.37 nboot
u-boot-1.1.4代碼對於nboot命令的幫助不正確,修改如下:
正確的順序為:
nboot InAddr dev FlAddr
InAddr: 需要裝載到的記憶體的位址。
FlAddr: 在nand flash上uImage存放的地址
dev: 設備號
需要提前設置環境變數,否則nboot不會調用bootm
CRANE2410 #setenv autostart yes
CRANE2410 # nboot 30008000 0 100000
Loading from device 0: at 0x4e000000 (offset 0x100000)
Image Name: Linux-2.6.14.3
Created: 2006-07-06 7:31:52 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 897428 Bytes = 876.4 kB
Load Address: 30008000
Entry Point: 30008040
Automatic boot of image at addr 0x30008000 ...
## Booting image at 30008000 ...
Starting kernel ...
4.3 命令簡寫說明
所以命令都可以簡寫,只要命令前面的一部分不會跟其他命令相同,就可以不用寫全整個命令.
save命令
CRANE2410 # sa
Saving Environment to Flash...
Un-Protected 1 sectors
Erasing Flash...Erasing sector 10 ... Erased 1 sectors
4.4 把文件寫入NandFlash
如果把一個傳到記憶體中的檔寫入到Nand Flash中, 如:新的uboot.bin, zImage(內核),
rootfs等, 如果做呢?我們可以用Nand Flash命令來完成. 但是Nand Flash寫時,必須先要把Nand
Flash的寫入區全部擦除後,才能寫. 下面以把記憶體0x30008000起長度為0x20000的內容寫到Nand
Flash中的0x100000為例.
CRANE2410 # nand erase 0x100000 20000
NAND erase: device 0 offset 1048576, size 131072 ... OK
CRANE2410 # nand write 0x30008000 0x100000 0x20000
NAND write: device 0 offset 1048576, size 131072 ...
131072 bytes written: OK
PS:鄙视用繁体字来写的人:
用法:
# nand erase FlAddr size
# nand write InAddr FlAddr size
# tftp RamAddr FileName
烧写UBOOT:
# nand erase 0x0 0x40000
# tftp 0x30008000 u-boot.bin
# nand write 0x30008000 0 0x40000
烧写内核的正确方法:
# nand erase 0x200000 0x200000
# tftp 0x30008000 zImage
# nand write 0x30008000 0x200000 0x200000
阅读(2478) | 评论(0) | 转发(0) |