Using ARM coretx-M chip setGetting random INVPC hard fault exception error, while running iperf tool for measuring n/w throughput.Hard fault reg: 0x40000000
xPSR: 0x01000000
PRIMASK: 0x00000001
CONTROL: 0x00000000
Please help to find the possible root cause.
Assumed that you are using Cortex-M3/M4/M7, there are a number of possible reasons:
- corruption of EXC_RETURN during interrupt handling. This could be caused by stack corruption, or incorrectly implemented context switching code.
- corruption of stacked PSR during interrupt handling. This can lead to incorrect IPSR or ICI/IT which can both result in INVPC,
- Incorrect use of VECTCLRACTIVE bit / SCB->SHCSR that cleared the active status of an interrupt which is still running.
regards,
Joseph
Hi @Lokesh, I am running into seemingly the same issue, did you manage to solve the problem ?
Hi Joseph,
Regarding stack corruption. Could you please elaborate ? Is a workaround increasing stack size ? Are there any hints to explore this point ?
Thanks!
Yes, potentially the stack space reserved is too small, and during the execution of the interrupt handler, the EXC_RETURN was pushed to the stack, corrupted by data processing operations, and then POP back from the stack and used for exception return. In many development toolchain you can reported the stack usage of code. You need to add the stack space needed by exception handlers and stack frame to get a good estimation of total required stack space.
If you are using Keil Microcontroller Development Kit (MDK) the stack size is usually defined in the startup code. If you are using an RTOS, the RTOS would also have stack size definitions for each thread and you need to look into the documentation from the RTOS vendor to see how to control the thread's stack sizes.