debugging on ESP32
This commit is contained in:
parent
f9797d5e8e
commit
3453b1d9c3
2 changed files with 16 additions and 1 deletions
|
@ -18,6 +18,9 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(ESP32)
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(SHA2017)
|
#if defined(SHA2017)
|
||||||
#include "console_shabadge.h"
|
#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");
|
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() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
@ -224,6 +235,10 @@ void setup() {
|
||||||
Serial.print(F("Size of int: "));
|
Serial.print(F("Size of int: "));
|
||||||
Serial.println(sizeof(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)
|
#if !defined(BUILD_FOR_RP2040)
|
||||||
Serial.print(F("CPU clock frequency (MHz): "));
|
Serial.print(F("CPU clock frequency (MHz): "));
|
||||||
Serial.println(getCpuFrequencyMhz());
|
Serial.println(getCpuFrequencyMhz());
|
||||||
|
|
|
@ -822,7 +822,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
}
|
}
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
else if (cmd == "debug") {
|
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!");
|
cnsl->put_string_lf("HEAP corruption!");
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue