tcl: introduce using_(jtag|swd|hla) helpers and use them in reset handler 03/2003/8
authorPaul Fertser <fercerpav@gmail.com>
Sat, 1 Mar 2014 18:40:54 +0000 (22:40 +0400)
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>
Sat, 28 Jun 2014 09:28:12 +0000 (09:28 +0000)
Barely tested with plain SWD transport.

Change-Id: I48b59136bf4294ffed737dba01f1b30ef83aa86b
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2003
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
14 files changed:
src/jtag/startup.tcl
src/target/startup.tcl
tcl/target/1986ве1т.cfg
tcl/target/at91sam3XXX.cfg
tcl/target/at91sam4XXX.cfg
tcl/target/lpc17xx.cfg
tcl/target/mdr32f9q2i.cfg
tcl/target/stm32f1x.cfg
tcl/target/stm32f2x.cfg
tcl/target/stm32f3x.cfg
tcl/target/stm32f4x.cfg
tcl/target/stm32l.cfg
tcl/target/stm32w108xx.cfg
tcl/target/swj-dp.tcl

index 4153118c3a68ad2b8c0ecbce4ead0bfc485d8aff..94590e13389807fa98d8867fe3825b320c2b9056 100644 (file)
@@ -21,7 +21,9 @@ proc jtag_init {} {
 # 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
+       if {[using_jtag]} {
+               jtag arp_init-reset
+       }
 }
 
 #########
index 033e9c9cfe10a95e1fdb21c811e11ca5463ddf31..cf2813ba856fc440aba78dca884baf00ee794b7f 100644 (file)
@@ -63,7 +63,7 @@ proc ocd_process_reset_inner { MODE } {
 
        # Examine all targets on enabled taps.
        foreach t $targets {
-               if {[jtag tapisenabled [$t cget -chain-position]]} {
+               if {![using_jtag] || [jtag tapisenabled [$t cget -chain-position]]} {
                        $t invoke-event examine-start
                        set err [catch "$t arp_examine"]
                        if { $err == 0 } {
@@ -79,7 +79,7 @@ proc ocd_process_reset_inner { MODE } {
        }
        foreach t $targets {
                # C code needs to know if we expect to 'halt'
-               if {[jtag tapisenabled [$t cget -chain-position]]} {
+               if {![using_jtag] || [jtag tapisenabled [$t cget -chain-position]]} {
                        $t arp_reset assert $halt
                }
        }
@@ -94,7 +94,7 @@ proc ocd_process_reset_inner { MODE } {
        }
        foreach t $targets {
                # Again, de-assert code needs to know if we 'halt'
-               if {[jtag tapisenabled [$t cget -chain-position]]} {
+               if {![using_jtag] || [jtag tapisenabled [$t cget -chain-position]]} {
                        $t arp_reset deassert $halt
                }
        }
@@ -107,7 +107,7 @@ proc ocd_process_reset_inner { MODE } {
        # first executing any instructions.
        if { $halt } {
                foreach t $targets {
-                       if {[jtag tapisenabled [$t cget -chain-position]] == 0} {
+                       if {[using_jtag] && ![jtag tapisenabled [$t cget -chain-position]]} {
                                continue
                        }
 
@@ -131,7 +131,7 @@ proc ocd_process_reset_inner { MODE } {
        #Pass 2 - if needed "init"
        if { 0 == [string compare init $MODE] } {
                foreach t $targets {
-                       if {[jtag tapisenabled [$t cget -chain-position]] == 0} {
+                       if {[using_jtag] && ![jtag tapisenabled [$t cget -chain-position]]} {
                                continue
                        }
 
@@ -148,6 +148,21 @@ proc ocd_process_reset_inner { MODE } {
        }
 }
 
+proc using_jtag {} {
+       set _TRANSPORT [ transport select ]
+       expr { [ string first "jtag" $_TRANSPORT ] != -1 }
+}
+
+proc using_swd {} {
+       set _TRANSPORT [ transport select ]
+       expr { [ string first "swd" $_TRANSPORT ] != -1 }
+}
+
+proc using_hla {} {
+       set _TRANSPORT [ transport select ]
+       expr { [ string first "hla" $_TRANSPORT ] != -1 }
+}
+
 #########
 
 # Temporary migration aid.  May be removed starting in January 2011.
index 0338297a8d6c88a173594a43bf5b976396b3594f..c76a211136ef7f8a94a2c8f1d602d00523cc054a 100644 (file)
@@ -48,7 +48,7 @@ if { [info exists IMEMORY] && [string equal $IMEMORY true] } {
 adapter_khz 1000
 
 adapter_nsrst_delay 100
-if {$using_jtag} {
+if {[using_jtag]} {
    jtag_ntrst_delay 100
 }
 
index f36475b6d46ec754397167f294a13644f9f96af0..caadc5361cf96dc4359f33b384fc968229c5e66e 100644 (file)
@@ -76,7 +76,7 @@ $_TARGETNAME configure -event gdb-flash-erase-start {
 adapter_khz 500
 
 adapter_nsrst_delay 100
-if {$using_jtag} {
+if {[using_jtag]} {
    jtag_ntrst_delay 100
 }
 
index cc2941a8198f7550753ffb36676d8304fbc07daa..1570114049adea21de211448473c888676b38f5a 100644 (file)
@@ -56,7 +56,7 @@ $_TARGETNAME configure -event gdb-flash-erase-start {
 adapter_khz 500
 
 adapter_nsrst_delay 100
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag_ntrst_delay 100
 }
 
index 372107f7d4473897aef9f58745382f35f6ae5d3d..266cecb61b666ab40684cc17655734bd4c98911a 100644 (file)
@@ -72,7 +72,7 @@ adapter_khz 10
 
 # delays on reset lines
 adapter_nsrst_delay 200
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag_ntrst_delay 200
 }
 
index 8e8262d7611e531ced1ce9ad1d574c5363f3d742..961451e0b6e54fceddd54f5a3435da16fdd185aa 100644 (file)
@@ -46,7 +46,7 @@ if { [info exists IMEMORY] && [string equal $IMEMORY true] } {
 adapter_khz 1000
 
 adapter_nsrst_delay 100
-if {$using_jtag} {
+if {[using_jtag]} {
    jtag_ntrst_delay 100
 }
 
index f32654a57abf41ac27e3dc225ac2a4353836784d..c89a5b55e27f05f924cdc7b67c73ccf07d52b01a 100644 (file)
@@ -61,7 +61,7 @@ if { [info exists BSTAPID] } {
   set _BSTAPID9 0x06428041
 }
 
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
        -expected-id $_BSTAPID2 -expected-id $_BSTAPID3 \
        -expected-id $_BSTAPID4 -expected-id $_BSTAPID5 \
@@ -82,7 +82,7 @@ flash bank $_FLASHNAME stm32f1x 0x08000000 0 0 0 $_TARGETNAME
 adapter_khz 1000
 
 adapter_nsrst_delay 100
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag_ntrst_delay 100
 }
 
index 5022ef7dbd18dbe1c64197a32e1f8ce34398256d..4e43f0a1a0ae8ec92ea2b8ad5384f2d39f73dd4d 100644 (file)
@@ -34,7 +34,7 @@ if { [info exists WORKAREASIZE] } {
 adapter_khz 1000
 
 adapter_nsrst_delay 100
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag_ntrst_delay 100
 }
 
@@ -58,7 +58,7 @@ if { [info exists BSTAPID] } {
   set _BSTAPID 0x06411041
 }
 
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID
 }
 
index 3d68c4bfbafe657d5453fbb8edb0bf2c58001a83..ec5941bdef51b3383abd786ed8722abeaa4fb5d9 100644 (file)
@@ -34,7 +34,7 @@ if { [info exists WORKAREASIZE] } {
 adapter_khz 1000
 
 adapter_nsrst_delay 100
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag_ntrst_delay 100
 }
 
@@ -58,7 +58,7 @@ if { [info exists BSTAPID] } {
   set _BSTAPID2 0x06432041
 }
 
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 -expected-id $_BSTAPID2
 }
 
index feca77c7bf77960bc93d9ccbe1fafb8995ea5997..30ec686ca0924986dc56a91aa63d8dada41e9e0c 100644 (file)
@@ -47,7 +47,7 @@ if { [info exists BSTAPID] } {
   set _BSTAPID2 0x06419041
 }
 
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
        -expected-id $_BSTAPID2
 }
@@ -69,7 +69,7 @@ flash bank $_FLASHNAME stm32f2x 0 0 0 0 $_TARGETNAME
 adapter_khz 1000
 
 adapter_nsrst_delay 100
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag_ntrst_delay 100
 }
 
index f9f7425b9a7bb9925a21b9921710e908220b176e..5d6a53e0b95cdcc8283425c1e219ec8c87763974 100644 (file)
@@ -30,7 +30,7 @@ if { [info exists WORKAREASIZE] } {
 adapter_khz 100
 
 adapter_nsrst_delay 100
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag_ntrst_delay 100
 }
 
@@ -54,7 +54,7 @@ if { [info exists BSTAPID] } {
   set _BSTAPID 0x06416041
 }
 
-if {$using_jtag} {
+if {[using_jtag]} {
  jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID
 }
 
index 4bc51fc0496aaaf625925da3c505e46ae2d43fb1..faea0d8229de7d2793fb89fdd27d00931b6e0a41 100644 (file)
@@ -38,7 +38,7 @@ if { [info exists ENDIAN] } {
 
 swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
 
-if {$using_jtag} {
+if {[using_jtag]} {
  if { [info exists BSTAPID] } {
    set _BSTAPID $BSTAPID
    jtag newtap $_CHIPNAME bs -irlen 4 -ircapture 0xe -irmask 0xf -expected-id 0x269a862b
index fa44583a436fb1f2e6e3614252833f89ef035e1d..bd348e6611a4b6e178e110b312079f1e29288ecc 100644 (file)
 # split out "chip" and "tag" so we can someday handle
 # them more uniformly irlen too...)
 
-global using_jtag
-set using_jtag 1
-
 proc swj_newdap {chip tag args} {
- global using_jtag
- set tran [transport select]
- if [string equal $tran "jtag"] { eval jtag newtap $chip $tag $args; set using_jtag 1 }
- if [string equal $tran "swd"] { eval swd newdap $chip $tag $args; set using_jtag 0 }
- if [string equal $tran "cmsis-dap"] { eval cmsis-dap newdap $chip $tag $args; set using_jtag 0 }
+ if {[using_jtag]} { eval jtag newtap $chip $tag $args }
+ if {[using_swd]} { eval swd newdap $chip $tag $args }
+ if {[string equal [transport select] "cmsis-dap"]} { eval cmsis-dap newdap $chip $tag $args }
 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)