Issue:
When the compiler option QXK_ON_CONTEXT_SW is enabled, and the "-mfloat-abi=softfp" compiler flag is set, it would result in an infinite loop in PendSV_Handler (under PendSV_restore_ex).
This happens with QP version 6.9.3 arm-cm gnu port. It was observed on STM32L4 processor.
Causes:
This instruction (under PendSV_restore_ex) alters LR:
" BLX r3 \n" / call QXK_onContextSw() /
Since the original LR (containing an EXE_RETURN value) is not preserved, it now points to the instruction after "BLX r3".
If __ ARM_FP is enabled, it will be popped from stack with:
" LDMIA r2!,{r1,lr} \n" / restore aligner and EXC_RETURN into lr /
which works fine, but not so if __ ARM_FP is disabled. Finally the return instruction causes an infinite loop:
" BX lr \n" / return to the next extended-thread /
Suggested fix:
LR is preserved correctly under the case of PendSV_restore_ao:
" PUSH {r1,lr} \n" /* save the aligner + exception lr */
" BLX r2 \n" /* call QXK_onContextSw() */
" POP {r1,r2} \n" /* restore the aligner + lr into r2 */
It should work in this case too (with r2 replaced by r3).
Thanks,
-GA
Anonymous
Thanks a lot for reporting and for suggesting workarounds. This issue will be examined for the next QP/C/C++ release 7.0.0.
--MMS
This issue has been fixed in QP/C/C++ 7.0.0rc1 just pushed to GitHub.
The applied fix saves/restores the LR around the call to
QXK_onContextSw()in the one spot that it was missing.--MMS
Fixed in the official releases: QP/C and QP/C++ 7.0.0.