-
Notifications
You must be signed in to change notification settings - Fork 2k
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
makefiles: Add openocd-rtt #18526
makefiles: Add openocd-rtt #18526
Conversation
Nice, works well even with a particle debugger and just SWDIO/CLK! I agree that --- a/makefiles/tools/serial.inc.mk
+++ b/makefiles/tools/serial.inc.mk
@@ -19,6 +19,10 @@ PROG_DEV ?= $(PORT)
export BAUD ?= 115200
+ifneq (,$(filter stdio_rtt,$(USEMODULE)))
+ RIOT_TERMINAL ?= openocd-rtt
+endif
+
RIOT_TERMINAL ?= pyterm
ifeq ($(RIOT_TERMINAL),pyterm)
TERMPROG ?= $(RIOTTOOLS)/pyterm/pyterm would be more ergonomic - I had no idea about |
Once we go for the more ergonomic default sizes, I'd also introspect the PROGRAMMER -- if it's jlink, RIOT_TERMINAL should become jlink-rtt instead. (I'd start from the diff you showed in a next iteration after this is through). In the meantime I've found out the numbers: They're a start and length of memory to search for the magic string (provided in the argument) in. I'm a bit conflicted about how to best fill them in: My default mode is pedantic, for which I'd pick the |
I love this one. Other than the ergonomic defaults, this looks ready for merge, right? |
I think yes -- I didn't merge it because the second commit (which addresses the hardcoded numbers that were there before) wasn't part of the original ACK, and touches a few more places. If you're happy with that, please bring it ahead :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK. Looks good to me and has already been tested. IMO you could squash the two commits. If you don't feel like squashing, you may hit merge instead.
JLink presumably has information about the device's RAM available internally. Not passing the precise symbol area (which would be available in the ELF file) because a) that'd make the terminal break when the flashed firmware does not equal the built one, and b) that would introduce a dependency from `term` to the ELF file that other terminals don't have.
Squashed without code changes after a successful run, setting the "skip build" flag. |
Contribution description
The RTT mechanism, by which a debugger emulates a serial interface, has been invented and described by Segger (creator of JLink), but was so far only available through their own JLink program. As the same interface is also implemented by OpenOCD, it can be used with that and thus any debug adapter (eg. STLink).
Open issues
Testing procedure
microbit-v2
, and an example that has nice shell (eg.saul
)make -C examples/saul BOARD=microbit-v2 all flash term
Issues/PRs references
This is based on the existing code in jlink.sh, and notes from @nica-f.
Future steps
openocd.sh
and between it andjlink.sh
.Both of these are probably doable in shell and Makefile, but IMO too complex to be done there well and maintainably -- so some duplication it is for now, as it has been for some time.
stdio_
modules. As this would also affectstdio_acm
(in which case it'd influence MOST_RECENT_BOARD selectors as in makefiles/tools/serial.inc.mk: Improve PORT selection when RIOT's USB CDC ACM is used for stdio #18525), I think that's better done in a follow-up step.