CPU test bug in the X-CUBE-STL (gcc)
Hi, this isn't really a question, but I figured I'd share back with the community (and hopefully bring the change back into ST's next release) on the X-CUBE-STL CPU test code.
There are some instances, where the APSR has some bit set in what ARM documents as "reserved" bits. I'm not sure who/what sets them, but occasionally we see some reserved bits set after a firmware update (e.g. DFU).
The result is that the FailSafePOR() hook gets triggered, which in our case performs a NVIC_SystemReset(). After resetting, these reserved bits are cleared and will allow the system to boot properly.
I've added this extra line (with the TLK comment) in the stm32f4xx_STLcpustartGCC.s (v2.1.0) to clear out the bits.
STL_StartUpCPUTest:
MOVS R0, #0x00000000 /* Set Z(ero) Flag */
BNE.W FailSafePOR /* Fails if Z clear */
SUBS R0,#1 /* Set N(egative) Flag */
BPL.W FailSafePOR /* Fails if N clear */
ADDS R0,#2 /* Set C(arry) Flag and do not set Z */
BCC.W FailSafePOR /* Fails if C clear */
MOVS R0, #0x80000000 /* Prepares Overflow test */
ADDS R0, R0, R0 /* Set V(overflow) Flag */
BVC.W FailSafePOR /* Fails if V clear */
MOVS R0, #0xFFFFFFFF /* Prepares Saturation test */
USAT R1,#10,R0 /* Set Q(saturation) Flag */
MRS R0, APSR /* Get Status register */
AND R0, R0, #0xF8000000 /* <--------- TLK: Hack to remove stuff from reserved bits */
CMP R0, #0xB8000000 /* Verifies that N=C=V=Q=1 */
BNE.W FailSafePOR /* Fails if Q+N+C=V clear */Tom