mtd-utils 的 使用
关于编译可以查看文章:《Arm-Linux 移植 mtd-utils 1.x》
查看信息
使用命令前用cat /proc/mtd 查看一下mtdchar字符设备;或者用ls -l /dev/mtd*
cat /proc/mtd
dev: size erasesize name
mtd0: 00c00000 "ROOTFS"
mtd1: "BOOTLOADER"
mtd2: "KERNEL"
mtd3: "NAND ROOTFS partition"
mtd4: 04b00000 "NAND DATAFS partition"
为了更详细了解分区信息用mtd_debug命令
mtd_debug info /dev/mtdX #(不能使用mtdblockX, mtdblockX 只是提供用來 mount 而已) mtd.type = MTD_NORFLASH
mtd.flags =
mtd.size = (12M)
mtd.erasesize = (128K)
mtd.oobblock =
mtd.oobsize =
mtd.ecctype = (unknown ECC type - new MTD API maybe?)
regions =
mtd 有关命令
命令:flash_erase
擦除指定范围内flash的内容;如果不指定,默认擦出起始位置的第一块,使相应flash变为全1
用法:
flash_erase MTD-device [start] [cnt (# erase blocks)] [lock]
MTD-device:待擦出的分区,如/dev/mtd0
start:起始位置设置,这里必须设置为0x20000(128K)的整数倍
cnt: 从start开始计算,要擦出的块数
lock: 写保护
eg: ./flash_erase /dev/mtd0 0x40000 //擦出mtd0分区上从0x40000开始的5块数据 ,128K/块
命令:flash_eraseall
擦除整个分区的数据,同时也会作坏块检测
用法:
flash_eraseall [OPTION] MTD_DEVICE
-q, --quiet 不显示打印信息
-j, --jffs2 一jffs2 格式化分区 eg: ./flash_eraseall -j /dev/mtd0
命令:flashcp
copy 数据到 flash 中
用法:
usage: flashcp [ -v | --verbose ] <filename> <device>
flashcp -h | --help
filename:待写入的数据
device: 写入的分区,如/dev/mtd0 eg:
filename制作: mkfs.jffs2 -e 0x20000 -d cq8401 -o cq8401.img -n //这里的-e 0x20000 必须更你芯片的erasesize 相等 ./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 )
-p, --pad pad to page size
-b, --blockalign=|| 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 /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 <device>
mtd_debug read <device> <offset> <len> <dest-filename>
mtd_debug write <device> <offset> <len> <source-filename>
mtd_debug erase <device> <offset> <len> 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
参考地址(节选)
http://blog.csdn.net/gzshun/article/details/7051425
mtd-utils 的 使用的更多相关文章
- Creating and Flashing UBIFS with MTD Utils
转:http://wiki.atlas-embedded.com/index.php?title=Creating_and_Flashing_UBIFS_with_MTD_Utils Contents ...
- Is an MTD device a block device or a char device?
转:http://www.linux-mtd.infradead.org/faq/general.html#L_mtd_what Note, you can find Ukranian transla ...
- UBIFS - UBI File-System
参考:http://www.linux-mtd.infradead.org/doc/ubifs.html#L_raw_vs_ftl UBIFS - UBI File-System Table of c ...
- 【C#公共帮助类】 Utils 10年代码,最全的系统帮助类
为大家分享一下个人的一个Utils系统帮助类,可能有些现在有新的技术替代,自行修改哈~ 这个帮助类主要包含:对象转换处理 .分割字符串.截取字符串.删除最后结尾的一个逗号. 删除最后结尾的指定字符后的 ...
- python学习笔记-import utils报错
今天遇到一个坑爹的问题,查找了半天原因,终于解决了,在此特地记录一下. 运行环境:Windows eclipse 我在eclipse中配置了python的运行环境,在eclipse中编写python代 ...
- Lind.DDD.Utils.HttpHelper里静态对象引出的Http超时问题
回到目录 Lind.DDD.Utils.HttpHelper组件主要实现了对HTTP的各种操作,如Get,Post,Put和Delete,它属于最纯粹的操作,大叔把它封装的目的主要为了实现与API安全 ...
- Utils
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.CollectionUtils ...
- Spring @Autowired注解在utils静态工具类
[转] 使用场景:在一个静态方法中,如何使用以下注入: @Autowired private ItemMapper itemMapper; @Component public class TestUt ...
- utils.js
/** * //2.0检测方式(目测,测量,专用仪器测试等) function GetCheckType() { $.ajax({ url: '@Url.Action("GetCheckTy ...
- Perl/Nagios – Can’t locate utils.pm in @INC
While trying to use a Nagios plugin I got an error saying that “Can’t locate utils.pm in @INC”. Foll ...
随机推荐
- sql server for centos7
sql server for centos7 笔者在CENTOS7上面安装SQL SERVER,感觉非常方便. 但有一点要注意,字段是字符串类型的,要使用nvarchar(),不能使用varchar( ...
- Kettle建立数据库链接报错-'MS SQL Server' driver (jar file) is installed. kettle的bug,对于12.2而言
1.链接sql server数据库报错 错误连接数据库 [My_vm_win_sql] : org.pentaho.di.core.exception.KettleDatabaseException: ...
- ActiveMQ持久化
ActiveMQ中,持久化是值对消息数据的持久化.在ActiveMQ中,默认的消息是保存在内存中的.当内存容量不足的时候,或ActiveMQ正常关闭的时候,会将内存中的未处理的消息持久化到磁盘中.具体 ...
- post请求头中常见content-type(非常重要)
定义和用法 enctype 属性规定在发送到服务器之前应该如何对表单数据进行编码.默认地,表单数据会编码为 "application/x-www-form-urlencoded". ...
- Javascript事件派发-dispatchEvent
事件派发的作用: 1.派发数据,将一个封闭模块中的数据传递给另一个封闭模块.2.事件完成了较为复杂的解耦. 事件和回调函数不同在于: 1.事件可以在任意地方去获取,而回调函数只能在一个地方存在,如果需 ...
- 【Python】使用POST方式抓取有道翻译结果
1.安装requests库 2.打开有道翻译,按下F12,进入开发者模式,输入我爱青青,点击Network,再点击XHR 3.撰写爬虫 import requestsimport json # 使用有 ...
- 005-guava 集合-集合工具类-java.util.Collections中未包含的集合工具[Maps,Lists,Sets],Iterables、Multisets、Multimaps、Tables
一.概述 工具类与特定集合接口的对应关系归纳如下: 集合接口 属于JDK还是Guava 对应的Guava工具类 Collection JDK Collections2:不要和java.util.Col ...
- Spring cloud微服务安全实战-6-9sentinel之熔断降级
来讲一下降级规则 服务会互相调用,服务A会有一些服务之间的依赖. 假设服务D的响应时间变长了.A调用D就会卡住了. 熔断,某一个服务出现问题,会把服务拖死.如果A出现,会把依赖A的那些服务拖死. 主要 ...
- LODOP打印table表格宽度固定-超宽隐藏
之前有博文介绍关于超出div隐藏内容的:LODOP打印超过后隐藏内容样式里面提到了overflow:hidden;控制超出后隐藏,但是前面那篇用的是div,如果是在table中,由于table默认的t ...
- VSCode 代码格式化快捷键
转载自:http://geek-docs.com/vscode/vscode-tutorials/vscode-code-formatting.html VSCode 代码格式化快捷键,我们平常在做自 ...