xilinx-dna.cfg 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. proc xilinx_dna_addr {chip} {
  3. array set addrs {
  4. Spartan6 0x30
  5. Series7 0x17
  6. }
  7. return $addrs($chip)
  8. }
  9. # Get the "Device DNA".
  10. # Most Xilinx FPGA devices contain an embedded, unique device identifier.
  11. # The identifier is nonvolatile, permanently programmed into
  12. # the FPGA, and is unchangeable providing a great serial / tracking number.
  13. # This function returns the DNA as a 64 bit integer with the 7 LSBs zeroed.
  14. # This is compatible with the FUSE DNA which contains all 64 bits.
  15. proc xilinx_get_dna {tap chip} {
  16. set XC7_ISC_ENABLE 0x10
  17. set XC7_ISC_DISABLE 0x16
  18. set XC7_ISC_DNA [xilinx_dna_addr $chip]
  19. irscan $tap $XC7_ISC_ENABLE
  20. runtest 64
  21. irscan $tap $XC7_ISC_DNA
  22. scan [drscan $tap 32 0 32 0] "%08x %08x" hi lo
  23. runtest 64
  24. irscan $tap $XC7_ISC_DISABLE
  25. runtest 64
  26. # openocd interprets DR scans as LSB first, bit-reverse it
  27. return [scan [string reverse [format "%032b%032bb0" $lo $hi]] "%i"]
  28. }
  29. # Print out the "Device DNA" in the same format that impact uses.
  30. proc xilinx_print_dna {dna} {
  31. set dna [expr {$dna >> 64 - 57}]
  32. echo [format "DNA = %057b (0x%016x)" $dna $dna]
  33. }
  34. proc xc7_get_dna {tap} {
  35. return [xilinx_get_dna $tap Series7]
  36. }
  37. proc xc6s_get_dna {tap} {
  38. return [xilinx_get_dna $tap Spartan6]
  39. }