retro-go/tools/patches/esp-idf-4.0-panic-hook.diff

33 lines
1.1 KiB
Diff

--- a/components/esp32/panic.c
+++ b/components/esp32/panic.c
@@ -65,10 +65,15 @@
#if !CONFIG_ESP32_PANIC_SILENT_REBOOT
//printf may be broken, so we fix our own printing fns...
+void __attribute__((weak)) esp_panic_putchar_hook(char c)
+{
+ // nothing
+}
static void panicPutChar(char c)
{
while (((READ_PERI_REG(UART_STATUS_REG(CONFIG_ESP_CONSOLE_UART_NUM)) >> UART_TXFIFO_CNT_S)&UART_TXFIFO_CNT) >= 126) ;
WRITE_PERI_REG(UART_FIFO_REG(CONFIG_ESP_CONSOLE_UART_NUM), c);
+ esp_panic_putchar_hook(c);
}
static void panicPutStr(const char *c)
@@ -160,9 +165,11 @@ static __attribute__((noreturn)) inline void invoke_abort()
void abort()
{
-#if !CONFIG_ESP32_PANIC_SILENT_REBOOT
- ets_printf("abort() was called at PC 0x%08x on core %d\r\n", (intptr_t)__builtin_return_address(0) - 3, xPortGetCoreID());
-#endif
+ panicPutStr("abort() was called at PC 0x");
+ panicPutHex(__builtin_return_address(0) - 3);
+ panicPutStr(" on core ");
+ panicPutDec(xPortGetCoreID());
+ panicPutStr("\r\n");
/* Calling code might have set other reset reason hint (such as Task WDT),
* don't overwrite that.
*/