diff --git a/ESP32/main.ino b/ESP32/main.ino index cbe8a39..15c3220 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -18,6 +18,9 @@ #include #include #endif +#if defined(ESP32) +#include "esp_heap_caps.h" +#endif #if defined(SHA2017) #include "console_shabadge.h" @@ -210,6 +213,14 @@ void set_tty_serial_speed(console *const c, const uint32_t bps) c->put_string_lf("Failed to store configuration file with serial settings"); } +#if defined(ESP32) +void heap_caps_alloc_failed_hook(size_t requested_size, uint32_t caps, const char *function_name) +{ + printf("%s was called but failed to allocate %d bytes with 0x%X capabilities\r\n", function_name, requested_size, caps); +} + +#endif + void setup() { Serial.begin(115200); @@ -224,6 +235,10 @@ void setup() { Serial.print(F("Size of int: ")); Serial.println(sizeof(int)); +#if defined(ESP32) + heap_caps_register_failed_alloc_callback(heap_caps_alloc_failed_hook); +#endif + #if !defined(BUILD_FOR_RP2040) Serial.print(F("CPU clock frequency (MHz): ")); Serial.println(getCpuFrequencyMhz()); diff --git a/debugger.cpp b/debugger.cpp index 12c259a..51e425b 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -822,7 +822,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto } #if defined(ESP32) else if (cmd == "debug") { - if (heap_caps_check_integrity(MALLOC_CAP_DEFAULT, true) == false) + if (heap_caps_check_integrity_all(true) == false) cnsl->put_string_lf("HEAP corruption!"); continue;