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

Wake sleeping CPU on RTT write? #145

Open
esky-software opened this issue Mar 8, 2025 · 2 comments
Open

Wake sleeping CPU on RTT write? #145

esky-software opened this issue Mar 8, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@esky-software
Copy link

Writing to RTT downlink when the CPU is sleeping in WFI does not wake the CPU.
In some circumstances this would be nice to have happen.

AFAICT waking the CPU requires a 'debug event', which background memory access is not.
Ideally such an event could be generated without halting the CPU, but I don't see any obvious way to do this.
So I guess just a halt & continue after the RTT write would be sufficient.

Adding this as an optional capability would be very handy.

@rgrr
Copy link
Owner

rgrr commented Mar 10, 2025

Interesting idea. One could also think about sending a debug event if the RTT up buffer is read via DAP.

In the "Armv8-M Architecture Reference Manual" one can read under "B2.1.1 The Wait for Event (WFE) instruction" about WFE wakeup events:

  • ...
  • If debug is enabled, a debug event.
  • ...

If you continue reading about WFI wakeup, it is much more complex.

So I'm wondering why you intend to use WFI?

And also, what is the use case for your idea? If you have a look at Seggers RTT read/write, you can find blocking operations which do an active wait. TMO while the debug IF is active, current is no actual limitation.

@esky-software
Copy link
Author

My use case is that I'm using RTT as a debug terminal, which means I can't sleep indefinitely - I need to wake periodically to check for RTT data.

It's a minor annoyance, but one that can be easily fixed with this feature.

I agree that generating a debug event after uplink read also sounds good. I'd suggest that these be enabled/disabled independently.

WFI vs WFE is an interesting question, especially since so much of their details are implementation-specific. After combing the armv6m and armv8m manuals and the rp2040 and rp2350 datasheets and corralling all the snippets of information scattered through them, I've come to the conclusion that Arm's intention is for WFE to stop the processor but not much else, and WFI to also trigger low-power modes in surrounding subsystems. But I've never found a satisfactory explanation of the whole deal. (Probably not too hard to test for any specific processor though.)

BTW I'm currently working with rp2040.

@rgrr rgrr added the enhancement New feature or request label Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants