summaryrefslogtreecommitdiffstats
path: root/reverse-engineering/top2049/vpp-sniffer.patch
blob: 0fbc1b9ba7b12db6db9a2f3cea049a4fa7acc7c0 (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
diff -u a/libtoprammer/main.py b/libtoprammer/main.py
--- a/libtoprammer/main.py
+++ b/libtoprammer/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", 4)
+		count = 0
+		for i in range(0, 0xFF+1):
+			self.cmdLoadVPPLayout(0)
+			self.cmdLoadVPPLayout(i)
+			self.flushCommands()
+			time.sleep(0.1)
+			d = s.read()
+			d = ord(d[0]) | (ord(d[1]) << 8) | (ord(d[2]) << 16) | (ord(d[3]) << 24)
+			d ^= 0xFFFFFFFF
+			sys.stdout.write("0x%08X," % d)
+			count += 1
+			if count == 5:
+				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