Save exception details and stack trace to the SPIFFS everytime the ESP8266 crashes
Save exception details and stack trace to SPIFFS everytime the ESP8266 crashes. Implement it in your sketch in two simple steps.
EspSaveCrashSpiffs is another handy little library that will keep automatically catching and saving crash information to ESP8266 module’s flash in case it fails due to exception or software WDT. You will then be able to analyze the crash log and decode the stack trace using ESP Exception Decoder.
This library is inspired by the EspSaveCrash library written by krzychb.
You will implement it in your sketch in two simple steps:
Include the library
#include "EspSaveCrashSpiffs.h"
Declare object
EspSaveCrashSpiffs SaveCrashSpiffs(0);
That’s it.
To print out the latest crash log to Serial use this:
// allocate some space for the latest log filename
char* _lastCrashFileName;
_lastCrashFileName = (char*)calloc(255, sizeof(char));
// get the last filename
SaveCrashSpiffs.getLastLogFileName(_lastCrashFileName);
Serial.printf("Name of last log file: '%s'\n", _lastCrashFileName);
Serial.println("--- BEGIN of crash file ---");
SaveCrashSpiffs.print(_lastCrashFileName);
Serial.println("--- END of crash file ---");
// free the allocated space
free(_lastCrashFileName);
Example serial output might be something like this:
Name of last log file: '/crashLog-5.log'
--- BEGIN of crash file ---
Crashed at 33535 ms
Restart reason: 2
Exception cause: 28
epc1=0x4020161a epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
>>>stack>>>
3fffff90: 00000a65 00000000 00000001 40202cfd
3fffffa0: 3fffdad0 00000000 3ffee958 40202d8c
3fffffb0: feefeffe feefeffe 3ffe8504 40100459
<<<stack<<<
--- END of crash file ---
The browser output looks like that:
To delete existing crash files from the flash refer to the deleteSomeFile()
function in the SimpleCrashSpiffs example.
Check the examples folder for sample implementation of this library and tracking down where the program crash happened. Also an example to show how to access to latest saved information remotely with a web browser.
epc1
, epc2
, epc3
, excvaddr
and depc
Library comes with example sketches that let you trigger some exceptions and see how to visualize saved data.
Feel free to contribute to the project in any way you like!
If you find any issues with code or descriptions please report them using Issues tab above.
brainelectronics
GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999