-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix for Silicon Labs RTC #5854
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
Fix for Silicon Labs RTC #5854
Conversation
How did you preload for your test? My way now seems to really mess things up! |
@chrissnow same as you wrote in the bug report...
|
@stevew817 Looks to have upset some of my mods to get EM2 in idle. some of this isn't nice but did work before. |
Actually I think it's unrelated to my changes, Just using your branch I still have issues. The simple test below doesn't like the preloading either. #include "mbed.h"
DigitalOut led(LED1, 1);
int main() {
while (true) {
led = !led;
Thread::wait(500);
}
} |
@chrissnow I tried your simple test program as a clean program with mbed-os @ the bugfix branch patched with preloading as shown earlier, and it works fine here. This was on an EFM32PG12 STK3402. I'm not sure where our differences come from? |
This commit fixes ARMmbed#5840. Fix verified by running mbed_hal-lp_ticker test suite with preloaded RTC counter such that it wrapped in the middle of the suite. Also removes explicit sleep blocking from the us_ticker implementation, since sleep blocking for us tickers is done at mbed HAL level now. This was causing one of the lp_ticker tests to fail.
ca0cd6e
to
5d6c5dd
Compare
@chrissnow Figured it out, you are defining MBED_TICKLESS for the target, which hasn't been applied on master. This was causing thread:delay to not use the rtc/lp_ticker on my end. Also figured out where I went wrong. Reading the RTC in interrupt context may involve a counter wrap without having handled the overflow interrupt yet. That's now fixed, and the implementation should work :) |
@stevew817 Looks good to me :-) I forgot that despite switching branches to get rid of my changes I needed to re export to get rid of tickless. It's a shame you removed your own sleep blocking layer, with tickless enabled any users code would take advantage of the best sleep mode at any given time it was idle. the mbed HAL locking is a major step backwards in terms of energy management on EFM32. |
We realize that the mbed HAL version of sleep blocking is less flexible, but at the same time we have to account for the rules and spirit of mbed OS, which is to provide a common-denominator abstraction such that one can effortlessly port applications across targets. mbed wants to push their implementation, so we removed our vendor-specific one. But even for tickless RTOS, which will still always set a timer to expire, we'd be stuck with EM2. Reason is the LFXO isn't available in EM3, and RAM retention goes out the window in EM4. So for the time being, I don't really see much value in resurrecting our own sleep handling to maybe allow EM3. You're welcome to try and convince me otherwise, though :) |
/morph build |
I appreciate your reasons, certainly makes sense, just a shame to lose what I found a key usability feature of the EFM32 vs other targets. My main issue with the current implementation is that it wont even go into EM2 when it is idle without modifying the idle task since it locks deep sleep, I appreciate you need to know the limitations of this but your method took care of this. EM3 and EM4 is probably not appropriate for what most mbed users want. What would have been great is if the mbed sleep manager was able to do what yours did but abstracted for targets with similar functionality. |
locks deep sleep for backward compability by default (deepsleep and systick does not play together) and only if tickless is disabled (=not supported), otherwise it would go. Once tickless is supported by target, it will go to deepsleep. |
@0xc0170 I dont think that matches my experience, or my understanding of the code mbed-os/rtos/TARGET_CORTEX/mbed_rtx_idle.cpp Lines 201 to 203 in 7be79f9
I appreciate there may be more work to do than I did to enable tickless. |
@0xc0170 That's my experience as well, the idle loop for tickless shouldn't block deepsleep unchecked before sleeping. Actually, there are various places in the mbed codebase which lock deepsleep for no apparent reason, and this prevents tickless from being very useful. Are there plans to take away those blocks? Are you waiting for a user to PR changes? |
It should not, I'll check that one.
Can you point to them? It's mostly in drivers, for those objects that operate often on high freq clocks. |
Build : SUCCESSBuild number : 875 Triggering tests/morph test |
Sure. mbed-os/platform/mbed_wait_api_rtos.cpp Line 42 in cd8e9e6
-> rtos scheduler should handle sleeping... Line 137 in 31f59b9
-> We have support for I2C in deep sleep... Actually, shouldn't all drivers leave the locking/unlocking up to the vendor? Or at least provide some configurability? |
wait API invokes us ticker there thus it locks. In this case we might want to just use there Ticker object instead that would lock automatically
We discussed this previously, that the current implementation provides generic sleep handling (covers most cases). There are peripherals that might operate in some cases, might provide full functionality or partial only. |
Agreed, since this conversation is outside of the scope of this PR.
It should be possible to do something smarter than that. You can't really mandate a us ticker running for whichever waiting period a user can supply. I can understand using a us ticker for sub-ms waits (maybe sub-100ms), but for delays larger than that, you should really be able to use the lp ticker instead. Can we get this implemented, maybe with a configurable cutoff for using us timer instead of lp timer? |
Exporter Build : SUCCESSBuild number : 546 |
Test : SUCCESSBuild number : 722 |
@stevew817 @0xc0170 @chrissnow Would y'all mind moving the discussion to it's own dedicated issue? |
@cmonr Yes I will, in the meantime there’s nothing blocking the merge ;) |
Description
This commit fixes #5840. Fix verified by running mbed_hal-lp_ticker test suite on both EFM32GG and EFM32PG12 with preloaded RTC counter such that it wrapped in the middle of the suite.
Also removes explicit sleep blocking from the us_ticker implementation, since sleep blocking for us tickers is done at mbed HAL level now. This was causing one of the lp_ticker tests to fail.
Status
READY
Migrations
NO