X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Fstartup.tcl;h=a8f78ab49f59560274362817afeded4549b33fc3;hb=70ead8ff5d2af43aa79fbc14f80fe370d569df52;hp=d68417e808efd135c5bb4d5d92ba55866effef68;hpb=fb71a0a0dddf68fa3f266aab5e35409773acc567;p=openocd.git diff --git a/src/target/startup.tcl b/src/target/startup.tcl index d68417e808..a8f78ab49f 100644 --- a/src/target/startup.tcl +++ b/src/target/startup.tcl @@ -63,8 +63,14 @@ proc ocd_process_reset_inner { MODE } { # Examine all targets on enabled taps. foreach t $targets { - if {[jtag tapisenabled [$t cget -chain-position]]} { - $t arp_examine + if {![using_jtag] || [jtag tapisenabled [$t cget -chain-position]]} { + $t invoke-event examine-start + set err [catch "$t arp_examine allow-defer"] + if { $err } { + $t invoke-event examine-fail + } else { + $t invoke-event examine-end + } } } @@ -75,7 +81,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 } } @@ -90,7 +96,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 } } @@ -103,11 +109,17 @@ 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 + } + + # don't wait for targets where examination is deferred + # they can not be halted anyway at this point + if { ![$t was_examined] && [$t examine_deferred] } { continue } - # Wait upto 1 second for target to halt. Why 1sec? Cause + # Wait up to 1 second for target to halt. Why 1sec? Cause # the JTAG tap reset signal might be hooked to a slow # resistor/capacitor circuit - and it might take a while # to charge @@ -127,7 +139,13 @@ 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 + } + + # don't wait for targets where examination is deferred + # they can not be halted anyway at this point + if { ![$t was_examined] && [$t examine_deferred] } { continue } @@ -144,10 +162,47 @@ 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. -proc armv4_5 params { - echo "DEPRECATED! use 'arm $params' not 'armv4_5 $params'" - arm $params +# Target/chain configuration scripts can either execute commands directly +# or define a procedure which is executed once all configuration +# scripts have completed. +# +# By default(classic) the config scripts will set up the target configuration +proc init_targets {} { +} + +proc set_default_target_event {t e s} { + if {[$t cget -event $e] == ""} { + $t configure -event $e $s + } +} + +proc init_target_events {} { + set targets [target names] + + foreach t $targets { + set_default_target_event $t gdb-flash-erase-start "reset init" + set_default_target_event $t gdb-flash-write-end "reset halt" + set_default_target_event $t gdb-attach "halt 1000" + } +} + +# Additionally board config scripts can define a procedure init_board that will be executed after init and init_targets +proc init_board {} { }