Hello,
I've noticed that when I use "reset halt" on an ARM64 target (iMX8m), I'm
seeing SRST asserted twice in ocd_process_reset_inner (src/target/startup.tcl).
The first time is in the call to init_reset. The default implementation calls
init_reset from src/jtag/startup.tcl which calls jtag arp_init-reset. This
invokes jtag_init_reset from jtag/tcl.c and asserts the SRST signal. The
comments from ocd_process_reset_inner say that it should perform a TRST:
# Use TRST or TMS/TCK operations to reset all the tap controllers.
# TAP reset events get reported; they might enable some taps.
init_reset $MODE
The comments in jtag_init_reset in jtag/core.c explain some of the history of
why it's complicated and SRST can be asserted.
The second SRST assertion comes from later in ocd_process_reset_inner where
arp_reset assert $halt is invoked for each active target:
# Assert SRST, and report the pre/post events.
# Note: no target sees SRST before "pre" or after "post".
foreach t $targets {
$t invoke-event reset-assert-pre
}
foreach t $targets {
# C code needs to know if we expect to 'halt'
if {![using_jtag] || [jtag tapisenabled [$t cget -chain-position]]} {
$t arp_reset assert $halt
}
}
The second comment at the beginning is false as init_reset will assert the SRST
line before it reaches this line.
I can resolve this for my case by providing a reset_init override function in a
board config file that replaces jtag arp_init-reset with jtag arp_init:
proc init_reset { mode } {
if {[using_jtag]} {
jtag arp_init
}
}
However, doing this across OpenOCD would break the "init" handling where if
jtag arp_init fails in jtag_init (src/jtag/startup.tcl), it calls init_reset to
perform a hard reset. It seems to me that a way of resolving this is to have
init_reset inspect the unused "mode" parameter. Three values come from the
reset command: halt, init, and run, jtag_init uses "startup". But the mode
parameter doesn't imply the reset type, so this would probably make things
worse.
Would it be better to replace the call to init_reset in ocd_process_reset_inner
with jtag_init for JTAG debug devices? Or is the following comment in
jtag_init_reset that says it should eventually be replaced by tcl script code
still the path forwards?
* REVISIT once Tcl code can read the reset_config modes, this won't
* need to be a C routine at all...
Neil Shipp
[email protected]