在/sys/devices/platform/6b030000.esdhc/mmc_host/mmc0/mmc0:0001/目录下可以读取到cid、csd、dsr、ocr、寄存器的值.
# mount -t debugfs none /sys/kernel/debug/
@xxx:/sys/kernel/debug/mmc0 # cat ios
@xxx:/sys/kernel/debug/mmc0/mmc0:0001 # cat ext_csd
00000000000000000000000000000000390300c0470700c04707000000000000000101000000000000000000000000000000000000000000000000000a000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000900e00070100000000151f20000000000000000000000000000000010100090000000008000200571f0a0aeeee8888001e0f460f78140100c0470710140a0a090201320808400007fdfb550100640aeeeeee99011e0200000000320a00100000ee01000000000000000000012020010100000000000000000000000000000000000000000000000000000000000000000000000000001f0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffff00000103007f0003013f3f01010100000000000000
当然这样看很难看,无法很快的确认寄存器中某些位的值。因此,网上就有个小哥写了个python脚本来解析这512字节的数据,以常人可以理解的格式进行解析。详见:https://blog.kylemanna.com/linux/parse-emmc-extended-csd-ecsd-registers-with-python/ 输出的格式如下:
victor @victor-HP:~/ work2/cal_time$ python analysis_ext_csd.py
0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0016: 39 03 00 c0 47 07 00 c0 47 07 00 00 00 00 00 00
0032: 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00
0048: 00 00 00 00 00 00 00 00 00 00 00 00 0a 00 00 01
0064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0096: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0112: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0128: 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00
0144: 00 00 00 00 00 00 00 00 00 00 00 00 00 90 0e 00
0160: 07 01 00 00 00 00 15 1f 20 00 00 00 00 00 00 00
0176: 00 00 00 00 00 00 00 00 01 01 00 09 00 00 00 00
0192: 08 00 02 00 57 1f 0a 0a ee ee 88 88 00 1e 0f 46
0208: 0f 78 14 01 00 c0 47 07 10 14 0a 0a 09 02 01 32
0224: 08 08 40 00 07 fd fb 55 01 00 64 0a ee ee ee 99
0240: 01 1e 02 00 00 00 00 32 0a 00 10 00 00 ee 01 00
0256: 00 00 00 00 00 00 00 00 01 20 20 01 01 00 00 00
0272: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0288: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0304: 00 00 00 1f 01 00 00 00 00 00 00 00 00 00 00 00
0320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0336: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0352: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0368: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0384: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0416: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0432: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0448: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0464: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0480: 00 00 00 00 00 00 01 ff ff ff ff 00 00 01 03 00
0496: 7f 00 03 01 3f 3f 01 01 01 00 00 00 00 00 00 00
BOOT_SIZE_MULTI[226] = 0x20
Python内容如下:
#!/usr/bin/env python
"""
Author: Kyle Manna <kyle@kylemanna.com>
Blog: https://blog.kylemanna.com
"""
import binascii
import re
import sys
def str2bytearray(s):
if len(s) % 2:
s = '0' + s
reorder = True
if reorder:
r = []
i = 1
while i <= len(s):
r.append(s[len(s) - i - 1])
r.append(s[len(s) - i])
i += 2
s = ''.join(r)
out = binascii.unhexlify(s)
return out
if __name__ == '__main__':
ecsd_str = '00000000000000000000000000000000390300c0470700c04707000000000000000101000000000000000000000000000000000000000000000000000a000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000900e00070100000000151f20000000000000000000000000000000010100090000000008000200571f0a0aeeee8888001e0f460f78140100c0470710140a0a090201320808400007fdfb550100640aeeeeee99011e0200000000320a00100000ee01000000000000000000012020010100000000000000000000000000000000000000000000000000000000000000000000000000001f0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ffffffff00000103007f0003013f3f01010100000000000000'
#ecsd_str = '320100'
ecsd = str2bytearray(ecsd_str)
csd_len = len(ecsd)
line_len = 16
i = 0
while i < len(ecsd):
sys.stdout.write("{0:04d}:\t".format(i))
for j in range(line_len):
if (i < csd_len):
sys.stdout.write("{0:=02x}".format(ord(ecsd[csd_len-i-1])))
i = i + 1
else:
break
if (j == (line_len - 1)): pass
elif (i % 4): sys.stdout.write(" ")
else: sys.stdout.write(" ")
sys.stdout.write("\n")
print "BOOT_SIZE_MULTI[226] = 0x{:x}".format(ord(ecsd[csd_len-168-1]))