-
Notifications
You must be signed in to change notification settings - Fork 2.1k
stdio_semihosting: Initial include of Semihosting-based STDIO #13320
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
Conversation
1e7dc10
to
26d1b97
Compare
Hm, how does this work? Segger J-Link
edbg on samr21-xpro
|
😢 I'll check if I forgot something |
@benpicco on the samr21-xpro I can reproduce your issue. However if I restart the node from the OpenOCD session it somehow starts working. I'll see if I can make this work without having to restart the node. |
/* Moves cmd and args to r0 and r1. Then triggers a breakpoint. | ||
* Finally moves the results stored in r0 to result | ||
*/ | ||
__asm( |
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.
__asm( | |
__asm__( |
@@ -0,0 +1,103 @@ | |||
/* |
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.
do these defines need to be exported? If not, it is fine to define them in stdio_semihosting.c.
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.
Done!
ssize_t stdio_read(void* buffer, size_t count) | ||
{ | ||
if (STDIO_SEMIHOSTING_RX) { | ||
ssize_t read = 0; |
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.
please rename variable. Somehow my brain doesn't shadow read()
as happily as the C compiler, especially in stdio context.
Hm, this doesn't come with an automatic test, but I guess that's difficult? If so, we should at least blacklist it for all workers and add a comment. |
offline discussion, result: please add README.md. |
Added a very concise readme |
@bergzand can you rebase this one? |
3b66345
to
75e378f
Compare
Rebased! |
You also seemed to have addressed a couple of the commetns I was going to make hahaha :D |
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.
Some comments, I'll test asap.
* `RIOT_TERMINAL` variable has to be set to `semihosting`: | ||
* | ||
* ``` | ||
* make term RIOT_TERMINAL=semihosting |
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.
You didn't add this to Makefile.include
because of inclusion order right?
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.
You mean to automatically setting the RIOT_TERMINAL
based on whether stdio_semihosting
is enabled? I honestly haven't tried it :D
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.
It would work if USEMODULE
is passe by the user or in the APPLICATION
but not in a BOARD
configuration, which kind of sucks.
It is indeed slow but works like a charm.
|
Hmm I checked the output with more details and there is:
|
I do not get the timeout on a |
I do not have anymore comments here you can squash if @kaspar030 feels like his comments have been addressed as well! |
0c0f593
to
11ee5ff
Compare
Squashed |
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 on my side.
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 from me, too.
Thanks! |
Contribution description
This PR adds ARM Semihosting-based STDIO capabilities. It allows STDIO over SWD/JTAG, similar to the Segger RTT protocol, but without requiring the proprietary Jlink binaries or a Jlink programmer to function. Only ARM MCUs are supported (but I've heard rumors that RISC-V has something similar). The big downsides are that Semihosting is relative slow and that it requires an active debugging session (at all times) when it is enabled. This last bit because it throws breakpoint instructions for write and read requests from the host.
Currently the terminal used is OpenOCD in debugger mode. Maybe this can be refined at some point by not halting the CPU when starting the terminal, but that's for later.
Testing procedure
I haven't tested it with pyOCD. It is probably also possible to use pyOCD for this, but that can be included in a follow-up PR.
Issues/PRs references
None