aboutsummaryrefslogtreecommitdiff
path: root/tcl/cpld
diff options
context:
space:
mode:
authorTim 'mithro' Ansell <mithro@mithis.com>2015-09-27 20:09:38 +1000
committerPaul Fertser <fercerpav@gmail.com>2015-10-21 09:11:48 +0100
commit3edb15784eca5bdd7981f7889909e273ad9775d1 (patch)
tree104e8a272634f7d317426bce7b609be2ae120839 /tcl/cpld
parent41daa32351e2aba8055ffc9358c3d8a9c996c85f (diff)
tcl: Support for reading "Device DNA" from Spartan 6 devices.
Most Xilinx FPGA devices contain an embedded, unique device identifier called the "Device DNA". The identifier is nonvolatile, permanently programmed into the FPGA, and is unchangeable providing a great serial / tracking number. Debugging was done in https://github.com/timvideos/HDMI2USB/issues/36 Change-Id: Iad03eafb40887f0321a4dc22858a7c3bf37a12b3 Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com> Reviewed-on: http://openocd.zylin.com/2960 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Diffstat (limited to 'tcl/cpld')
-rw-r--r--tcl/cpld/xilinx-xc6s.cfg36
1 files changed, 36 insertions, 0 deletions
diff --git a/tcl/cpld/xilinx-xc6s.cfg b/tcl/cpld/xilinx-xc6s.cfg
index b705ea1f..9ce7ad49 100644
--- a/tcl/cpld/xilinx-xc6s.cfg
+++ b/tcl/cpld/xilinx-xc6s.cfg
@@ -52,3 +52,39 @@ proc xc6s_program_iprog {tap} {
irscan $tap $XC6S_BYPASS
runtest 1
}
+
+set XC6S_ISC_ENABLE 0x10
+set XC6S_ISC_DISABLE 0x16
+set XC6S_ISC_DNA 0x30
+
+# Get the "Device DNA" from the Spartan 6.
+# Most Xilinx FPGA devices contain an embedded, unique device identifier called
+# the "Device DNA". The identifier is nonvolatile, permanently programmed into
+# the FPGA, and is unchangeable providing a great serial / tracking number.
+proc xc6s_get_dna {tap} {
+ global XC6S_ISC_ENABLE XC6S_ISC_DISABLE XC6S_ISC_DNA
+ irscan $tap $XC6S_ISC_ENABLE
+ runtest 64
+ irscan $tap $XC6S_ISC_DNA
+ # Device DNA is 57 bits long, but we can only read 32bits at a time
+ # with OpenOCD.
+ set dna [drscan $tap 16 0 16 0 16 0 9 0]
+ runtest 64
+ irscan $tap $XC6S_ISC_DISABLE
+ runtest 64
+
+ # Convert the binary data into the order impact uses
+ scan $dna "%x %x %x %x" v1 v2 v3 v4
+ set bin_dna [string reverse [concat [format "%09b" $v4][format "%016b" $v3][format "%016b" $v2][format "%016b" $v1]]]
+
+ # Return a hex version of binary
+ scan [format "0b%s" $bin_dna] "%i" hex_dna
+ return $hex_dna
+}
+
+# Print out the "Device DNA" in the same format that impact uses.
+proc xc6s_print_dna {tap} {
+ set hex_dna [xc6s_get_dna $tap]
+
+ puts [format "DNA = %57b (0x%x)\n" $hex_dna $hex_dna]
+}