Remove debug logs
This commit is contained in:
@@ -154,33 +154,6 @@ enum class BootResume : uint8_t {
|
|||||||
// startDeepSleep() does not return, so a set latch only ends at the wakeup reset.
|
// startDeepSleep() does not return, so a set latch only ends at the wakeup reset.
|
||||||
static bool deepSleepInProgress = false;
|
static bool deepSleepInProgress = false;
|
||||||
|
|
||||||
// Heap-integrity probe. Scoped to MALLOC_CAP_8BIT|MALLOC_CAP_DEFAULT so we
|
|
||||||
// only inspect the user-app heap, not ROM/BLE/WiFi reserved DRAM regions that
|
|
||||||
// `heap_caps_check_integrity_all` would also walk (those report spurious
|
|
||||||
// canary mismatches because the user-heap allocator never stamped canaries
|
|
||||||
// there — the address 0x3fcdc710 we kept seeing FAIL on is outside our
|
|
||||||
// dram0_0_seg, in a system-reserved area). A fail here genuinely means user
|
|
||||||
// code overwrote a heap canary. Transition is loud (ERR), steady-state is DBG.
|
|
||||||
void runHeapIntegrityProbe(const char* stage) {
|
|
||||||
const bool integrityOk = heap_caps_check_integrity(MALLOC_CAP_8BIT | MALLOC_CAP_DEFAULT, true);
|
|
||||||
static bool lastIntegrityOk = true;
|
|
||||||
static bool firstIntegrityProbe = true;
|
|
||||||
const uint32_t freeHeap = esp_get_free_heap_size();
|
|
||||||
const uint32_t contigHeap = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_DEFAULT);
|
|
||||||
if (firstIntegrityProbe || integrityOk != lastIntegrityOk) {
|
|
||||||
if (integrityOk) {
|
|
||||||
LOG_INF("MEM", "[%s] integrity ok (uptime %lu ms, free=%lu contig=%lu)", stage, millis(), freeHeap, contigHeap);
|
|
||||||
} else {
|
|
||||||
LOG_ERR("MEM", "[%s] integrity FAIL (uptime %lu ms, free=%lu contig=%lu) — corruption introduced here", stage,
|
|
||||||
millis(), freeHeap, contigHeap);
|
|
||||||
}
|
|
||||||
lastIntegrityOk = integrityOk;
|
|
||||||
firstIntegrityProbe = false;
|
|
||||||
} else {
|
|
||||||
LOG_DBG("MEM", "[%s] integrity %s (free=%lu contig=%lu)", stage, integrityOk ? "ok" : "fail", freeHeap, contigHeap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void silentRestart() {
|
void silentRestart() {
|
||||||
if (deepSleepInProgress) return; // sleeping supersedes the heap-defrag reboot
|
if (deepSleepInProgress) return; // sleeping supersedes the heap-defrag reboot
|
||||||
// ESP.restart() bypasses activity onExit(), so flush any in-flight reading
|
// ESP.restart() bypasses activity onExit(), so flush any in-flight reading
|
||||||
@@ -375,7 +348,6 @@ void ensureSdFontLoadedForPath(const char* path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
runHeapIntegrityProbe("setup_entry");
|
|
||||||
{
|
{
|
||||||
esp_ota_img_states_t otaState;
|
esp_ota_img_states_t otaState;
|
||||||
const esp_partition_t* running = esp_ota_get_running_partition();
|
const esp_partition_t* running = esp_ota_get_running_partition();
|
||||||
@@ -383,7 +355,6 @@ void setup() {
|
|||||||
esp_ota_mark_app_valid_cancel_rollback();
|
esp_ota_mark_app_valid_cancel_rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runHeapIntegrityProbe("setup_after_otaCheck");
|
|
||||||
|
|
||||||
// Read-and-clear so a panic later in setup() doesn't loop into silent reboot.
|
// Read-and-clear so a panic later in setup() doesn't loop into silent reboot.
|
||||||
// Bound the target range too — RTC_NOINIT memory is uninitialized on cold boot.
|
// Bound the target range too — RTC_NOINIT memory is uninitialized on cold boot.
|
||||||
@@ -393,20 +364,13 @@ void setup() {
|
|||||||
silentRebootMagic = 0;
|
silentRebootMagic = 0;
|
||||||
silentRebootTarget = 0;
|
silentRebootTarget = 0;
|
||||||
|
|
||||||
runHeapIntegrityProbe("setup_before_HalSystem_begin");
|
|
||||||
HalSystem::begin();
|
HalSystem::begin();
|
||||||
runHeapIntegrityProbe("setup_after_HalSystem_begin");
|
|
||||||
gpio.begin();
|
gpio.begin();
|
||||||
runHeapIntegrityProbe("setup_after_gpio_begin");
|
|
||||||
powerManager.begin();
|
powerManager.begin();
|
||||||
runHeapIntegrityProbe("setup_after_powerManager_begin");
|
|
||||||
halTiltSensor.begin();
|
halTiltSensor.begin();
|
||||||
runHeapIntegrityProbe("setup_after_halTiltSensor_begin");
|
|
||||||
gpio_deep_sleep_hold_dis(); // Release deep sleep GPIO hold state from previous sleep cycle
|
gpio_deep_sleep_hold_dis(); // Release deep sleep GPIO hold state from previous sleep cycle
|
||||||
runHeapIntegrityProbe("setup_after_deepSleepHoldDis");
|
|
||||||
|
|
||||||
const auto wakeupReason = gpio.getWakeupReason();
|
const auto wakeupReason = gpio.getWakeupReason();
|
||||||
runHeapIntegrityProbe("setup_after_getWakeupReason");
|
|
||||||
|
|
||||||
if (wakeupReason == HalGPIO::WakeupReason::AfterUSBPower) {
|
if (wakeupReason == HalGPIO::WakeupReason::AfterUSBPower) {
|
||||||
// If USB power caused a cold boot, go back to sleep immediately without initializing subsystems
|
// If USB power caused a cold boot, go back to sleep immediately without initializing subsystems
|
||||||
@@ -429,7 +393,6 @@ void setup() {
|
|||||||
LOG_INF("MAIN", "Hardware detect: %s", gpio.deviceIsX3() ? "X3" : "X4");
|
LOG_INF("MAIN", "Hardware detect: %s", gpio.deviceIsX3() ? "X3" : "X4");
|
||||||
LOG_DBG("MAIN", "Wakeup reason: %d, millis=%lu, rawPowerPin=%d", static_cast<int>(wakeupReason), millis(),
|
LOG_DBG("MAIN", "Wakeup reason: %d, millis=%lu, rawPowerPin=%d", static_cast<int>(wakeupReason), millis(),
|
||||||
digitalRead(InputManager::POWER_BUTTON_PIN) == LOW);
|
digitalRead(InputManager::POWER_BUTTON_PIN) == LOW);
|
||||||
runHeapIntegrityProbe("setup_after_hwInit");
|
|
||||||
|
|
||||||
// Load just the settings we need *before* initializing the SD card to speed up and reduce power on unverified wakes
|
// Load just the settings we need *before* initializing the SD card to speed up and reduce power on unverified wakes
|
||||||
SETTINGS.loadStartupFromNvs();
|
SETTINGS.loadStartupFromNvs();
|
||||||
@@ -507,9 +470,7 @@ void setup() {
|
|||||||
: !APP_STATE.showBootScreen ? BootResume::QuickResume
|
: !APP_STATE.showBootScreen ? BootResume::QuickResume
|
||||||
: BootResume::Splash;
|
: BootResume::Splash;
|
||||||
|
|
||||||
runHeapIntegrityProbe("setup_before_displayAndFonts");
|
|
||||||
setupDisplayAndFonts(resume != BootResume::Splash);
|
setupDisplayAndFonts(resume != BootResume::Splash);
|
||||||
runHeapIntegrityProbe("setup_after_displayAndFonts");
|
|
||||||
|
|
||||||
switch (resume) {
|
switch (resume) {
|
||||||
case BootResume::Silent:
|
case BootResume::Silent:
|
||||||
@@ -540,12 +501,10 @@ void setup() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
runHeapIntegrityProbe("setup_after_initialPaint");
|
|
||||||
HalClock::restore();
|
HalClock::restore();
|
||||||
RECENT_BOOKS.loadFromFile();
|
RECENT_BOOKS.loadFromFile();
|
||||||
GLOBAL_BOOKMARKS.load();
|
GLOBAL_BOOKMARKS.load();
|
||||||
READING_STATS.loadFromFile();
|
READING_STATS.loadFromFile();
|
||||||
runHeapIntegrityProbe("setup_after_userStoresLoaded");
|
|
||||||
|
|
||||||
if (recoveryFirmwareMode) {
|
if (recoveryFirmwareMode) {
|
||||||
// Skip normal home/reader routing: jump straight into the SD firmware picker.
|
// Skip normal home/reader routing: jump straight into the SD firmware picker.
|
||||||
@@ -605,7 +564,6 @@ void loop() {
|
|||||||
if (Serial && millis() - lastMemPrint >= 10000) {
|
if (Serial && millis() - lastMemPrint >= 10000) {
|
||||||
LOG_INF("MEM", "Free: %d bytes, Total: %d bytes, Min Free: %d bytes, MaxAlloc: %d bytes", ESP.getFreeHeap(),
|
LOG_INF("MEM", "Free: %d bytes, Total: %d bytes, Min Free: %d bytes, MaxAlloc: %d bytes", ESP.getFreeHeap(),
|
||||||
ESP.getHeapSize(), ESP.getMinFreeHeap(), ESP.getMaxAllocHeap());
|
ESP.getHeapSize(), ESP.getMinFreeHeap(), ESP.getMaxAllocHeap());
|
||||||
runHeapIntegrityProbe("MEM_periodic");
|
|
||||||
lastMemPrint = millis();
|
lastMemPrint = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user