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