ub.tcl 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # -*- tcl -*-
  2. # List all available programming hardwares, and select the USBBlaster.
  3. # (Note: this example assumes only one USBBlaster connected.)
  4. puts "Programming Hardwares:"
  5. foreach hardware_name [get_hardware_names] {
  6. puts $hardware_name
  7. if { [string match "USB-Blaster*" $hardware_name] } {
  8. set usbblaster_name $hardware_name
  9. }
  10. }
  11. puts "\nSelect JTAG chain connected to $usbblaster_name.\n";
  12. # List all devices on the chain, and select the first device on the chain.
  13. puts "\nDevices on the JTAG chain:"
  14. foreach device_name [get_device_names -hardware_name $usbblaster_name] {
  15. puts $device_name
  16. if { [string match "@1*" $device_name] } {
  17. set test_device $device_name
  18. }
  19. }
  20. puts "\nSelect device: $test_device.\n";
  21. # Virtual JTAG commands
  22. set vjtag_index 0
  23. proc vdr {length {value ""}} {
  24. upvar vjtag_index ix
  25. set opad [string repeat 0 [expr ($length+3)/4 - [string length $value]]]
  26. return [device_virtual_dr_shift -instance_index $ix \
  27. -show_equivalent_device_ir_dr_shift \
  28. -value_in_hex -length $length -dr_value "$opad$value"]
  29. }
  30. proc vir {cmd} {
  31. upvar vjtag_index ix
  32. return [device_virtual_ir_shift -instance_index $ix \
  33. -show_equivalent_device_ir_dr_shift \
  34. -ir_value $cmd -no_captured_ir_value]
  35. }
  36. # Device JTAG commands
  37. proc ddr {length {value ""}} {
  38. set opad [string repeat 0 [expr ($length+3)/4 - [string length $value]]]
  39. return [device_dr_shift -value_in_hex -length $length \
  40. -dr_value "$opad$value"]
  41. }
  42. proc dir {cmd} {
  43. return [device_ir_shift -ir_value $cmd -no_captured_ir_value]
  44. }
  45. # Open device
  46. open_device -hardware_name $usbblaster_name -device_name $test_device
  47. # Lock device
  48. device_lock -timeout 100000