Skip to content

BMDA: RP2040 does not connect via dap42 (CMSIS-DAP) adapter #1370

@dmsc

Description

@dmsc

Trying to debug a RP2040 MCU with the dap42 debugger, via CMSIS-DAP interface, the SWD scan fails:

(gdb) tar ext :2000
Remote debugging using :2000
(gdb) mon s        
Exception: SWDP invalid ACK
SW-DP scan failed!
Failed

Problem is with target selection after a forced error, at the end of the log file:

 command: 06 00 04 00 0f 
response: 06 04 00 01 0d 00 00 00 10 00 00 00 05 00 00 00 b1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
dap_mem_read transferred 4 blocks
ap_memread @ e00ffff0 len 16: 0d 00 00 00 10 00 00 00 05 00 00 00 b1 00 00 00
dap_swd_dp_error (protocol recovery? false)
-> dap_swj_sequence (64 cycles)
 command: 12 40 ff ff ff ff ff ff ff 0f 
response: 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 command: 05 00 01 02 
response: 05 01 01 77 24 c1 0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
        dap_read_reg 00 0bc12477
        dap_write_reg 0c 01002927
 command: 05 00 01 0c 27 29 00 01 
response: 05 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
dap_write_reg 0c data 01002927:fault
 command: 05 00 01 06 
response: 05 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

The code is at cmsis_dap.c, line 282:

static uint32_t dap_swd_dp_error(adiv5_debug_port_s *dp, const bool protocol_recovery)
{
	DEBUG_PROBE("dap_swd_dp_error (protocol recovery? %s)\n", protocol_recovery ? "true" : "false");
	if (dp->version >= 2 || protocol_recovery) {
		/* On protocol error target gets deselected.
		 * With DP Change, another target needs selection.
		 * => Reselect with right target! */
		dap_line_reset();
		dap_read_reg(dp, ADIV5_DP_DPIDR);
		dap_write_reg(dp, ADIV5_DP_TARGETSEL, dp->targetsel);
		/* Exception here is unexpected, so do not catch */
	}

The line with dap_write_reg(dp, ADIV5_DP_TARGETSEL, dp->targetsel); fails, as the probe returns error 7 = NO_ACK (no response from target). Note that from the reset all read and write commands fail.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BMD AppBlack Magic Debug App (aka. PC hosted) (not firmware)BugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions