-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
pendsv_nlr_jump hard faults #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have not had any issues with this. I just tried 20 times the infinite loop, and ctrl-C breaks out cleanly every time. Are you compiling with debugging (-g) enabled? |
I'm compiling with BOARD=STM32F4DISC DEBUG=1 let me try this again |
The pendsv handler is specific to the way the stack is organised. With DEBUG=1 it's probably different... |
I will test it again with and without debugging, does the crystal freq has anything to do with it ? and do I need something specific enabled in mpconfigboard ? |
I have verified that it hard faults with DEBUG=1. It's because the stack layout changes. I'll see if I can fix it. It should just work if DEBUG is not defined. No other configuration options are needed, and xtal freq is irrelevant. |
yup, it definitely faults with debugging, I've tested it twice on STM32Discovery board and my own board |
Stack layout is different when -g used, so need to handle the pendsv jump differently. Addresses Issue #315.
Okay, it's now working (for me) with DEBUG=1, and without DEBUG set. |
awesome thanks :) .. while we're at it, I noticed this:
I could be missing something here, but why not clear the interrupt char before raising the interrupt ?
|
This is not the case that needs to be fixed. The case is: a non-CTRL-C exception occurs and control goes into the exception handler. Then, just before disabling CTRL-C, the user presses CTRL-C and VCP raises that exception. This exception is not caught and will hard fault. |
Hi, sorry for digging up this old issue, but I recently tried to debug a firmware built with
In gdb I set two breakpoints on
I debugged a few boards with different GCC versions, and it seems the stack frame doesn't change when -g is used (so pc gets written at the wrong offset when PENDSV_DEBUG is defined). I tested boards with H7, F7 and F4 using GCC 7.3 and GCC 4.8 (gcc 4.8 was used around the time this issue was reported back in 2014) as you can see r12 for example is always stacked at the expected offset (sp[4]) as described in the exception stack frame: Stack frame on H743, gcc 7.3, -O0 -g:
Stack frame on F765, gcc 7.3, -O0 -g:
Stack frame on H743,gcc 4.8, -O0 -g:
Stack frame on F765, gcc 4.8, -O0 -g:
Stack frame on F427,gcc 4.8, -O0 -g:
The only logical conclusion here is that the initial assumption (that the stack frame changes with
|
* PENDSV_DEBUG causes pc to be stacked at the wrong offset. * See micropython#315 (comment)
* PENDSV_DEBUG causes pc to be stacked at the wrong offset. * See micropython/micropython#315 (comment)
* PENDSV_DEBUG causes pc to be stacked at the wrong offset. * See micropython/micropython#315 (comment)
pressing Ctrl-C hard faults... example code:
gdb backtrace
Sometimes it takes more than one try, but calling
pendsv_nlr_jump
from USB IRQ handler always faults.The text was updated successfully, but these errors were encountered: