Crash reports only carried the coredump's PC/cause/vaddr, which for every abort() is panic_abort()'s own write to 0x0 - so all aborts looked the same. - Read the coredump backtrace (up to 16 PCs) and crashing ELF SHA prefix - Wrap esp_system_abort (-Wl,--wrap) to keep the abort/assert/stack-overflow message in RTC_NOINIT memory across the reboot - TelemetryTask snapshots uptime/free heap/largest block/min free heap into the same RTC block every second - Reported in MQTT boot_report and SD boot log as crash.backtrace, crash.elf_sha256 and a new pre_crash object (additive) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
679 lines
26 KiB
C++
679 lines
26 KiB
C++
#include "Telemetry.hpp"
|
|
|
|
#define TAG "Telemetry"
|
|
#include <ArduinoJson.h>
|
|
#include <cstring>
|
|
|
|
void Telemetry::begin() {
|
|
resetReason = esp_reset_reason();
|
|
LOG_INFO(TAG, "Reset reason: %s%s", getResetReasonString().c_str(), isFaultReset() ? " (FAULT)" : "");
|
|
|
|
initBootTracking();
|
|
captureCrashReport();
|
|
|
|
// Always consume (it clears RTC memory), but only keep it for a fault
|
|
// reset — after a clean reset/OTA the previous boot's snapshot is noise.
|
|
PreCrashSnapshot crumbs = CrashBreadcrumbs::consume();
|
|
if (isFaultReset() && crumbs.available) {
|
|
preCrash = crumbs;
|
|
LOG_WARNING(TAG, "Pre-crash state: uptime %lu ms, free heap %lu, largest block %lu, min free %lu",
|
|
preCrash.uptimeMs, preCrash.freeHeap, preCrash.largestBlock, preCrash.minFreeHeap);
|
|
if (preCrash.abortMsg[0] != ' |