blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.24k stars 770 forks source link

SWD scan fail on RaspberryPi Pico W #1965

Closed ENAC-Robotique closed 4 days ago

ENAC-Robotique commented 5 days ago

I have trouble debugging on a RaspberryPi Pico WH. Its working fine on a RaspberryPi Pico.

Anyone having the same issue ?

When I run an SWD can on a pico it returns:

No. Att Driver
 1      RP2040 M0+
 2      RP2040 M0+
 3      RP2040 Rescue (Attach to reset) 

but on a pico W(H):

SWD scan failed!
Failed

In both cases I connected GND, SDWCLK, SWDIO and reset (RUN).

My probe is a custom one based on the native design (using STM32F103), that I use daily with STM32F4, F7,H7. I updated it with the latest master.

desertsagebrush commented 5 days ago

Just to chime in, I have no issues with main for debugging any of the Picos (normal, W), though I haven't played with my Pico 2 yet. I just retested with the two Pico Ws that I have on my desk with a native probe running v1.10.0-1318-ge7957530, compiled with arm-provided GCC 12.2.rel1 as suggested by the project, and was able to see/connect/load/debug/etc.

Do you have any other Pico W(H)s that you could test against to see if it is the specific board at fault? Another debug probe (with the same platform or different) to see if your platform has a strange issue? What compiler did you use for building your firmware image, and which cross-file/meson/makefile setup?

If you do narrow it down to something in the project itself (i.e not an out-of-tree platform or hardware issue), I'd guess that Dragonmux will ask for logs from the Black Magic Debug App (BMDA) while scanning the problematic target. If you are using meson, this will be built by default (blackmagic[.exe]) in the build directory if the dependencies are present. I suspect that she will ask for you to run it as blackmagic -tv 5 and post the full logs, but I could be wrong.

dragonmux commented 4 days ago

You are indeed completely correct in your final paragraph desertsagebrush! To the letter 😂 - until we can see why you're winding up with a scan failure it's very hard to predict what's wrong and why, but BMDA tells all for this sort of issue.

ENAC-Robotique commented 4 days ago

Problem solved! Thank you very much for your time. I did everything you said, it was not giving a lot of information, and in the end, before quitting, I tried the dumbest thing of all: switching SWDIO and SWDCLK. It worked :rage: . It seems that all documentation about the picoW is wrong. On my board, SWDCLK is on the right, SWDIO is on the left. Exactly the opposite from what is said on the official documentation https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html#raspberry-pi-pico-w-and-pico-wh

dragonmux commented 4 days ago

Glad to hear you got it figured out - the lack of scan information from BMDA is a solid indicator for such a swap of the two wires as well. Thankfully, RPi Foundation are generally pretty good about fixing things like this if you ping them a message some way or another and let them know what's wrong.