Closed phkehl closed 6 years ago
Not sure if this is a great default. People might have redirected to an alternative output that does have some chance of working in the context of an exception. The output is likely lost anyway in a deployed device unless some method to save this output is added, a method that allows this output to be recovered on re-boot. e.g. Perhaps some extension of the 'reset reasons' state. This might be stored in the limited RTC memory where it would be inefficient to store the text output. So perhaps some hooks are need to allow these exception functions to be re-defined, or to allow alternatives to be linked, and that would address the use case that this patch addresses.
Thanks for you comments! That makes sense. I've studied the code a bit more. I found that set_user_exception_handler() lets me do what I want already. I'll close this.
Reset stdout to the default direct-to-UART handler on exceptions and abort()s. Users may have used set_write_stdout() to redirect output elsewhere, which likely isn't going to work in the exception handler.