Skip to content

Add picoprobe cmsis-dap support #1198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

hathach
Copy link
Contributor

@hathach hathach commented Feb 16, 2023

picoprobe have switched to use CMSIS DAP protocol in latest release

Therefore for new picoprobe implementation, openocd config now must be changes from interface/picoprobe.cfg (custom protocol) to more standard cmsis-dap protocol interface/cmsis-dap.cfg.

From latest getting started with pico

Screenshot from 2023-02-14 10-43-58

Note: even though the getting started doc does not mention, but I found that adapter speed 5000 is required, otherwise we will get Error: CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed . Check out raspberrypi/openocd#78 for detail.

With correct speed (as part of upload command), it works well and seem to be more reliably than the previous picoprobe implementation. Menu with PR chagnes

Screenshot 2023-02-16 22:13:29

/home/hathach/Arduino/hardware/rp2040/rp2040/system/openocd/bin/openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -s /home/hathach/Arduino/hardware/rp2040/rp2040/system/openocd/share/openocd/scripts -c adapter speed 5000 -c program {/tmp/arduino_build_979743/Blink.ino.elf} verify reset exit 
Open On-Chip Debugger 0.11.0-g228ede43d-dirty (2022-12-23-00:38)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : Hardware thread awareness created
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
adapter speed: 5000 kHz

Info : Using CMSIS-DAPv2 interface with VID:PID=0x2e8a:0x000c, serial=E660C06213513538
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 5000 kHz
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x00000001
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x10000001
Info : rp2040.core0: hardware has 4 breakpoints, 2 watchpoints
Info : rp2040.core1: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for rp2040.core0 on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread 
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
** Programming Started **
Info : RP2040 B0 Flash Probe: 2097152 bytes @10000000, in 512 sectors

target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
Info : Writing 53248 bytes starting at 0x0
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
** Programming Finished **
** Verify Started **
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
** Verified OK **
** Resetting Target **
shutdown command invoked

Copy link
Owner

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is great!

One additional change needs to be made, though, to get the release packaged version working right. You'll need to add a new set of sed macros to fix the platform.txt rules paths:

sed 's/^tools.picoprobe.cmd=.*//g' | \
sed 's/^#tools.picoprobe.cmd=/tools.picoprobe.cmd=/g' | \
sed 's/^tools.picotool.cmd=.*//g' | \
sed 's/^#tools.picotool.cmd=/tools.picotool.cmd=/g' | \
sed 's/^tools.picodebug.cmd=.*//g' | \
sed 's/^#tools.picodebug.cmd=/tools.picodebug.cmd=/g' | \

Also, would it make sense to add the adapter speed 5000 to the TCL file you added? That way it always takes effect?

@earlephilhower earlephilhower changed the title add picoprobe cmsis-dap support Add picoprobe cmsis-dap support Feb 17, 2023
@earlephilhower earlephilhower merged commit 060aa52 into earlephilhower:master Feb 18, 2023
@maxgerhardt
Copy link
Contributor

Very interesting. I also recently had problems when I flashed the new Picoprobe firmware and suddenly I could not upload to my target RP2040 again. Had to search for an older release to get up an running again. I will also need to pull these changes into platform-raspberrypi and state / document very clearly that the Picoprobe upload now has two possible different configurations (upload_protocol = picoprobe and upload_protocol = cmsis-dap basically), otherwise this will get very confusing.

@earlephilhower
Copy link
Owner

Would it make sense to just call it CMSIS-DAP and drop the Picoprobe portion of the name? I'm not really up on CMSIS-anything, but if this openocd script could work with any CMSIS-compliant uploader, maybe that would make it easier to distinguish?

@hathach
Copy link
Contributor Author

hathach commented Feb 21, 2023

sorry, I was busy last few days, and couldn't make changes as request. Thanks for doing that. For the tcl script, yes, I think we should add the speed selection to scrip file. However, to be honest, I haven't tried and run that script yet. I am not so sure on the syntax, please free feel to add it.

PS: the new pico debug probe from https://www.raspberrypi.com/products/debug-probe/ is based on the cmsis dap version aka this PR. So @earlephilhower may be we should just rename this to pi-debug-probe or something. I guess the amount of user that use this ready-to-use probe will increase by the time.

@earlephilhower
Copy link
Owner

No worries about the package changes, it's not something you'd know unless you delved deep into the guts of the core.

Why didn't they go with USB-C for the connector on the new board? 😞 I'm sure they had their reasons, but it's a pain now with everything else on USB-C.

The board runs the Picoprobe firmware unmodified, AFAICT, so I think the name should still be CMSIS-DAP or Picoprobe CMSIS-DAP.

I can try flashing a new board to the CMSISDAP FW and see if it's just a matter of adding the speed line to the TCL...

@earlephilhower
Copy link
Owner

Just did a quick check using the upload CMSIS command and the TCL script to start OpenOCD from the CLI (w/ #1218 added) and all seems good. Naming, we'll see if people complain :), but for now I think we're good to go.

@hathach hathach deleted the add-picoprobe-cmsis-dap branch February 22, 2023 03:31
@hathach
Copy link
Contributor Author

hathach commented Feb 22, 2023

yeah, it is a bit weird for no USB-C in 2023 board. I am glad we wrapped this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants