-
-
Save checko/32e668d0358e1d1f4af7d3f19cd407c0 to your computer and use it in GitHub Desktop.
Parse eMMC Extended CSD and print useful things.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Author: Kyle Manna <kyle@kylemanna.com> | |
Blog: https://blog.kylemanna.com | |
cat /d/mmc0/mmc0:0001/ext_csd | |
0000000000000001030100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000087a0000000000000000061502030700100608010101080800100000728000000808080808080000000000010200070002000500000000000001000200000000000000000000000000000100050000000000030001ca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
""" | |
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 = '0000000000000001030100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000087a0000000000000000061502030700100608010101080800100000728000000808080808080000000000010200070002000500000000000001000200000000000000000000000000000100050000000000030001ca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' | |
#ecsd_str = '320100' | |
ecsd = str2bytearray(ecsd_str) | |
line_len = 16 | |
i = 0 | |
while i < len(ecsd): | |
sys.stdout.write("{0:04x}:\t".format(i)) | |
for j in range(line_len): | |
if (i < len(ecsd)): | |
sys.stdout.write("{0:=02x}".format(ord(ecsd[i]))) | |
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 "SLC_DEVICE_HEALTH_STATUS[87] = 0x{:x}".format(ord(ecsd[87])) | |
print "MLC_DEVICE_HEALTH_STATUS[94] = 0x{:x}".format(ord(ecsd[94])) | |
print "SEC_BAD_BLK_MGMNT[134] = 0x{:x}".format(ord(ecsd[134])) | |
print "FW_CONFIG[169] = 0x{:x}".format(ord(ecsd[169])) | |
print "ERASE_GROUP_DEF[175] = 0x{:x}".format(ord(ecsd[175])) | |
print "EXT_CSD_REV[192] = 0x{:x}".format(ord(ecsd[192])) | |
print "CSD_STRUCTURE[194] = 0x{:x}".format(ord(ecsd[194])) | |
print "CARD_TYPE[196] = 0x{:x}".format(ord(ecsd[196])) | |
print "ERASE_TIMEOUT_MULT[223] = 0x{:x}".format(ord(ecsd[223])) | |
print "HC_ERASE_GRP_SIZE[224] = 0x{:x}".format(ord(ecsd[224])) | |
print "BOOT_INFO[228] = 0x{:x}".format(ord(ecsd[228])) | |
print "SEC_TRIM_MULT[229] = 0x{:x}".format(ord(ecsd[229])) | |
print "SEC_ERASE_MULT[230] = 0x{:x}".format(ord(ecsd[230])) | |
print "SEC_FEATURE_SUPPORT[231] = 0x{:x}".format(ord(ecsd[231])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment