-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Recent LP Ticker Changes Break Tickless #7858
Comments
If you revert that commit or PR, works as expected?
👍 |
cc @c1728p9 |
I believe so but it is all a bit complicated and I went around a few circles. I'm currently trying to retrace my steps methodically in order to be sure. |
I deployed Then I deployed Above, I pointed my finger at a particular commit within Fixes for tickless and LPTICKER_DELAY_TICKS #7524 but I haven't double-checked this yet. I have a further suspicion that the hang occurs when Mbed OS deepsleeps for the first time. I.e. all of the initialisation gets done and then it hangs. |
Hi @mattbrown015 can you provide steps or an example project I can use to reproduce this failure? Also what board variant of the |
Hi @c1728p9, I think the most important nugget of info is that I'm using the RTC for my lp ticker i.e. We've created a custom target which is inherited from I don't have a cut down example for you yet but here's what I've just done:
So there was some inconsistent behaviour which is making it difficult for me to be certain of anything. I.e. why did it not work until I turned it off and on again? Once possible explanation is that flashing and resetting doesn't actually reset the RTC. I shall keep investigating for another 30 minutes and then I'm off home! :-) |
I didn't put STM32L4 in the title because I don't know that only STM32L4s are affected, but it is quite possibly a STM32L4 problem. Hence I wonder if @jeromecoutant has any comment? I notice that @jeromecoutant has made some RTC changes since adc64cc but I tried being right up to date and that doesn't work either. I've got meetings this morning but my plan is to get my NUCLEO-L433RC-P and try mbed-os-example-blinky in tickless mode using the RTC as the lp ticker. |
cc @ARMmbed/team-st-mcd |
Oh, I added Is this the correct thing to do? There's plenty of discussion about |
@mattbrown015 What's your target ? What is the current value now? |
My target is a custom target inherited from The default value of But, I am also changing So I think my question is... What is the correct |
Hi @mattbrown015 I think I was able to reproduce your issue on a To investigate this further I instrumented the ticker wrapper and looked at the signals with a logic analyzer. I found when the program locked up it was actually stuck in sleep mode. I couldn't find anything wrong with the ticker wrapper layer - the 3 cycle delay between back-to-back calls to Program which reproduces the failure: #include "mbed.h"
int main() {
uint32_t count = 0;
while (true) {
led1 = !led1;
wait(0.1);
count++;
printf("Count: %i\r\n", count);
}
} [Mirrored to Jira] |
Hi I have checked Russ program:
Note that for other targets where lpticker_lptim is 0 by default, It seems that LPTICKER_DELAY_TICKS is still not compatible with TICKLESS ? [Mirrored to Jira] |
Hi |
Hi @jeromecoutant I looked into this again, and I suspect the reason the removing the printf or setting LPTICKER_DELAY_TICKS to 0 makes this go away is because its a race condition that is highly timing dependent. By modifying the code and varying the delay time I was able to get this to fail both with LPTICKER_DELAY_TICKS=0 and with LPTICKER_DELAY_TICKS=3 when lpticker_lptim is set to 0. One thing that we saw a while back, and I noticed with this as well, is if I phsyically touch the 32KHz crystal it stops oscillating while I'm touching it. Do STM32 devices support software controlled capacitors on the clock lines? If so could the rtc backend be configuring the capacitor values differently than the lpt and thus less reliable? When you see the Code to reproduce the failure in both configurations and without printf: #include "mbed.h"
DigitalOut led1(LED1);
static void busy_delay(int cycles)
{
volatile int count = cycles;
while (count--);
}
int main() {
uint32_t count = 0;
while (true) {
led1 = !led1;
wait(0.1);
count = (count + 1) % 128;
busy_delay(count * 10000);
}
} [Mirrored to Jira] |
Its not the 32KHz stopping which is the problem. I configured the STM32L432 to output the 32KHz clock on MCO, and I don't see it stop when this failure occurs. Something else must be the cause. For reference the code I used to output the 32KHz clock on D9 is: RCC->CFGR = (RCC->CFGR & ~RCC_CFGR_MCOPRE_Msk);
RCC->CFGR = (RCC->CFGR & ~RCC_CFGR_MCOSEL_Msk) | (7 << RCC_CFGR_MCOSEL_Pos);
GPIOA->MODER = (GPIOA->MODER & ~GPIO_MODER_MODE8_Msk) | (2 << GPIO_MODER_MODE8_Pos); [Mirrored to Jira] |
I think I found the source of this problem. The rtc implementation of the low power ticker on ST devices can drop match events if they are set at the right time. This causes the device to get stuck sleeping without a wakeup source. This is more pronounced when tickless is enabled because there is no systick interrupt to wake the system if it gets stuck. The setting LPTICKER_DELAY_TICKS make this even more likely to occur, as it filters out spurious low power ticker interrupts (match interrupts which fire too early) which would normally wake the system. I created #8129 to fix this and a tests to catch regressions like this in the future. |
Perhaps I'm getting ahead of the game, the PR isn't merged yet, but... Does this mean the correct value for And, when the PR is merged I should put my |
Hi @mattbrown015, when you are using the RTC implementation (lpticker_lptim = 0) I would recommend setting The goal of After #8129 is merged the RTC implementation will work reliably with or without [Mirrored to Jira] |
Please check #8242 As explained there, I think TICKLESS mode could be enabled now with targets with lpticker_lptim set to 1. [Mirrored to Jira] |
Hi @jeromecoutant,
Oh... I need to I've got other things to worry about at the moment and I'm waiting for various PRs to merge, so it's not my most urgent concern but it will become an issue! |
Internal Jira reference: https://jira.arm.com/browse/IOTHAL-294 |
Description
I've just tried to update to today's master and it has broken my software. :-(
I'm building for STM32L4 and using tickless in RTC mode.
I suspect the problem is something to do with recent LP ticker changes.
My software runs, does its initialisation and then just appears to stop. I think it is stuck in a ticker handler.
My current theory is the problem comes from the changes made by this PR, Fixes for tickless and LPTICKER_DELAY_TICKS #7524 and, in particular, this commit Update low power ticker wrapper.
Sorry about being vague but this is a big problem for me and I wanted to get an issue created. I shall continue to investigate and try and add more detail.
Issue request type
[ ] Question
[ ] Enhancement
[X] Bug
The text was updated successfully, but these errors were encountered: