esp_debug_helpers.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. #ifndef __ASSEMBLER__
  6. #include "esp_err.h"
  7. #define ESP_WATCHPOINT_LOAD 0x40000000
  8. #define ESP_WATCHPOINT_STORE 0x80000000
  9. #define ESP_WATCHPOINT_ACCESS 0xC0000000
  10. /**
  11. * @brief If an OCD is connected over JTAG. set breakpoint 0 to the given function
  12. * address. Do nothing otherwise.
  13. * @param fn Pointer to the target breakpoint position
  14. */
  15. void esp_set_breakpoint_if_jtag(void *fn);
  16. /**
  17. * @brief Set a watchpoint to break/panic when a certain memory range is accessed.
  18. *
  19. * @param no Watchpoint number. On the ESP32, this can be 0 or 1.
  20. * @param adr Base address to watch
  21. * @param size Size of the region, starting at the base address, to watch. Must
  22. * be one of 2^n, with n in [0..6].
  23. * @param flags One of ESP_WATCHPOINT_* flags
  24. *
  25. * @return ESP_ERR_INVALID_ARG on invalid arg, ESP_OK otherwise
  26. *
  27. * @warning The ESP32 watchpoint hardware watches a region of bytes by effectively
  28. * masking away the lower n bits for a region with size 2^n. If adr does
  29. * not have zero for these lower n bits, you may not be watching the
  30. * region you intended.
  31. */
  32. esp_err_t esp_set_watchpoint(int no, void *adr, int size, int flags);
  33. /**
  34. * @brief Clear a watchpoint
  35. *
  36. * @param no Watchpoint to clear
  37. *
  38. */
  39. void esp_clear_watchpoint(int no);
  40. /**
  41. * @brief Checks stack pointer
  42. */
  43. static inline bool esp_stack_ptr_is_sane(uint32_t sp)
  44. {
  45. return !(sp < 0x3ffae010UL || sp > 0x3ffffff0UL || ((sp & 0xf) != 0));
  46. }
  47. #endif
  48. #ifdef __cplusplus
  49. }
  50. #endif