raspberrypi/openocd

Upstream v0.11.0 introduced breaking change

josuah opened this issue · 2 comments

As described in https://openocd.org/doc/html/TAP-Declaration.html at 10.8 DAP declaration:

Since OpenOCD version 0.11.0, the Debug Access Port (DAP) is no longer implicitly created together with the target. It must be explicitly declared using the dap create command. For all ARMv6-M, ARMv7 and ARMv8 targets, the option "-dap dap_name" has to be used instead of "-chain-position dotted.name" when the target is created.

The result is :

$ make ocd
openocd -f interface/stlink.cfg -f target/rp2040.cfg
Open On-Chip Debugger 0.11.0-g610f137-dirty (2022-02-19-14:57)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : Could not determine executable path, using configured BINDIR.
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
/usr/local/bin/../share/openocd/scripts/target/swj-dp.tcl:30: Error: Unknown param: -dp-id, try one of: -irlen, -irmask, -ircapture, -enable, -disable, -expected-id, or -ignore-version
in procedure 'script'
at file "embedded:startup.tcl", line 26
in procedure 'swj_newdap' called at file "/usr/local/bin/../share/openocd/scripts/target/rp2040.cfg", line 8
at file "/usr/local/bin/../share/openocd/scripts/target/swj-dp.tcl", line 30
*** Error 1 in /home/josuah/Code/libzmcu/rp2040/examples (../Makefile.mk:21 'ocd')

The relevant message is : Error: Unknown param: -dp-id.

At this line:

swj_newdap $_CHIPNAME.core0 cpu -dp-id $_CPUTAPID -instance-id 0

With swj_newdap defined in "/usr/local/bin/../share/openocd/scripts/target/swj-dp.tcl" as:

proc swj_newdap {chip tag args} {
 if [using_jtag] {
     eval jtag newtap $chip $tag $args
 } elseif [using_swd] {
     eval swd newdap $chip $tag $args
 } else {
     echo "Error: transport '[ transport select ]' not supported by swj_newdap"
     shutdown
 }
}

As I understand, the flag -dp-id passed directly to swd newdap should now be passed to an extra dap create before that, as stated by https://openocd.org/doc/html/Debug-Adapter-Configuration.html at 8.3.2 SWD Transport:

The newer SWD devices (SW-DP v2 or SWJ-DP v2) support the multi-drop extension of SWD protocol: two or more devices can be connected to one SWD adapter. SWD transport works in multi-drop mode if DAP is configured with both -dp-id and -instance-id parameters regardless how many DAPs are created.

I have not a good enough understanding of OpenOCD and SWD to fix it myself at time of writing, in hope that changes some day!

Some links with related discussions on OpenOCD side:

In particular: