Closed werediver closed 2 years ago
Thank you for trying it out. I had a 70% shot at it so I took it. Could you give me some details of what device and which openocd (xpack, from ST, etc.) There are so many versions of custom openocds so I want to have some idea.
I can create some logging data so we can debug in your setup why it is not working. But first, I will try to duplicate it myself with the info above.
I was trying to set up RTT for Rasperry Pi Pico / RP2040 target using another Pico with raspberrypi/picoprobe as a debugger. The picoprobe, unfortunately, is not a CMSIS-DAP compatible debugger and requires a custom raspberrypi/openocd build.
If I stop the firmware after RTT initialization and manually issue monitor rtt start
command, RTT is attached and the plug-in works as expected. Without doing this manual maneuver, though, RTT doesn't get attached, as OpenOCD is searching for a control block before the target is initialized.
I understand it's more of an OpenOCD issue, so today I tried switching to ciniml/rust-dap (a CMSIS-DAP compliant debugger running on Pico) and pyocd/pyOCD. pyOCD supports RTT (via pyocd rtt
terminal command), but monitor rtt start
doesn't work with it (https://github.com/pyocd/pyOCD/issues/1439):
60-interpreter-exec console "monitor rtt start"
-> @"Error: unrecognized command 'rtt'\n"
Error: unrecognized command 'rtt'
-> 60^done
Again, this is an issue with pyOCD and not the plug-in, unless we start talking about custom pyOCD RTT support, but that would be a topic for a separate ticket.
I could use a CMSIS-DAP debugger with the vanilla OpenOCD too, but I assume the vanilla OpenOCD has the same issue with RTT initialization.
Glad pyocd now supports RTT but support for it is not in Cortex-Debug as there were no requests and not sure how that one works. Only (latest?) OpenOCD or JLink for now.
There is no standardization on what monitor (aka. gdb-server) commands a given gdb-server supports. Anything after the word monitor is sent to the gdb-server to act on. Syntax/methods/command-set are different. In OpenOCD, it might be rtt start
but in pyOCD, it can be something totally different.
Also, CMSIS-DAP may not be related. All that needs to work is SWD and a gdb-server providing the additional service for RTT.
Also, CMSIS-DAP may not be related. All that needs to work is SWD and a gdb-server providing the additional service for RTT.
Sure, the difference CMSIS-DAP makes is with a CMSIS-DAP compliant debugger the vanilla upstream OpenOCD can be used, no outdated custom builds.
I should try a Pico with a CMSIS-DAP compliant firmware and the vanilla upstream OpenOCD.
Another possible combination is a CMSIS-DAP debugger with Black Magic Debug App. I'm inclined to try the latter first, especially given that I should receive BMP v2.3a soon.
In the meantime, I've opened https://github.com/pyocd/pyOCD/issues/1439 to check on pyOCD monitor rtt
support.
RTT is very custom and unrelated to CMSIS-DAP. RTT is a layer above basic SWD. Not many gdb-servers support it. Until recently OpenOCD didn't. Only SEGGER, the creators of RTT did it with JLink and it had nothing to do with CMSIS. RTT even works with non ARM processors.
Servers like JLink/openocd/pyocd need to know about RTT, its protocol and open TCP ports for clients to communicate with. Unrelated to CMSIS. JLink for instance only opens one port for one channel. But OpenOCD can open multiple TCP ports -- one per each channel.
You're right on everything and know more details on the debugging protocols and software than I do, but my point still holds:
Don't you agree CMSIS-DAP does make a difference? Even if unrelated directly to RTT.
I have not seen pyOCD's RTT implementation. Your issue over there may be misplaced. JLink for instance does not even need monitor rtt start
and nor does it have such a command. pyOCD implemented RTT very recently and I have not had a chance to look at it so chances of it working are near zero with our extension. And nothing to do with CMSIS -- JLink who invented this proves that you do not need CMSIS.
Anyway. If you want to work with me we can make this work with your setup.
I tried some more combinations here, but in the end I'm still interested in making RTT retry logic (rtt_start_retry
) work with OpenOCD. I'd appreciate your help.
From what I see in the log, the retry doesn't seem to ever happen (rtt_start_retry
is 1000), only the initial attempt. Below is the log filtered by "rtt":
23-interpreter-exec console "monitor rtt setup 0x2003fba0 10 {SEGGER RTT}"
24-interpreter-exec console "monitor rtt server start 60001 0"
-> @"Listening on port 60001 for rtt connections\n"
Listening on port 60001 for rtt connections
25-interpreter-exec console "monitor rtt start"
-> @"rtt: Searching for control block 'SEGGER RTT'\n"
rtt: Searching for control block 'SEGGER RTT'
-> @"rtt: No control block found\n"
rtt: No control block found
The set-up is
I suppose, I could try debugging the plug-in locally. Will take some time to figure out the process, though, because I'm not typically working with NodeJS, Electron, and JS/TS.
Looking forward for any hints, advice, or extra info requests.
On a side note. I've learned that BMP got RTT support recently (not included in v1.8.2): blackmagic-debug/blackmagic/blob/main/UsingRTT.md. I assume, Cortex Debug doesn't support RTT via BMP yet. It may be a cool future addition too 👀
Please hang on...I may have some good news shortly. We have to focus on OpenOCD. Probe/other-SW does not matter.
Can you please try this build I created manually (not published to marketplace). You have ot install it manually
https://github.com/Marus/cortex-debug/releases/tag/v1.5.6-pre1
Give me feedback. I create a launch.json to log all transactions to a file and we can enable that if it is still not working.
@haneefdm In a few tests I made, v1.5.6-pre1 worked perfectly! I tried:
runToEntryPoint
either)The plug-in manages to attach RTT in both cases.
RTT doesn't work, if I use "Run Without Debugging", but, I suppose, that's to be expected.
Thanks a lot for implementing the fix! Looking forward to the next release.
Thank you for the feedback. I will make a release (pre) soon. I need to remove some of the debug messages that are still in there.
Yes, Run Without Debugging
does not do many of the things we normally do....technically, some things are possible but require a ton of changes and may break the normal flow.
I switched to v1.5.5 (pre-release) in hope
rtt_start_retry
option can help with enabling RTT via OpenOCD automatically (stopping after RTT initialization and manually issuingmonitor rtt start
works), but it doesn't seem to have any effect.I understand this is an unstable feature, so just providing feedback.