improve startup tcl scripts
[fw/openocd] / src / jtag / startup.tcl
1 # Defines basic Tcl procs for OpenOCD JTAG module
2
3 # Executed during "init". Can be overridden
4 # by board/target/... scripts
5 proc jtag_init {} {
6         if {[catch {jtag arp_init} err]!=0} {
7                 # try resetting additionally
8                 init_reset startup
9         }
10 }
11
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.
14 #
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.
19 #
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 } {
24         jtag arp_init-reset
25 }
26
27 #########
28
29 # TODO: power_restore and power_dropout are currently neither
30 # documented nor supported except on ZY1000.
31
32 proc power_restore {} {
33         puts "Sensed power restore."
34         reset init
35 }
36
37 add_help_text power_restore "Overridable procedure run when power restore is detected. Runs 'reset init' by default."
38
39 proc power_dropout {} {
40         puts "Sensed power dropout."
41 }
42
43 #########
44
45 # TODO: srst_deasserted and srst_asserted are currently neither
46 # documented nor supported except on ZY1000.
47
48 proc srst_deasserted {} {
49         puts "Sensed nSRST deasserted."
50         reset init
51 }
52 add_help_text srst_deasserted "Overridable procedure run when srst deassert is detected. Runs 'reset init' by default."
53
54 proc srst_asserted {} {
55         puts "Sensed nSRST asserted."
56 }