debug: add heap integrity checkpoints
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <WiFi.h>
|
||||
#include <esp_heap_caps.h>
|
||||
#include <WebServer.h>
|
||||
#include <Preferences.h>
|
||||
#include <esp_wifi.h>
|
||||
@@ -1631,7 +1632,9 @@ bool startAccessPoint() {
|
||||
void restartAccessPoint() {
|
||||
WiFi.softAPdisconnect(true);
|
||||
delay(250);
|
||||
heapCheckpoint("before:startAccessPoint");
|
||||
startAccessPoint();
|
||||
heapCheckpoint("after:startAccessPoint");
|
||||
}
|
||||
|
||||
void sendSimpleJsonError(int status, const char* error, const char* detail) {
|
||||
@@ -2085,7 +2088,9 @@ void connectStaWifi() {
|
||||
|
||||
WiFi.disconnect(false, false);
|
||||
delay(500);
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
heapCheckpoint("before:WiFi.mode");
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
heapCheckpoint("after:WiFi.mode");
|
||||
delay(250);
|
||||
|
||||
WiFi.begin(staSsids[i].c_str(), staPasswords[i].c_str());
|
||||
@@ -3115,7 +3120,9 @@ void handleDebugSerial() {
|
||||
}
|
||||
|
||||
if (command == "config") {
|
||||
printConfig();
|
||||
heapCheckpoint("before:printConfig");
|
||||
printConfig();
|
||||
heapCheckpoint("after:printConfig");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4070,8 +4077,28 @@ void handleStatus() {
|
||||
server.send(200, "application/json", output);
|
||||
}
|
||||
|
||||
|
||||
void heapCheckpoint(const char* label) {
|
||||
Serial.print("HEAP CHECK ");
|
||||
Serial.print(label);
|
||||
Serial.print(" free=");
|
||||
Serial.print(ESP.getFreeHeap());
|
||||
Serial.print(" min=");
|
||||
Serial.println(ESP.getMinFreeHeap());
|
||||
|
||||
if (!heap_caps_check_integrity_all(true)) {
|
||||
Serial.print("HEAP CORRUPTION DETECTED AT: ");
|
||||
Serial.println(label);
|
||||
while (true) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(500);
|
||||
heapCheckpoint("setup:start");
|
||||
|
||||
#if DASHBOARD_UART_ENABLED
|
||||
DashboardSerial.begin(
|
||||
@@ -4088,23 +4115,37 @@ void setup() {
|
||||
Serial.println("Overland Controller Booting");
|
||||
Serial.println("==================================");
|
||||
|
||||
heapCheckpoint("before:oledBegin");
|
||||
oledBegin();
|
||||
heapCheckpoint("after:oledBegin");
|
||||
|
||||
heapCheckpoint("before:loadConfig");
|
||||
loadConfig();
|
||||
heapCheckpoint("after:loadConfig");
|
||||
printConfig();
|
||||
|
||||
pinMode(IGNITION_PIN, INPUT);
|
||||
|
||||
heapCheckpoint("before:initRelays");
|
||||
initRelays();
|
||||
heapCheckpoint("after:initRelays");
|
||||
heapCheckpoint("before:initSensors");
|
||||
initSensors();
|
||||
heapCheckpoint("after:initSensors");
|
||||
#if BMS_COMPILE_ENABLED
|
||||
heapCheckpoint("before:initBms");
|
||||
initBms();
|
||||
heapCheckpoint("after:initBms");
|
||||
#else
|
||||
Serial.println("BMS/BLE disabled for LilyGO bring-up test");
|
||||
#endif
|
||||
|
||||
heapCheckpoint("before:loadWifiConfig");
|
||||
loadWifiConfig();
|
||||
heapCheckpoint("after:loadWifiConfig");
|
||||
heapCheckpoint("before:loadApConfig");
|
||||
loadApConfig();
|
||||
heapCheckpoint("after:loadApConfig");
|
||||
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
startAccessPoint();
|
||||
@@ -4226,9 +4267,12 @@ void setup() {
|
||||
});
|
||||
|
||||
|
||||
heapCheckpoint("before:server.begin");
|
||||
server.begin();
|
||||
heapCheckpoint("after:server.begin");
|
||||
|
||||
Serial.println("Web Server Started");
|
||||
heapCheckpoint("setup:end");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
Reference in New Issue
Block a user