1 # Defines basic Tcl procs for OpenOCD JTAG module
3 # Executed during "init". Can be overridden
4 # by board/target/... scripts
6 if {[catch {jtag arp_init
} err
]!=0} {
7 # try resetting additionally
12 # This reset logic may be overridden by board/target/... scripts as needed
13 # to provide a reset that, if possible, is close to a power-up reset.
15 # Exit requirements include: (a) JTAG must be working, (b) the scan
16 # chain was validated with "jtag arp_init" (or equivalent), (c) nothing
17 # stays in reset. No TAP-specific scans were performed. It's OK if
18 # some targets haven't been reset yet; they may need TAP-specific scans.
20 # The "mode" values include: halt, init, run (from "reset" command);
21 # startup (at OpenOCD server startup, when JTAG may not yet work); and
22 # potentially more (for reset types like cold, warm, etc)
23 proc init_reset
{ mode
} {
31 # TODO: power_restore and power_dropout are currently neither
32 # documented nor supported except on ZY1000.
34 proc power_restore
{} {
35 echo
"Sensed power restore, running reset init and halting GDB."
38 # Halt GDB so user can deal with a detected power restore.
40 # After GDB is halted, then output is no longer forwarded
42 set targets
[target names
]
45 $t invoke-event arp_halt_gdb
49 add_help_text power_restore
"Overridable procedure run when power restore is detected. Runs 'reset init' by default."
51 proc power_dropout
{} {
52 echo
"Sensed power dropout."
57 # TODO: srst_deasserted and srst_asserted are currently neither
58 # documented nor supported except on ZY1000.
60 proc srst_deasserted
{} {
61 echo
"Sensed nSRST deasserted, running reset init and halting GDB."
64 # Halt GDB so user can deal with a detected reset.
66 # After GDB is halted, then output is no longer forwarded
68 set targets
[target names
]
71 $t invoke-event arp_halt_gdb
75 add_help_text srst_deasserted
"Overridable procedure run when srst deassert is detected. Runs 'reset init' by default."
77 proc srst_asserted
{} {
78 echo
"Sensed nSRST asserted."
81 # measure actual JTAG clock
84 set iterations
10000000;
86 echo
"Running at more than [expr $iterations.0 / ([ms]-$start_time)] kHz";
89 add_help_text measure_clk
"Runs a test to measure the JTAG clk. Useful with RCLK / RTCK."
91 proc default_to_jtag
{ f args
} {
92 set current_transport
[transport select
]
96 error "session transport is \"$current_transport\" but your config requires JTAG"
101 eval default_to_jtag jtag
$args
104 proc jtag_rclk args
{
105 eval default_to_jtag jtag_rclk
$args
108 proc jtag_ntrst_delay args
{
109 eval default_to_jtag jtag_ntrst_delay
$args
112 proc jtag_ntrst_assert_width args
{
113 eval default_to_jtag jtag_ntrst_assert_width
$args
116 # BEGIN MIGRATION AIDS ... these adapter operations originally had
117 # JTAG-specific names despite the fact that the operations were not
118 # specific to JTAG, or otherewise had troublesome/misleading names.
120 # FIXME phase these aids out after about April 2011
123 echo
"DEPRECATED! use 'adapter_khz' not 'jtag_khz'"
124 eval adapter_khz
$args
127 proc jtag_nsrst_delay args
{
128 echo
"DEPRECATED! use 'adapter_nsrst_delay' not 'jtag_nsrst_delay'"
129 eval adapter_nsrst_delay
$args
132 proc jtag_nsrst_assert_width args
{
133 echo
"DEPRECATED! use 'adapter_nsrst_assert_width' not 'jtag_nsrst_assert_width'"
134 eval adapter_nsrst_assert_width
$args
137 # stlink migration helpers
138 proc stlink_device_desc args
{
139 echo
"DEPRECATED! use 'hla_device_desc' not 'stlink_device_desc'"
140 eval hla_device_desc
$args
143 proc stlink_serial args
{
144 echo
"DEPRECATED! use 'hla_serial' not 'stlink_serial'"
145 eval hla_serial
$args
148 proc stlink_layout args
{
149 echo
"DEPRECATED! use 'hla_layout' not 'stlink_layout'"
150 eval hla_layout
$args
153 proc stlink_vid_pid args
{
154 echo
"DEPRECATED! use 'hla_vid_pid' not 'stlink_vid_pid'"
155 eval hla_vid_pid
$args
159 echo
"DEPRECATED! use 'hla' not 'stlink'"