-
Notifications
You must be signed in to change notification settings - Fork 747
segger_rtt: mark allocated struct as _SEGGER_RTT
in ELF
#4124
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
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.
This looks good to me. I don't like the code duplication in the static_buf
macro, but it'd probably be even more confusing if we tried to split this out in another macro or recursively invoke itself to generate the second half of the expression.
kernel/src/utilities/static_init.rs
Outdated
// initialized. | ||
&mut BUF.0 | ||
}}; | ||
($T:ty, $N:expr) => {{ |
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.
($T:ty, $N:expr) => {{ | |
($T:ty, $N:expr $(,)?) => {{ |
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.
Oh yes!
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.
I think this should be a new macro that can be documented as to what the second parameter is and when it should be used. Macros are hard to document as it is, and the static_X infrastructure is fairly confusing already. This seems like a very niche use case and since we are already copying the macro I think it makes sense to not change the existing static_buf
macro.
For posterity, if you like me were wondering how this worked already, the standard way that host-side tools find the RTT buffer is by looking for a sentinel in RAM. However, it does seem that Segger does suggest using the symbol |
Come to think of it, in concept this is somewhat similar to
I don't know whether it could be combined with |
I will note that |
This is a de-facto standard for tools that interact with Segger RTT that allows them to find the shared memory buffer in the ELF
@bradjc @alexandruradovici @lschuermann revised to be a separate macro (that also fixes the syntax parsing error @alexandruradovici noticed). Suggestions on the documentation for the macro are welcome, I'm not sure how or what to say about how to use this beyond "it adds an export name". |
…y of `static_named_buf` Co-authored-by: Brad Campbell <bradjc5@gmail.com>
Pull Request Overview
This PR adds an ELF section name to the statically allocated Segger RTT struct to marking for tools on the host where to find that memory. This is a de-facto standard for tools that interact with Segger RTT that allows them to find the shared memory buffer in the ELF. For example,
probe-rs
uses this.Testing Strategy
Running
probe-rs run --chip nRF52840_xxAA target/thumbv7em-none-eabi/release/sma_q3
with an sma_q3 connected and watch for the Segger RTT output.TODO or Help Wanted
N/A
Documentation Updated
/docs
, or no updates are required.Formatting
make prepush
.