How to deal with hardfaults #16992
Unanswered
jotamudo
asked this question in
Core Development
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello guys,
Last month I was working on some company internal tools, and while writing a C usermodule to interface an external library had faced quite a lot of hard faults while refactoring the code (if there's any suggestion for testing with the gc and upy objects at play I'm very much open to any ideas!). The board we work on is an extension board for a pyboard sf2w, so no dice with SWD on runtime (tried for 2 weeks to connect a jlink without success), so I ended up following the ideas of both of these articles:
And both modified the linkerscript of the board to reserve a special region to store that small cpu context on board restarts so I could retrieve and reason where I was. I did notice that on the STM32's port there's a hardfault handler prepared to spit out some data to the UART (that did not work on my case in anytime I tried). I also made a very small usermodule to retrieve that information later on the micropython REPL (not open-sourced yet but planning to do so this weekend) which I then used to find where the CPU had crashed on using gdb on the compiled firmware image.
I may have gone orthogonal to the orthodox way of solving these kinds of crashes, in which case I'd love for suggestions for the proper way, but isn't such a case an interesting feature to have in the firmware on debug mode?
Beta Was this translation helpful? Give feedback.
All reactions