./flashcp cq8401.img /dev/mtd0 // copy cq8401.img文件系统到 /dev/mtd0分区中
当然这个命令的功能跟 dd if=/tmp/fs.img of=/dev/mtd0差不多
命令:nandwrite
作用:向nand flash中写数据
用法:
nandwrite [OPTION] MTD_DEVICE INPUTFILE
-a, --autoplace Use auto oob layout
-j, --jffs2 force jffs2 oob layout (legacy support)
-y, --yaffs force yaffs oob layout (legacy support)
-f, --forcelegacy force legacy support on autoplacement enabled mtd device
-n, --noecc write without ecc
-o, --oob image contains oob data
-s addr, --start=addr set start address (default is 0)
-p, --pad pad to page size
-b, --blockalign=1|2|4 set multiple of eraseblocks to align to
-q, --quiet don't display progress messages
--help display this help and exit
--version output version information and exit
eg: ./nandwrite -p /dev/mtd0 /tmp/rootfs.jffs2
命令:nanddump
作用:dump出nand flash一些信息,如:block size,erasesize,oobblock 大小,oob data ,page data等;同时也会作坏块检测
用法:
nanddump [OPTIONS] MTD-device
--help display this help and exit
--version output version information and exit
-f file --file=file dump to file
-i --ignoreerrors ignore errors
-l length --length=length length
-o --omitoob omit oob data
-b --omitbad omit bad blocks from the dump
-p --prettyprint print nice (hexdump)
-s addr --startaddress=addr start address
eg:./nanddump -p -f nandinfo.txt /dev/mtd0 //dump出nand flash /dev/mtd0数据并保存到 nandinfo.txt
命令:mtd_debug
作用: 对mtd 调试作用
用法:
usage: mtd_debug info
mtd_debug read
mtd_debug write
mtd_debug erase
eg:
#./mtd_debug info /dev/mtd0 // 输出/dev/mtd0上的一些信息,这里必须用mtdx
#./mtd_debug erase /dev/mtd0 0x0 0x40000 // 擦出/dev/mtd0 分区上 从0x0开始的 , 128K*2 大小的数据
#./mtd_debug write /dev/mtdblock0 ox0 0x360810 cq8401.img //向mtdblock0分区,写入 3.6M 大小的文件系统cq8401.img,这里最好用mtdblockx
#./mtd_debug read /dev/mtdblock0 ox0 0x360810 read.img //从mtdblock0中读出 3.6M 数据保存到read.img
# cmp -l cq8401.img read.img // 验证write to flash 和 read from flash 中的数据是否一致;也可以使用diff命令来比较
另外针对nand flash,mtd_debug这个工具来测试mtd驱动也不是很好,用nandwrite和nanddump这两个工具或许更好点。然后可以用cmp这个命令来比较一下nanddump出来的数据和nandwrite写入的数据是否一致。
命令:ftl_format
解释:In order to use one of conventional file systems (Ext2, ext3, XFS, JFS, FAT) over an MTD device, you need a software layer which emulates a block device over the MTD device. These layers are often called Flash Translation Layers (FTLs).
七、参考文章
http://blog.csdn.net/yinkaizhong/archive/2008/12/25/3604794.aspx
http://hi.baidu.com/qwetiop/blog/item/f2acb50f03e800eaab64577a.html
http://blog.chinaunix.net/u1/53103/showart_1101011.html