使用linux的MTD tests support测试flash性能

版权声明:本文为gp_scorpius原创文章,未经允许不得转载。 https://blog.csdn.net/gp_scoprius/article/details/53257056

在嵌入式linux开发过程中,经常会使用到nor flash,nand flash等存储设备,由于flash的芯片型号和接口类型较多,性能不一,我们需要对系统中使用的flash性能进行分析,并对设备工作的稳定性进行测试。

flash设备在嵌入式系统中,会被驱动为MTD分区,在linux kernel中,提供了针对MTD的测试模块,方面开发人员对flash的功能,性能,稳定性等进行测试。

使用make ARCH=arm  menuconfig打开kernel配置界面,配置 "Device Drivers" -> "Memory Technology Device (MTD) support" -> "MTD tests support",该选项只可以配置为按模块编译,保存配置后退出。

使用make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules编译代码,生成测试工具模块,存储在目录drivers/mtd/tests中,包括以下内容:

mtd_nandecctest.ko:nand flash的ECC校验测试

mtd_pagetest.ko:nand flash的page读写测试

mtd_speedtest.ko:MTD分区的读写速度测试

mtd_subpagetest.ko:nand flash的sub-page接口测试

mtd_oobtest.ko:nand falsh的OOB区域读写测试

mtd_readtest.ko:读取整个MTD分区

mtd_stresstest.ko:随机读写,擦除操作测试

mtd_torturetest.ko:该功能可用于做稳定性或者寿命测试,随机操作直到发生错误


在实时ko文件进行测试时,可以通过dev=n指定要测试的MTD分区,示例如下:

insmod mtd_stresstest.ko dev=9 count=1000
[ 3289.273771] =================================================
[ 3289.279826] mtd_stresstest: MTD device: 9
[ 3289.284079] mtd_stresstest: MTD device size 268435456, eraseblock size 131072, page size 2048, count of eraseblocks 2048, pages per eraseblock 64, OOB size 64
[ 3289.303250] mtd_stresstest: scanning for bad eraseblocks
[ 3289.420267] mtd_stresstest: scanned 2048 eraseblocks, 0 are bad
[ 3289.426534] mtd_stresstest: doing operations
[ 3289.431031] mtd_stresstest: 0 operations done
[ 3339.606972] mtd_stresstest: finished, 1000 operations done
[ 3339.612992] =================================================

当mtd_stresstest测试发生操作错误时,会退出并答应错误信息,示例如下:

[root@AT8XXX ~]# dmesg |grep mtd_stresstest
[591404.676252] mtd_stresstest: MTD device: 9
[591404.680577] mtd_stresstest: MTD device size 268435456, eraseblock size 131072, page size 2048, count of eraseblocks 2048, pages per eraseblock 64, OOB size 64
[591404.699798] mtd_stresstest: scanning for bad eraseblocks
[591404.715081] mtd_stresstest: block 78 is bad
[591404.723850] mtd_stresstest: block 159 is bad
[591404.812382] mtd_stresstest: block 1752 is bad
[591404.832925] mtd_stresstest: scanned 2048 eraseblocks, 3 are bad
[591404.839259] mtd_stresstest: doing operations
[591404.843859] mtd_stresstest: 0 operations done
[591459.037353] mtd_stresstest: 1024 operations done
[591510.529876] mtd_stresstest: 2048 operations done

[594847.430017] mtd_stresstest: error: write failed at 0xf964000
[594847.436350] mtd_stresstest: error -5 occurred

更多mtd test的信息参考http://www.linux-mtd.infradead.org/doc/general.html

阅读更多
换一批

没有更多推荐了,返回首页