debugging on ESP32

This commit is contained in:
folkert van heusden 2024-04-27 22:50:17 +02:00
parent f9797d5e8e
commit 3453b1d9c3
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 16 additions and 1 deletions

View file

@ -18,6 +18,9 @@
#include <sys/socket.h>
#include <sys/types.h>
#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());

View file

@ -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;