summaryrefslogtreecommitdiffstats
path: root/reverse-engineering/vccx-sniffer.patch
blob: c5b7c75ba5e01cf472848cc20ab3589044071011 (plain)
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
diff --git a/libtoprammer/toprammer_main.py b/libtoprammer/toprammer_main.py
index 3962d44..4b00100 100644
--- a/libtoprammer/toprammer_main.py
+++ b/libtoprammer/toprammer_main.py
@@ -204,7 +204,34 @@ class TOP:
 			raise TOPException("Init: Unexpected status register (b): 0x%08X" % stat)
 
 		self.__bitfileUpload()
+
 		self.chip.initializeChip()
+		self.chip.setOutputEnableMask(0)
+		self.cmdSetVPPVoltage(12)
+		self.queueCommand("\x0E\x28\x01\x00")
+		self.flushCommands()
+
+		import hc4094sniffer
+		s = hc4094sniffer.Sniffer("/dev/ttyUSB0", 3)
+		count = 0
+		for i in range(0, 0xFF+1):
+			self.cmdLoadVCCXLayout(0)
+			self.cmdLoadVCCXLayout(i)
+			self.flushCommands()
+			time.sleep(0.1)
+			d = s.read()
+			d = ord(d[0]) | (ord(d[1]) << 8) | (ord(d[2]) << 16)
+			d ^= 0xFFFFFF
+			sys.stdout.write("0x%06X," % d)
+			count += 1
+			if count == 6:
+				count = 0
+				sys.stdout.write("\n")
+			else:
+				sys.stdout.write(" ")
+			sys.stdout.flush()
+
+		sys.exit(0)
 
 	def __bitfileUpload(self):
 		self.printDebug("Uploading bitfile %s..." % self.bitfile.getFilename())
bues.ch cgit interface