Hard fault when exiting stop mode with RTC alarm on STM32F051
Moderator: RoccoMarco
Re: Hard fault when exiting stop mode with RTC alarm on STM32F051
There is already one nop after wfi, if I add another one - nothing changes, the program still crash and still in the middle of the bl, but if I add 3 or more nops, or remove all of them - program stops crashing. The function call seems to be important in the reproduction of this crash, I firstly tried to move __disable_irq() directly in the body of the waiting loop, but with that the crash is also disappears, no matter how many nops I add around it, so I moved it in its own noinline function.
Re: Hard fault when exiting stop mode with RTC alarm on STM32F051
Tried this on the STM32F318K8U6 board and there everything works fine, without hard faults. I can not be 100% sure though, the problem is tricky to reproduce, with all these nops in the right places, maybe I just did not made the timing right.
Re: Hard fault when exiting stop mode with RTC alarm on STM32F051
I have reproduced this problem without chibios, using STM32 HAL and STM32CubeIDE 1.0.2, it also turned out that the function call is unnecessary for reproduction and I further simplified RTC_Wait:
Now the hard fault happens at the address 8000e24, and there is actually no instructions at all!
Now it really looks like a hardware bug, it seems as if the execution continues from the wrong address.
If someone is interested in reproducing this my full STM32CubeIDE project is in the attachment.
Code: Select all
void RTC_Wait()
{
nop();
//nop();
lexit=0;
PWR->CR|=PWR_CR_LPDS; // enter stop mode
SCB->SCR|=SCB_SCR_SLEEPDEEP_Msk; //
while(1)
{
nop();
__disable_irq();
if(lexit)
{
__enable_irq();
break;
}
__WFI();
nop();
//nop();
__enable_irq();
}
SCB->SCR&=~SCB_SCR_SLEEPDEEP_Msk;
}
Now the hard fault happens at the address 8000e24, and there is actually no instructions at all!
Code: Select all
8000e16: bf30 wfi
8000e18: 46c0 nop ; (mov r8, r8)
8000e1a: b662 cpsie i
8000e1c: e7f0 b.n 8000e00 <RTC_Wait+0x1c>
8000e1e: 46c0 nop ; (mov r8, r8)
8000e20: 20000020 .word 0x20000020
8000e24: 40007000 .word 0x40007000
8000e28: e000ed00 .word 0xe000ed00
Now it really looks like a hardware bug, it seems as if the execution continues from the wrong address.
If someone is interested in reproducing this my full STM32CubeIDE project is in the attachment.
- Attachments
-
- stopModeBug1.zip
- (3.37 MiB) Downloaded 352 times
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Hard fault when exiting stop mode with RTC alarm on STM32F051
Hi,
I would try to post this on the ST forum, it is possible they already handled this problem. Of course we would be interested in hearing the solution of this mystery
Giovanni
I would try to post this on the ST forum, it is possible they already handled this problem. Of course we would be interested in hearing the solution of this mystery
Giovanni