2023-05-25 05:59 AM
2023-05-25 06:03 AM
Is there a know list of issues with STM32CubeIDE in release code after power-loss reboot?
Our app is getting NaN's in the float's processing after reboot from power-down (**CCM memory is used for the floats), we've been through the code looking for the usual unitialised variables, but would be useful to know if there are any issues or things to do following a power fail.
We are locking an unlocking the RTC RAM STM32F407V on Discovery, and not seeing any RAM corruption.
We're using CMSIS DSP, this is were the issue seems to be, in this or the floating point support.
A hard reset always resolves the loss of float math. It works for a few second after power-fail reboot, but then we get NaN's occuring. Hard to debug as we can't see how to reconnect the debugger as is possible in other IDEs.
2023-05-26 08:34 AM
For CubeIDE v1.7 (I don't have the newer version handy) and STLink, to create a debug config that will connect to a running system:
You should be able to use this debug profile to connect to the running system. It MAY connect and halt the CPU, but it does not change the execution address. So you can click on "run" and the CPU will continue where it left off.
If you are using the JLink debugger, the steps are similar, but the fields in the "Debugger" tab are slightly different. But similar enough you should be able to figure them out.
2023-05-26 12:33 PM
Hi,
There is no such thing as power-loss reboot in STM32F4. You can get either a reset caused by brownout detector, or caused by watchdog, or caused by sleep/low power transition when it is disabled. Or a hardware (NRST pin) or software reset.
Otherwise there's only one power-on reset.
You can tell the reason of the last reset by bits in a special PWR register at the next start.
If some external memory makes troubles, maybe it does not receive enough power when the MCU starts too early. In this case wait until the voltage reaches the level needed by the external chip. Only then initialize it.
2023-05-26 01:00 PM
haha I mean when the user pulls the plug, sort of causes a sudden power-loss.
On powering back up the app works for 6 seconds approx., then get NaN errors on CMSIS IIR filter calls, I have verified the block size and State arrays match, input data is good, weird.
If the board is them reset manually or programatically it recovers.
Maybe I have an unitialised variable, can't find one but otherwise what could cause this???
2023-05-26 01:07 PM
Thanks Bob, that's a big help, worked immediately!
2023-05-26 05:02 PM
Does CCM have any special restrictions or conditions?
The float variables that get corrupted after a power-down then later power-up in our app are in CCM memory for faster access.
Using compiler optimisation for max speed the code that restores corrupted floats fails (in debug everything works unfortunately!), but if we compile for O3 "Most optimised", it does restore the corrupted variables and begins working again. But why would that be, random memory differences, an unitialised variable affected by the compile options???
Float processing fails a few seconds after power-up from a power-fail. But a reset while up and running restores everything perfectly.
Using CMSIS DSP filter functions, the State variables are cleared during initialisation. What's confuses is how this works in debug, works after a reset, but not from power-up.
2023-05-27 07:56 AM
Ah so there's no external memory. Well. Life is short and there's too many strange things.
If your code works well after reboot: detect the reset reason as mentioned above; if it was a pure power-on reset then do software restart (call NVIC_SystemReset).
2023-05-27 08:07 AM
If you are working on 'F407, it has a discontinuous memory (SRAM1+SRAM2, and CCMRAM are separated). Maybe you expect variables in some of the memories to be zeroed after reset, while the startup code zeros/initializes only one of the two areas.
JW
2023-05-27 10:13 AM
Yes, one day the reason will become clear... for now the hack seems to solve it, but I don't much like hacks