Sending all the fatal errors and backtrace values from Arduino's Serial Monitor to Display

Hello,
I am using ESP32 and I am getting below error message on my Serial Monitor

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Now in my project i can't keep arduino's serial Monitor always connected.

So i want a solution such that whenever this kind of error message come on serial monitor then it should also display on my tft display which is connected.

Or another solution can be it will be stored in eeprom with timestamp (like maintaining a log file) so whenever it is possible to connect serial i can read from EEPROM and print it on arduino's serial only.

Or another solution can be every such error messages can be transferred to some server.

Looking forward for any kind of help.
Thanks in advance

It seems unlikely that you can trap and redirect that diagnostic printout. Besides, given that your code caused a CPU exception, you have no idea what has been corrupted, including any code that would print to the TFT. Best you can probably do is determine the cause after the reboot with esp_reset_reason(). You can then print that code to the TFT.
See Here
And Here

ok i will go through it properly and try this tomorrow

const char* get_reset_reason_str(esp_reset_reason_t reason) {
    switch (reason) {
        case ESP_RST_UNKNOWN: return "Unknown reset reason";
        case ESP_RST_POWERON: return "Power-on reset";
        case ESP_RST_EXT: return "External reset (N/A for ESP32)";
        case ESP_RST_PANIC: return "Guru Meditation Error";
        case ESP_RST_INT_WDT: return "Interrupt watchdog reset";
        case ESP_RST_TASK_WDT: return "Task watchdog reset";
        case ESP_RST_WDT: return "Other watchdog reset";
        case ESP_RST_DEEPSLEEP: return "Deep sleep reset";
        default: return "Unknown reset reason";
    }
}

i am using this function to atleast send the reason why my esp reboot
but the problem is it only prints "Guru Meditation" but not the whole reason like below
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
the reason in parentheses is missing.
So how can i print even this reason on my tft display.

It seems to me that you do not fully understand the situation. Think about how these messages can be read by ESP32 itself if this is a mistake of the same controller? Where should be run the program that will read these messages?

As far as I can see, the only way to intercept and read these messages is to add another controller to your ESP32 (say, Arduino Nano) that will read the ESP32 messages.
But in my opinion this is too much. A better way is to fix your code on ESP32 so that these errors do not occur.

i tried fixing all possible errors in my code and code works fine but in between it reboots randomly and i got this guru meditation error. The project requires minimum 12hrs in working state and in those 12 hours it reboots once every day and i got this error

SOMETHING is wrong in your code. The ESP does not throw an Illegal load exception for no reason. Somewhere in your code, you are attemting to read from an invalid address. This is nearly always due to an uninitialized or incorrectly initialized pointer, or reading past the end of an array, or running out of heap space, or ignoring the return from malloc, or a host of other causes. In any case, it IS a problem in your code. Your best, only hope of finding it is to capture the ENTIRE error printout coming rom the Serial port, then using the ESP exception decoder to determine WHERE in your code it is happening. This will narrow the search for the actual cause considerably. Worst case, you might have to connect another device to the Serial port to capture, and preserve the entire error message. If you do this with another ESP, you can write the error message to its FFS, so you can pick it up at any time after the fact. I would simply setup another AP on that second ESP so you can just connect to it via WiFi, and download the file.

ok is it possible to store whole detailed error message in FFS?
And if yes can you provide some example like how i can achieve this thing?

Not in the same controller. You need a second ESP32 for it.

NOT on the same ESP! Your ESP has CRASHED, so the FFS is no longer accessible. So you can only captture the error message on ANOTHER device, and save it there.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.