diff --git a/components/esp32/include/esp_panic.h b/components/esp32/include/esp_panic.h index 6aba6c5f48..ce4ea3c501 100644 --- a/components/esp32/include/esp_panic.h +++ b/components/esp32/include/esp_panic.h @@ -14,8 +14,18 @@ #ifndef __ASSEMBLER__ +#include "esp_err.h" + void esp_set_breakpoint_if_jtag(void *fn); +#define ESP_WATCHPOINT_LOAD 0x40000000 +#define ESP_WATCHPOINT_STORE 0x80000000 +#define ESP_WATCHPOINT_ACCESS 0xC0000000 + +esp_err_t esp_set_watchpoint(int no, void *adr, int size, int flags); +void esp_clear_watchpoint(int no); + + #endif #endif \ No newline at end of file diff --git a/components/esp32/panic.c b/components/esp32/panic.c index 3cdbfb3e39..b4a84aee8e 100644 --- a/components/esp32/panic.c +++ b/components/esp32/panic.c @@ -32,6 +32,7 @@ #include "esp_gdbstub.h" #include "esp_panic.h" #include "esp_attr.h" +#include "esp_err.h" /* Panic handlers; these get called when an unhandled exception occurs or the assembly-level @@ -353,3 +354,50 @@ void esp_set_breakpoint_if_jtag(void *fn) setFirstBreakpoint((uint32_t)fn); } } + + +esp_err_t esp_set_watchpoint(int no, void *adr, int size, int flags) +{ + int x; + if (no<0 || no>1) return ESP_ERR_INVALID_ARG; + if (flags&(~0xC0000000)) return ESP_ERR_INVALID_ARG; + int dbreakc=0x3F; + //We support watching 2^n byte values, from 1 to 64. Calculate the mask for that. + for (x=0; x<6; x++) { + if (size==(1<pxStack, 32, ESP_WATCHPOINT_STORE); +#endif + + } portEXIT_CRITICAL_NESTED(irqstate); }