Linux下,如何验证SD/EMMC卡?

2023-08-29 16:40:35 浏览数 (3)

Linux下mmc_test测试工具使用

很多朋友也都有疑问,如何在Linux下,测试emmc/sd模块呢? 当然,mmc core提供了mmc_test.c来作为mmc driver的测试文件。

如何使用mmc_test.c测试文件测试mmc 驱动呢?

1、将mmc_test.c编译到内核

默认情况下,mmc_test.c是独立的文件,并没有编译到内核中,需要我们到menuconfig中手动打开。

打开的配置有:CONFIG_MMC_TESTCONFIG_MMC_DEBUGCONFIG_DEBUG_FS三个配置。

注意CONFIG_MMC_TEST,该选项可以选择M*,分别对应为:编译成模块或者直接编译到内核

这里我们选择*

2、mmc_test绑定

默认情况下,我们一般都已经加载了mmc driver,那么要想使用mmc_test工具测试,需要将mmc设备绑定到该mmc_test驱动上。

2.1、查看驱动编号

通过下面命令,查询对应的mmc编号,如下:mmc0:0001,忽略掉

代码语言:javascript复制
ls /sys/bus/mmc/drivers/mmcblk/mmc0:0001/

2.2、解绑mmc原驱动

代码语言:javascript复制
echo mmc0:0001 >  /sys/bus/mmc/drivers/mmcblk/unbind

2.3、绑定mmc_test驱动

代码语言:javascript复制
echo mmc0:0001 > /sys/bus/mmc/drivers/mmc_test/bind

2.4、debugfs挂载

代码语言:javascript复制
mount -t debugfs none /sys/kernel/debug

2.5、查看测试列表

代码语言:javascript复制
cd /sys/kernel/debug/mmc0/mmc0:0001/
cat testlist 
代码语言:javascript复制
0:      Run all tests
1:      Basic write (no data verification)
2:      Basic read (no data verification)
3:      Basic write (with data verification)
4:      Basic read (with data verification)
5:      Multi-block write
6:      Multi-block read
7:      Power of two block writes
8:      Power of two block reads
9:      Weird sized block writes
10:     Weird sized block reads
11:     Badly aligned write
12:     Badly aligned read
13:     Badly aligned multi-block write
14:     Badly aligned multi-block read
15:     Correct xfer_size at write (start failure)
16:     Correct xfer_size at read (start failure)
17:     Correct xfer_size at write (midway failure)
18:     Correct xfer_size at read (midway failure)
19:     Highmem write
20:     Highmem read
21:     Multi-block highmem write
22:     Multi-block highmem read
23:     Best-case read performance
24:     Best-case write performance
25:     Best-case read performance into scattered pages
26:     Best-case write performance from scattered pages
27:     Single read performance by transfer size
28:     Single write performance by transfer size
29:     Single trim performance by transfer size
30:     Consecutive read performance by transfer size
31:     Consecutive write performance by transfer size
32:     Consecutive trim performance by transfer size
33:     Random read performance by transfer size
34:     Random write performance by transfer size
35:     Large sequential read into scattered pages
36:     Large sequential write from scattered pages
37:     Write performance with blocking req 4k to 4MB
38:     Write performance with non-blocking req 4k to 4MB
39:     Read performance with blocking req 4k to 4MB
40:     Read performance with non-blocking req 4k to 4MB
41:     Write performance blocking req 1 to 512 sg elems
42:     Write performance non-blocking req 1 to 512 sg elems
43:     Read performance blocking req 1 to 512 sg elems
44:     Read performance non-blocking req 1 to 512 sg elems
45:     Reset test
46:     Commands during read - no Set Block Count (CMD23)
47:     Commands during write - no Set Block Count (CMD23)
48:     Commands during read - use Set Block Count (CMD23)
49:     Commands during write - use Set Block Count (CMD23)
50:     Commands during non-blocking read - use Set Block Count (CMD23)
51:     Commands during non-blocking write - use Set Block Count (CMD23)

2.6、测试指定命令

代码语言:javascript复制
echo number > test

number:是上面的测试序号。

如:echo 1 > test

代码语言:javascript复制
mmc0: Starting tests of card mmc0:0001...
mmc0: Test case 1. Basic write (no data verification)...
mmc0: Result: OK

这个工具可以尽可能的帮助我们测试SD/EMMC卡,使用起来吧!

0 人点赞