greiman / ChRt

ChibiOS/RT for Arduino AVR, SAMD, Due, Teensy 3.x, Teensy 4.0.
88 stars 26 forks source link

Initialization code overwrites fault handler vectors #16

Open davide-b opened 2 years ago

davide-b commented 2 years ago

In st_lld_teensy4.cpp the function setVectors() is defined, which overwrites the fault handler vectors to custom functions defined somewhere else. These functions merely blink the builtin LED with a code corresponding to the type of fault.

While this may be useful, it prevents the CrashReport class, introduced in TeensyDuino 1.54, from working properly and reporting faults. See https://www.pjrc.com/teensyduino-1-54-released/ at "Fault Recovery & CrashReport".

I think it would be useful to keep that functionality for boards that feature the iMXRT chip, like Teensy 4.0, 4.1 and MicroMod. Right now I merely commented out these four lines in setVectors()

 _VectorsRam[3] = HardFault_Handler;
 _VectorsRam[4] = BusFault_Handler;
 _VectorsRam[5] = UsageFault_Handler;
 _VectorsRam[6] = MemManage_Handler;  

and that restored the CrashReport functionality.

I'll leave it up to you to decide whether this is something that you want to support in your codebase

greiman commented 2 years ago

I will remove them or make them optional with the default disabled. They are useful for systems that don't catch bus faults.