Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

  1. // -----------------------------------------------------------------------------
  2. // Save crash info
  3. // Taken from krzychb EspSaveCrash
  4. // https://github.com/krzychb/EspSaveCrash
  5. // -----------------------------------------------------------------------------
  6. #pragma once
  7. #define SAVE_CRASH_EEPROM_OFFSET 0x0100 // initial address for crash data
  8. /**
  9. * Structure of the single crash data set
  10. *
  11. * 1. Crash time
  12. * 2. Restart reason
  13. * 3. Exception cause
  14. * 4. epc1
  15. * 5. epc2
  16. * 6. epc3
  17. * 7. excvaddr
  18. * 8. depc
  19. * 9. adress of stack start
  20. * 10. adress of stack end
  21. * 11. stack trace size
  22. * 12. stack trace bytes
  23. * ...
  24. */
  25. #define SAVE_CRASH_CRASH_TIME 0x00 // 4 bytes
  26. #define SAVE_CRASH_RESTART_REASON 0x04 // 1 byte
  27. #define SAVE_CRASH_EXCEPTION_CAUSE 0x05 // 1 byte
  28. #define SAVE_CRASH_EPC1 0x06 // 4 bytes
  29. #define SAVE_CRASH_EPC2 0x0A // 4 bytes
  30. #define SAVE_CRASH_EPC3 0x0E // 4 bytes
  31. #define SAVE_CRASH_EXCVADDR 0x12 // 4 bytes
  32. #define SAVE_CRASH_DEPC 0x16 // 4 bytes
  33. #define SAVE_CRASH_STACK_START 0x1A // 4 bytes
  34. #define SAVE_CRASH_STACK_END 0x1E // 4 bytes
  35. #define SAVE_CRASH_STACK_SIZE 0x22 // 2 bytes
  36. #define SAVE_CRASH_STACK_TRACE 0x24 // variable
  37. constexpr size_t crashUsedSpace() {
  38. return (SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_SIZE + 2);
  39. }
  40. void crashClear();
  41. void crashDump();
  42. void crashSetup();