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.

startup.tcl 2.9 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. jtag arp_init-reset
  23. }
  24. #########
  25. # TODO: power_restore and power_dropout are currently neither
  26. # documented nor supported except on ZY1000.
  27. proc power_restore {} {
  28. echo "Sensed power restore, running reset init and halting GDB."
  29. reset init
  30. # Halt GDB so user can deal with a detected power restore.
  31. #
  32. # After GDB is halted, then output is no longer forwarded
  33. # to the GDB console.
  34. set targets [target names]
  35. foreach t $targets {
  36. # New event script.
  37. $t invoke-event arp_halt_gdb
  38. }
  39. }
  40. add_help_text power_restore "Overridable procedure run when power restore is detected. Runs 'reset init' by default."
  41. proc power_dropout {} {
  42. echo "Sensed power dropout."
  43. }
  44. #########
  45. # TODO: srst_deasserted and srst_asserted are currently neither
  46. # documented nor supported except on ZY1000.
  47. proc srst_deasserted {} {
  48. echo "Sensed nSRST deasserted, running reset init and halting GDB."
  49. reset init
  50. # Halt GDB so user can deal with a detected reset.
  51. #
  52. # After GDB is halted, then output is no longer forwarded
  53. # to the GDB console.
  54. set targets [target names]
  55. foreach t $targets {
  56. # New event script.
  57. $t invoke-event arp_halt_gdb
  58. }
  59. }
  60. add_help_text srst_deasserted "Overridable procedure run when srst deassert is detected. Runs 'reset init' by default."
  61. proc srst_asserted {} {
  62. echo "Sensed nSRST asserted."
  63. }
  64. # measure actual JTAG clock
  65. proc measure_clk {} {
  66. set start_time [ms];
  67. runtest 10000000;
  68. echo "Running at more than [expr 10000.0 / ([ms]-$start_time)] kHz";
  69. }
  70. add_help_text measure_clk "Runs a test to measure the JTAG clk. Useful with RCLK / RTCK."
  71. # BEGIN MIGRATION AIDS ... these adapter operations originally had
  72. # JTAG-specific names despite the fact that the operations were not
  73. # specific to JTAG, or otherewise had troublesome/misleading names.
  74. #
  75. # FIXME phase these aids out after about April 2011
  76. #
  77. proc jtag_khz args { eval adapter_khz $args }
  78. proc jtag_nsrst_delay args { eval adapter_nsrst_delay $args }
  79. proc jtag_nsrst_assert_width args { eval adapter_nsrst_assert_width $args }
  80. # END MIGRATION AIDS