2015-10-30 11:01 AM
Hello,
since a week, I always get a HardFault in the line ''bx R14'' of the FreeRTOS 8.2.2 assembler routine vPortSVCHandler on a STM32F103zg. ''Attempt to do exception with bad value in EXEC_RETURN number (INVPC)'' I think it is related to the value of PSP at that moment (0x64006420), which is the location of the stack of the IDLE task. I have relocated the entire task heap to the ''External RAM'' region. When I place the heap in the SRAM region instead, the exception doesn't occurs. The downside is, I don' have enough memory in the SRAM region for the entire heap. My problem is, I have relocated the heap to the External RAM more then a year ago and now out of nowhere I get that fault. Also the same works with a STM32F429zg very fine. In the ARM reference manual, I can't find a difference between both MCU generations regarding the memory region. In both there is no mention like the SRAM ''You can also put code here.''. So, is the PSP really the cause of my fault?2015-10-30 11:11 AM
Heap != Stack
A suitably coded allocator can pull from multiple pools. External memory is significantly slower than internal memory. Stacks in external memory will slow ALL execution. Allocate stack from the fastest memory available. The FSMC can generate faults, or more specifically the lack of decoding for a specific address can cause a fault. Like -DACK on the old 68000 processors, acknowledging a specific address has data behind it. Look at exactly what is faulting, the instruction, and the registers it's acting upon. If the external memory is flaky, and you're using it for the stack, failures will be more apparent as you're constantly reloading the PC from it.