最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

将新的Linux kernel中的MTD test加入到旧的kernel中

工作和技术 crifan 1334浏览 0评论

Linux Kernel自从2.6.29之后,就加入了MTD test模块,即几个测试模块,用于测试你的mtd的特性。

分别是:

mtd_oobtest.c //测试oob数据读写是否正常
mtd_pagetest.c //测试page读写
mtd_readtest.c //测试读功能
mtd_speedtest.c //测试mtd的速度
mtd_stresstest.c //压力测试
mtd_subpagetest.c //子页面(如果支持的话,此处我的是MLC,不支持sub page)
mtd_torturetest.c //扭曲测试? 反正就是对mtd“严刑拷打”,看看其能经受多少读写,直至挂掉。。,所以,作者说了,除非你知道自己在干啥,否则不要随意进行这个测试。

其中,最有用的就是speed test了,方便了开发者用来测试你的mtd(我的此处是nand flash)的读/写/擦除块的速度。

我当前用的Linux kernel是2.6.28.4,没有加入MTD test,所以自己加入:

(1)下载mtd tests源码,并加入到自己的内核中,编译成.ko模块用于后期动态加载:

我这里是从最新内核linux-2.6.32.8:

http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.8.tar.bz2

中的/drivers/mtd/test里面抽取的,然后放到自己的kernel源码中:

/drivers/mtd/test,再把

config MTD_TESTS
tristate "MTD tests support"
depends on m
help
This option includes various MTD tests into compilation. The tests
should normally be compiled as kernel modules. The modules perform
various checks and verifications when loaded.
加入到Kconfig中,把

obj-y   += tests/

加入到Makefile中。然后make ARCH=arm menuconfig,去把mtd test选上:

Device Drivers —>

<*> Memory Technology Device (MTD) support —>

<M>   MTD tests support

再编译一下:

make ARCH=arm; make ARCH=arm uImage

就可以生成对应的.ko模块文件了。

(2).如何使用MTD test:

进入Kernel后,使用也很简单

比如:insmod mtd_speedtest.ko dev=3

注:此处的dev指的是你mtd设备number,我这里的:

# cat /proc/mtd
dev:    size   erasesize name
mtd0: 00100000 00080000 "U-Boot"
mtd1: 00800000 00080000 "Kernel"
mtd2: 0c800000 00080000 "Root filesystem"
mtd3: 04000000 00080000 "Temp"
mtd4: 69000000 00080000 "Data"

dev=3,就是mtd3,就是上面的Temp分区。

(3)举例如何使用:

最后列举一些测试结果如下:

# ls
mtd_oobtest.ko          mtd_readtest.ko         mtd_subpagetest.ko
mtd_speedtest.ko        mtd_torturetest.ko
mtd_pagetest.ko         mtd_stresstest.ko
# insmod mtd_speedtest.ko dev=3

=================================================
mtd_speedtest: MTD device: 3
mtd_speedtest: MTD device size 67108864, eraseblock size 524288, page size 4096, count of eraseblocks 128, pages per eraseblock 128, OOB size 128
mtd_speedtest: scanning for bad eraseblocks
mtd_speedtest: scanned 128 eraseblocks, 0 are bad
mtd_speedtest: testing eraseblock write speed
mtd_speedtest: eraseblock write speed is 1754 KiB/s
mtd_speedtest: testing eraseblock read speed
mtd_speedtest: eraseblock read speed is 2443 KiB/s
mtd_speedtest: testing page write speed
mtd_speedtest: page write speed is 1748 KiB/s
mtd_speedtest: testing page read speed
mtd_speedtest: page read speed is 2439 KiB/s
mtd_speedtest: testing 2 page write speed
mtd_speedtest: 2 page write speed is 1751 KiB/s
mtd_speedtest: testing 2 page read speed
mtd_speedtest: 2 page read speed is 2440 KiB/s
mtd_speedtest: Testing erase speed
mtd_speedtest: erase speed is 439838 KiB/s
mtd_speedtest: finished
=================================================

# insmod mtd_oobtest.ko dev=3

=================================================
mtd_oobtest: MTD device: 3
mtd_oobtest: MTD device size 67108864, eraseblock size 524288, page size 4096, count of eraseblocks 128, pages per eraseblock 128, OOB size 128
mtd_oobtest: scanning for bad eraseblocks
mtd_oobtest: scanned 128 eraseblocks, 0 are bad
mtd_oobtest: test 1 of 5
mtd_oobtest: erasing whole device
mtd_oobtest: erased 128 eraseblocks
mtd_oobtest: writing OOBs of whole device
mtd_oobtest: written up to eraseblock 0
mtd_oobtest: written 128 eraseblocks
mtd_oobtest: verifying all eraseblocks
mtd_oobtest: verified up to eraseblock 0
mtd_oobtest: verified 128 eraseblocks
mtd_oobtest: test 2 of 5
mtd_oobtest: erasing whole device
mtd_oobtest: erased 128 eraseblocks
mtd_oobtest: writing OOBs of whole device
mtd_oobtest: written up to eraseblock 0
mtd_oobtest: written 128 eraseblocks
mtd_oobtest: verifying all eraseblocks
mtd_oobtest: verified up to eraseblock 0
mtd_oobtest: verified 128 eraseblocks
mtd_oobtest: test 3 of 5
mtd_oobtest: erasing whole device
mtd_oobtest: erased 128 eraseblocks
mtd_oobtest: writing OOBs of whole device
mtd_oobtest: written up to eraseblock 0
mtd_oobtest: written 128 eraseblocks
mtd_oobtest: verifying all eraseblocks
mtd_oobtest: verified up to eraseblock 0
mtd_oobtest: verified 128 eraseblocks
mtd_oobtest: test 4 of 5
mtd_oobtest: erasing whole device
mtd_oobtest: erased 128 eraseblocks
mtd_oobtest: attempting to start write past end of OOB
mtd_oobtest: an error is expected…
mtd_oobtest: error occurred as expected
mtd_oobtest: attempting to start read past end of OOB
mtd_oobtest: an error is expected…
mtd_oobtest: error occurred as expected
mtd_oobtest: attempting to write past end of device
mtd_oobtest: an error is expected…
mtd_oobtest: error occurred as expected
mtd_oobtest: attempting to read past end of device
mtd_oobtest: an error is expected…
mtd_oobtest: error: read past end of device
mtd_oobtest: attempting to write past end of device
mtd_oobtest: an error is expected…
mtd_oobtest: error occurred as expected
mtd_oobtest: attempting to read past end of device
mtd_oobtest: an error is expected…
mtd_oobtest: error: read past end of device
mtd_oobtest: test 5 of 5
mtd_oobtest: erasing whole device
mtd_oobtest: erased 128 eraseblocks
mtd_oobtest: writing OOBs of whole device
mtd_oobtest: written up to eraseblock 0
mtd_oobtest: written up to eraseblock 0
mtd_oobtest: written 127 eraseblocks
mtd_oobtest: verifying all eraseblocks
mtd_oobtest: verified up to eraseblock 0
mtd_oobtest: verified 127 eraseblocks
mtd_oobtest: finished with 2 errors
=================================================

[附录]

1.MTD tests

http://www.linux-mtd.infradead.org/doc/general.html

转载请注明:在路上 » 将新的Linux kernel中的MTD test加入到旧的kernel中

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
54 queries in 0.115 seconds, using 18.66MB memory