Can somebody tell me how to catch a crashing program on the FE310? My code is crashing around some function accessing the RTC and dealing with the PLIC as well. I would like gdb to stop the execution when that happens so I can do a bt to find out where it happened. What is the best way to do this? Where do I find some resources around debugging?
I’ve not get to try it yet on the FE310 but it should work in similar way to how you can debug a hard fault on a Cortex-M device. The basic idea is that in case of any exception (also a hard fault) certain registers as well as the address of the offending instruction is put onto the stack. By putting a breakpoint into the exception handler and then examining the stack content one can discover the address of the instruction triggering the exception.
A excellent write-up how to perform this technique for Cortex-M is written up here. The concept should be applicable to FE310 too. Please let me know how this works for you, it’s smth I’ve wanted to try for some time but did not yet get to it.