There appears to be a regression in the behavior of "reset halt" on the NXP
ls1021a cpu (cortex_a). On this CPU, hard reset seems to cause a shutdown of the debug
logic.
In the old code this was detected and re-initialised. In the new code that is
not the case. The consequence is that the CPU resets but does not halt.
Relevant -d3 logs are;
-d3 log of latest version
Debug: 298 35421 command.c:152 script_debug(): command - ls1020a.cpu arp_examine allow-defer
Debug: 299 35422 adi_v5_jtag.c:657 jtagdp_transaction_endcheck(): jtag-dp: CTRL/STAT 0x20
Error: 300 35422 adi_v5_jtag.c:663 jtagdp_transaction_endcheck(): Debug regions are unpowered, an unexpected reset might have happened
Error: 301 35422 adi_v5_jtag.c:668 jtagdp_transaction_endcheck(): JTAG-DP
STICKY ERROR
Error: 302 35423 cortex_a.c:2895 cortex_a_examine_first(): Could not initialize
the APB-AP
-d3 log of older version
Debug: 408 8534 adi_v5_jtag.c:621 jtagdp_transaction_endcheck(): jtag-dp:
CTRL/STAT 0x20
Error: 409 8534 adi_v5_jtag.c:627 jtagdp_transaction_endcheck(): Debug regions
are unpowered, an unexpected reset might have happened
Error: 410 8535 adi_v5_jtag.c:632 jtagdp_transaction_endcheck(): JTAG-DP STICKY
ERROR
Debug: 411 8535 arm_adi_v5.c:653 dap_dp_init(): ls1020a.dap
Debug: 412 8535 arm_adi_v5.c:698 dap_dp_init(): DAP: wait CDBGPWRUPACK
Debug: 413 8535 arm_adi_v5.h:507 dap_dp_poll_register(): DAP: poll 4, mask
0x20000000, value 0x20000000
Debug: 414 8536 arm_adi_v5.c:706 dap_dp_init(): DAP: wait CSYSPWRUPACK
Debug: 415 8536 arm_adi_v5.h:507 dap_dp_poll_register(): DAP: poll 4, mask
0x80000000, value 0x80000000
Info : 417 8797 adi_v5_jtag.c:535 jtagdp_overrun_check(): DAP transaction
stalled (WAIT) - slowing down
Debug: 418 8798 arm_adi_v5.c:888 dap_find_ap(): Found APB-AP at AP index: 1
(IDR=0x44770002)
Debug: 419 8798 arm_adi_v5.c:777 mem_ap_init(): MEM_AP Packed Transfers:
disabled
Debug: 420 8798 arm_adi_v5.c:788 mem_ap_init(): MEM_AP CFG: large data 0, long
address 0, big-endian 0
Debug: 421 8798 cortex_a.c:2706 cortex_a_examine_first(): ls1020a.cpu's dbgbase
is not set, trying to detect using the ROM table
The issue appears to be an indirect consequence of a change in target/cortex_a.c
In adi_v5_jtag.c jtagdp_transaction_endcheck() flags dap->do_reconnect when it detects
"debug regions are unpowered".
That flag is picked up by the jtag_ap_q_read() and jtag_ap_q_write() routines
via a call to jtag_check_reconnect()
In the past cortex_a_examine_first() always called dap_find_ap() which in turn
resulted in a call to jtag_ap_q_read() which detected the do_reconnect() and
all worked fine.
Now dap_find_get_ap() may or may not be called. If not called the re-connect does not
happen (or if it does its not at the right time) and hence things dont restart and we get
"Could not initialize the APB-AP".
A workaround is to restore the old behavior, but that is probably the wrong
solution.
That can be done by removing the conditional code as below in target/cortex_a.c
cortex_a_examine_first().
// if (!armv7a->debug_ap) {
// if (pc->ap_num == DP_APSEL_INVALID) {
/* Search for the APB-AP - it is needed for access to
debug registers */
retval = dap_find_get_ap(swjdp, AP_TYPE_APB_AP,
&armv7a->debug_ap);
if (retval != ERROR_OK) {
LOG_ERROR("Could not find APB-AP for debug
access");
return retval;
}
// } else {
// armv7a->debug_ap = dap_get_ap(swjdp, pc->ap_num);
// if (!armv7a->debug_ap) {
// LOG_ERROR("Cannot get AP");
// return ERROR_FAIL;
// }
// }
// }
With the above change halt appears to wor and we get;
Debug: 1085 4258170 adi_v5_jtag.c:657 jtagdp_transaction_endcheck(): jtag-dp:
CTRL/STAT 0x20
Error: 1086 4258170 adi_v5_jtag.c:663 jtagdp_transaction_endcheck(): Debug
regions are unpowered, an unexpected reset might have happened
Error: 1087 4258170 adi_v5_jtag.c:668 jtagdp_transaction_endcheck(): JTAG-DP
STICKY ERROR
Debug: 1088 4258170 arm_adi_v5.c:1120 dap_put_ap(): refcount AP#0x0 put 0
Debug: 1089 4258170 arm_adi_v5.c:1095 dap_get_ap(): refcount AP#0x1 get 7
Debug: 1090 4258170 arm_adi_v5.c:679 dap_dp_init(): ls1020a.dap
Debug: 1091 4258170 arm_adi_v5.c:711 dap_dp_init(): DAP: wait CDBGPWRUPACK
Debug: 1092 4258171 arm_adi_v5.h:642 dap_dp_poll_register(): DAP: poll 4, mask
0x20000000, value 0x20000000
Debug: 1093 4258171 arm_adi_v5.c:719 dap_dp_init(): DAP: wait CSYSPWRUPACK
Debug: 1094 4258171 arm_adi_v5.h:642 dap_dp_poll_register(): DAP: poll 4, mask
0x80000000, value 0x80000000
Info : 1095 4258432 adi_v5_jtag.c:558 jtagdp_overrun_check(): DAP transaction
stalled (WAIT) - slowing down and resending
Debug: 1096 4258433 arm_adi_v5.c:1040 dap_find_get_ap(): Found MEM-AP APB2 or
APB3 at AP index: 1 (IDR=0x44770002)
Debug: 1097 4258434 arm_adi_v5.c:826 mem_ap_init(): MEM_AP Packed Transfers:
disabled
Debug: 1098 4258434 arm_adi_v5.c:837 mem_ap_init(): MEM_AP CFG: large data 0,
long address 0, big-endian 0
Debug: 1099 4258434 cortex_a.c:2903 cortex_a_examine_first(): ls1020a.cpu's
dbgbase is not set, trying to detect using the ROM table