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.

52 lines
1.5 KiB

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