Skip to content

Default runner support for rpi_pico2 (OpeOCD) is missing/incomplete. #88333

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

Open
gonzolively opened this issue Apr 9, 2025 · 4 comments
Open
Assignees
Labels
area: Documentation bug The issue is a bug, or the PR is fixing a bug platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico) priority: low Low impact/importance bug

Comments

@gonzolively
Copy link

The Programming and Debugging section of the rpi_pico2 support page states that a user should be able to use OpenOcd as the default runner (e.g. west flash) in conjunction with the Raspberry Pi Debug Probe — however, that is not the case.

Steps to Reproduce

Here are the steps I followed, and the resulting error:

  1. Physically hooked up my Pico Pi Debug Probe to the appropriate pins on my Pico 2W board.
  2. Built my Zephyr application and attempted to flash via west flash.
  3. I received the following error:
-- west flash: rebuilding
ninja: no work to do.
-- west flash: using runner openocd
-- runners.openocd: Flashing file: /Users/knox/Repos/zephyrproject/build/zephyr/zephyr.hex
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
set_adapter_speed_if_not_set
Can't find target/rp2350.cfg
FATAL ERROR: command exited with status 1: /opt/homebrew/bin/openocd -s /Users/knox/Repos/zephyrproject/zephyr/boards/raspberrypi/rpi_pico2/support -s /Users/knox/zephyr-sdk-0.16.8/sysroots/arm64-pokysdk-linux/usr/share/openocd/scripts -f /Users/knox/Repos/zephyrproject/zephyr/boards/raspberrypi/rpi_pico2/support/openocd.cfg -c 'source [find interface/cmsis-dap.cfg]' -c 'source [find target/rp2350.cfg]' -c 'set_adapter_speed_if_not_set 5000' '-c init' '-c targets' -c 'reset init' -c 'flash write_image erase /Users/knox/Repos/zephyrproject/build/zephyr/zephyr.hex' -c 'reset run' -c shutdown

After quite a bit of digging around, I was able to find Raspberry Pi's OpenOCD fork, and I copied the missing config, rp2350.cfg, from that repo and placed it in the appropriate place in my current OpenOCD install. Though I got further, I still was unable to build as I received this error:

checking adapter speed...
Error: BUG: unknown adapter clock mode
adapter speed: 5000 kHz

Info : Using CMSIS-DAPv2 interface with VID:PID=0x2e8a:0x000c, serial=E663B03597613F26
Info : CMSIS-DAP: SWD supported
Info : CMSIS-DAP: Atomic commands supported
Info : CMSIS-DAP: Test domain timer 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 0x4c013477
Info : [rp2350.dap.core0] Cortex-M33 r1p0 processor detected
Info : [rp2350.dap.core0] target has 8 breakpoints, 4 watchpoints
Info : [rp2350.dap.core1] Cortex-M33 r1p0 processor detected
Info : [rp2350.dap.core1] target has 8 breakpoints, 4 watchpoints
Info : starting gdb server for rp2350.dap.core0 on 3333
Info : Listening on port 3333 for gdb connections
    TargetName         Type       Endian TapName            State
--  ------------------ ---------- ------ ------------------ ------------
 0* rp2350.dap.core0   cortex_m   little rp2350.swd         running
 1  rp2350.dap.core1   cortex_m   little rp2350.swd         running

Warn : [rp2350.dap.core1] VECTRESET is not supported on this Cortex-M core, using SYSRESETREQ instead.
Warn : [rp2350.dap.core1] Set 'cortex_m reset_config sysresetreq'.
[rp2350.dap.core0] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x00000088 msp: 0xf0000000
[rp2350.dap.core1] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x00000088 msp: 0xf0000000
Error: Incorrect RP2040 BOOT ROM version
Error: Debug trampoline not found in RP2040 ROM.
Error: auto_probe failed
auto erase enabled
FATAL ERROR: command exited with status 1: /opt/homebrew/bin/openocd -s /Users/knox/Repos/zephyrproject/zephyr/boards/raspberrypi/rpi_pico2/support -s /Users/knox/zephyr-sdk-0.16.8/sysroots/arm64-pokysdk-linux/usr/share/openocd/scripts -f /Users/knox/Repos/zephyrproject/zephyr/boards/raspberrypi/rpi_pico2/support/openocd.cfg -c 'source [find interface/cmsis-dap.cfg]' -c 'source [find target/rp2350.cfg]' -c 'set_adapter_speed_if_not_set 5000' '-c init' '-c targets' -c 'reset init' -c 'flash write_image erase /Users/knox/Repos/zephyrproject/build/zephyr/zephyr.hex' -c 'reset run' -c shutdown

Expected Behavior

  1. Set up the physical debugger
  2. Build my Zephyr application
  3. Flash using west flash
  4. The application is successfully flashed to my board.

Closing Thoughts

Seeing as the board.cmake calls for (rp2350.cfg ) in the OpenOCD arguments you'd expect it to be in the OpenOCD code-base already as no other requirements/documentation says otherwise. I'm not sure if this is an oversight where you should have mentioned grabbing the RPI OpenOCD fork, or if it worked at one time and has been pulled from the OpenOCD repos, but either way the documentation seems to be lacking.

Copy link

github-actions bot commented Apr 9, 2025

Hi @gonzolively! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

@nordicjm nordicjm added the platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico) label Apr 9, 2025
@soburi
Copy link
Member

soburi commented Apr 9, 2025

@gonzolively

Please also see https://docs.zephyrproject.org/latest/boards/raspberrypi/rpi_pico/doc/index.html#using-openocd.
I know the lack of a link to this information is something that needs to be fixed.

@kartben kartben added area: Documentation priority: low Low impact/importance bug bug The issue is a bug, or the PR is fixing a bug labels Apr 15, 2025
@soburi
Copy link
Member

soburi commented Apr 25, 2025

Fix #88827

@ajf58
Copy link
Collaborator

ajf58 commented Apr 27, 2025

I'm not sure if this is an oversight where you should have mentioned grabbing the RPI OpenOCD fork,

It's documented in the commit message that introduces this support. dae7787 . I appreciate that not everyone goes digging into commit messages, however. Yes it would be nice to update Zephyr's version of OpenOCD and also get these changes upstreamed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Documentation bug The issue is a bug, or the PR is fixing a bug platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico) priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

5 participants