add overridable Tcl "init_reset"
authorDavid Brownell <dbrownell@users.sourceforge.net>
Fri, 9 Oct 2009 06:51:50 +0000 (23:51 -0700)
committerDavid Brownell <dbrownell@users.sourceforge.net>
Fri, 9 Oct 2009 06:51:50 +0000 (23:51 -0700)
This abstracts the "jtag arp_init-reset" call into a method
called from OpenOCD startup and reset processing.

Platforms which have different requirements for how such hard
resets must be performed can now override "init_reset" instead
of needing to rebuild custom hacked versions of the server.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
NEWS
src/helper/startup.tcl

diff --git a/NEWS b/NEWS
index a5a5401dad78548e96d81122ce3d3c2632411165..7fe542dbe31d6d3597dbc2d7f75c224096b1f507 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ JTAG Layer:
     New reset_config options for SRST gating the JTAG clock (or not)
     TAP declaration no longer requires ircapture and mask attributes
     New "post-reset" event handler for TAP-invariant setup code
+    Overridable Tcl "init_reset" and "jtag_init" procedures
 
 Target Layer:
     New commands for use with Cortex-M3 processors:
index 229aa066f23026a81414ff678b2edc6bca73e204..b12d02bbe8ebd84719e3872c4c49195eedd58e5c 100644 (file)
@@ -134,6 +134,23 @@ proc ocd_gdb_restart {target_id} {
        reset halt
 }
 
+
+# This reset logic may be overridden by board/target/... scripts as needed
+# to provide a reset that, if possible, is close to a power-up reset.
+#
+# Exit requirements include:  (a) JTAG must be working, (b) the scan
+# chain was validated with "jtag arp_init" (or equivalent), (c) nothing
+# stays in reset.  No TAP-specific scans were performed.  It's OK if
+# some targets haven't been reset yet; they may need TAP-specific scans.
+#
+# The "mode" values include:  halt, init, run (from "reset" command);
+# startup (at OpenOCD server startup, when JTAG may not yet work); and
+# potentially more (for reset types like cold, warm, etc)
+proc init_reset { mode } {
+       jtag arp_init-reset
+}
+
+
 global in_process_reset
 set in_process_reset 0
 
@@ -189,10 +206,7 @@ proc ocd_process_reset_inner { MODE } {
 
        # Use TRST or TMS/TCK operations to reset all the tap controllers.
        # TAP reset events get reported; they might enable some taps.
-       #
-       # REVISIT arp_init-reset pulses SRST (if it can) with TRST active;
-       # but SRST events aren't reported (unlike "jtag arp_reset", below)
-       jtag arp_init-reset
+       init_reset $MODE
 
        # Examine all targets on enabled taps.
        foreach t $targets {
@@ -361,11 +375,11 @@ proc capture_catch {a} {
 }
 
 
-# Executed during "init". Can be implemented by target script 
-# tar
+# Executed during "init". Can be overridden
+# by board/target/... scripts
 proc jtag_init {} {
        if {[catch {jtag arp_init} err]!=0} {
                # try resetting additionally
-               jtag arp_init-reset
+               init_reset startup
        }
-}
\ No newline at end of file
+}