You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

164 lines
4.2 KiB

  1. # Defines basic Tcl procs for OpenOCD JTAG module
  2. # Executed during "init". Can be overridden
  3. # by board/target/... scripts
  4. proc jtag_init {} {
  5. if {[catch {jtag arp_init} err]!=0} {
  6. # try resetting additionally
  7. init_reset startup
  8. }
  9. }
  10. # This reset logic may be overridden by board/target/... scripts as needed
  11. # to provide a reset that, if possible, is close to a power-up reset.
  12. #
  13. # Exit requirements include: (a) JTAG must be working, (b) the scan
  14. # chain was validated with "jtag arp_init" (or equivalent), (c) nothing
  15. # stays in reset. No TAP-specific scans were performed. It's OK if
  16. # some targets haven't been reset yet; they may need TAP-specific scans.
  17. #
  18. # The "mode" values include: halt, init, run (from "reset" command);
  19. # startup (at OpenOCD server startup, when JTAG may not yet work); and
  20. # potentially more (for reset types like cold, warm, etc)
  21. proc init_reset { mode } {
  22. if {[using_jtag]} {
  23. jtag arp_init-reset
  24. }
  25. }
  26. #########
  27. # TODO: power_restore and power_dropout are currently neither
  28. # documented nor supported except on ZY1000.
  29. proc power_restore {} {
  30. echo "Sensed power restore, running reset init and halting GDB."
  31. reset init
  32. # Halt GDB so user can deal with a detected power restore.
  33. #
  34. # After GDB is halted, then output is no longer forwarded
  35. # to the GDB console.
  36. set targets [target names]
  37. foreach t $targets {
  38. # New event script.
  39. $t invoke-event arp_halt_gdb
  40. }
  41. }
  42. add_help_text power_restore "Overridable procedure run when power restore is detected. Runs 'reset init' by default."
  43. proc power_dropout {} {
  44. echo "Sensed power dropout."
  45. }
  46. #########
  47. # TODO: srst_deasserted and srst_asserted are currently neither
  48. # documented nor supported except on ZY1000.
  49. proc srst_deasserted {} {
  50. echo "Sensed nSRST deasserted, running reset init and halting GDB."
  51. reset init
  52. # Halt GDB so user can deal with a detected reset.
  53. #
  54. # After GDB is halted, then output is no longer forwarded
  55. # to the GDB console.
  56. set targets [target names]
  57. foreach t $targets {
  58. # New event script.
  59. $t invoke-event arp_halt_gdb
  60. }
  61. }
  62. add_help_text srst_deasserted "Overridable procedure run when srst deassert is detected. Runs 'reset init' by default."
  63. proc srst_asserted {} {
  64. echo "Sensed nSRST asserted."
  65. }
  66. # measure actual JTAG clock
  67. proc measure_clk {} {
  68. set start_time [ms];
  69. runtest 10000000;
  70. echo "Running at more than [expr 10000.0 / ([ms]-$start_time)] kHz";
  71. }
  72. add_help_text measure_clk "Runs a test to measure the JTAG clk. Useful with RCLK / RTCK."
  73. proc default_to_jtag { f args } {
  74. if [catch {transport select} current_transport] {
  75. echo "Info : session transport was not selected, defaulting to JTAG"
  76. transport select jtag
  77. eval $f $args
  78. } {
  79. error "session transport is \"$current_transport\" but your config requires JTAG"
  80. }
  81. }
  82. proc jtag args {
  83. eval default_to_jtag jtag $args
  84. }
  85. proc jtag_rclk args {
  86. eval default_to_jtag jtag_rclk $args
  87. }
  88. proc jtag_ntrst_delay args {
  89. eval default_to_jtag jtag_ntrst_delay $args
  90. }
  91. proc jtag_ntrst_assert_width args {
  92. eval default_to_jtag jtag_ntrst_assert_width $args
  93. }
  94. # BEGIN MIGRATION AIDS ... these adapter operations originally had
  95. # JTAG-specific names despite the fact that the operations were not
  96. # specific to JTAG, or otherewise had troublesome/misleading names.
  97. #
  98. # FIXME phase these aids out after about April 2011
  99. #
  100. proc jtag_khz args {
  101. echo "DEPRECATED! use 'adapter_khz' not 'jtag_khz'"
  102. eval adapter_khz $args
  103. }
  104. proc jtag_nsrst_delay args {
  105. echo "DEPRECATED! use 'adapter_nsrst_delay' not 'jtag_nsrst_delay'"
  106. eval adapter_nsrst_delay $args
  107. }
  108. proc jtag_nsrst_assert_width args {
  109. echo "DEPRECATED! use 'adapter_nsrst_assert_width' not 'jtag_nsrst_assert_width'"
  110. eval adapter_nsrst_assert_width $args
  111. }
  112. # stlink migration helpers
  113. proc stlink_device_desc args {
  114. echo "DEPRECATED! use 'hla_device_desc' not 'stlink_device_desc'"
  115. eval hla_device_desc $args
  116. }
  117. proc stlink_serial args {
  118. echo "DEPRECATED! use 'hla_serial' not 'stlink_serial'"
  119. eval hla_serial $args
  120. }
  121. proc stlink_layout args {
  122. echo "DEPRECATED! use 'hla_layout' not 'stlink_layout'"
  123. eval hla_layout $args
  124. }
  125. proc stlink_vid_pid args {
  126. echo "DEPRECATED! use 'hla_vid_pid' not 'stlink_vid_pid'"
  127. eval hla_vid_pid $args
  128. }
  129. proc stlink args {
  130. echo "DEPRECATED! use 'hla' not 'stlink'"
  131. eval hla $args
  132. }
  133. # END MIGRATION AIDS