1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# Simple detection module for AX206 based DPF hardware
# (c) 2011 <hackfin@section5.ch>
#
# Run with argument:
#
# - generic scsi device, e.g. /dev/sg1
# or:
# - "usb0" for hacked device
#
# NOTE: The LCD detection will only work on a hacked device
import struct
import sys
sys.path.append("./Debug")
import dpf
g_spansion_types = {
0x13: ("s25fl008", 16, 0x10000)
}
g_stm_types = {
0x14: ("m25p80", 16, 0x10000),
0x15: ("m25p16", 32, 0x10000),
0x16: ("m25p32", 64, 0x10000)
}
g_amic_types = {
0x13: ("a25l080", 16, 0x10000),
}
g_vendors = {
0x00: ("ST legacy", g_stm_types),
0x01: ("Spansion", g_spansion_types),
0x20: ("ST/Numonyx", g_stm_types),
0x1c: ("EON", g_stm_types),
0x37: ("AMIC", g_amic_types),
0xc2: ("Macronix", g_stm_types),
0xc8: ("Apple", g_stm_types),
0xef: ("Winbond", g_stm_types)
}
g_lcdmanu = {
0x45: "Philips/NXP",
0x5c: "Sitronix",
0x54: "Ilitek"
}
g_lcdctrl = {
0x66: "ILI9163B",
0xf0: "ST7735R"
}
def detect_lcd(d):
d.writeMemory("app_detect.ihx")
d.run(0x18a0)
buf = d.readMemory(0x1900, 4)
v = struct.unpack("BBBB", buf)
if v[1] != 0xff:
try:
manu = g_lcdmanu[v[1]]
print "Manufacturer:", manu
print "Module/driver version:", hex(v[2])
print "Identified module:", g_lcdctrl[v[3]]
except KeyError:
print "Unknown module id", hex(v[1]), hex(v[2]), hex(v[3])
else:
print "Does not support RDID"
def detect_flash(d):
manu, dev0, dev1 = d.probeFlash()
try:
print "Manufacturer: %s" % g_vendors[manu][0]
f = g_vendors[manu][1][dev1]
except KeyError:
print "Unknown Manufacturer"
print "Got id[3]: %x, %x, %x" % (manu, dev0, dev1)
try:
f = g_stm_types[1][dev1]
print "Compatible : %s" % f[0]
except KeyError:
print "Unable to detect flash, just assuming 2MB size"
f = ("m25p16", 32, 0x10000)
bytes = f[1] * f[2]
print "Size : %d MB" % (bytes / (1024 * 1024))
return bytes
if __name__ == "__main__":
d = dpf.open(sys.argv[1])
detect_flash(d)
detect_lcd(d)
d.close()
|