ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
crash_report.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_CRASH_REPORT
6
7#include <array>
8#include <cstdint>
9
10#ifdef USE_ESP32
11#include <soc/soc_caps.h>
12#endif
13
14namespace esphome {
15
17static constexpr uint8_t CRASH_REPORT_MAX_BACKTRACE = 16;
18#ifdef USE_ESP32
19static constexpr uint8_t CRASH_REPORT_MAX_CORES = SOC_CPU_CORES_NUM;
20#else
21static constexpr uint8_t CRASH_REPORT_MAX_CORES = 1;
22#endif
23
25enum CrashReportFlag : uint8_t {
27 CRASH_REPORT_FLAG_PRESENT = 1 << 0, // Stored and not yet read
28 CRASH_REPORT_FLAG_BUILD_MATCHES = 1 << 1, // Recorded by the running firmware; assumed on ESP8266, RP2 and LibreTiny
29 CRASH_REPORT_FLAG_CAUSE = 1 << 2, // cause is valid
30 CRASH_REPORT_FLAG_FAULT_ADDRESS = 1 << 3, // fault_address is valid
31};
32
43
45 uint8_t core{0};
46 uint8_t count{0};
47 std::array<uint32_t, CRASH_REPORT_MAX_BACKTRACE> addresses{};
48};
49
53 uint8_t crashed_core{0};
54 uint8_t core_count{0};
59 std::array<CrashCoreBacktrace, CRASH_REPORT_MAX_CORES> cores{};
60};
61
63bool crash_report_get(CrashReport &out);
64
67
68} // namespace esphome
69
70#endif // USE_CRASH_REPORT
std::vector< uint8_t > & out
Definition gif.cpp:49
void crash_report_clear()
Mark the report read; it also no longer survives a reboot.
CrashReason
Sent as is over the native API.
CrashReportFlag
Sent as is over the native API.
@ CRASH_REPORT_FLAG_BUILD_MATCHES
@ CRASH_REPORT_FLAG_NONE
@ CRASH_REPORT_FLAG_PRESENT
@ CRASH_REPORT_FLAG_CAUSE
@ CRASH_REPORT_FLAG_FAULT_ADDRESS
bool crash_report_get(CrashReport &out)
The previous boot's crash; false when there is none or it was read. Implemented per platform.
static void uint32_t
std::array< uint32_t, CRASH_REPORT_MAX_BACKTRACE > addresses
std::array< CrashCoreBacktrace, CRASH_REPORT_MAX_CORES > cores