Skip to content
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

probe-rs run: Consider setting a breakpoint on main to synchronize RTT attach #2185

Open
Tiwalun opened this issue Feb 14, 2024 · 6 comments
Labels
component:cli enhancement New feature or request

Comments

@Tiwalun
Copy link
Member

Tiwalun commented Feb 14, 2024

probe-run does set a breakpoint on main, and attaches to RTT after that breakpoint is hit. probe-rs-cli currently tries to attach repeatedly.

I'm not sure if we consciously decided to take a different approach, so if anybody knows feel free to explain here and close this.

See https://github.com/knurling-rs/probe-run/blob/b4d99b621fc1de71cb2743fb10e015ff2905915b/src/main.rs#L311-L340

@Tiwalun Tiwalun added enhancement New feature or request component:cli labels Feb 14, 2024
@noppej
Copy link
Contributor

noppej commented Feb 14, 2024

@Tiwalun If we break on main, before the user code executes, will it not be a case of the RTT control structures have not yet been configured?

@jamesmunns
Copy link

jamesmunns commented Feb 14, 2024

I think that's a good point on the difference between defmt-rtt and rtt-target - the former is statically configured (so it will be initialized by cortex-m-rt essentially before main starts), while the latter requires an explicit init call (after main starts).

@noppej
Copy link
Contributor

noppej commented Feb 14, 2024

That is a valuable distinction. Our handling and timing of attach should follow different paths then for the two.

I suspect this distinction might answer @Tiwalun 's question about "if we consciously decided to take a different approach".

@Tiwalun
Copy link
Member Author

Tiwalun commented Feb 14, 2024

Now I'm just wondering why rtt-target actually need an explicit call 😄

@MabezDev
Copy link
Contributor

Now I'm just wondering why rtt-target actually need an explicit call 😄

rtt-target works around the possibility of the debugger polling the rtt control block before its fully constructed. It does this by writing the segger string last. However, in practice, I'm not sure this workaround is entirely relevant because I don't think anyone has ever run into it. It might not be worth implementing this workaround, and falling back to how defmt initializes the control block.

@Yatekii
Copy link
Member

Yatekii commented Feb 15, 2024

It's actually a real world issue that we run into sometimes. But maybe if we do the breakpoint procedure we can mitigate it and get something more out of it even :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:cli enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants