ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
crash_handler.cpp
Go to the documentation of this file.
1#ifdef USE_LIBRETINY
2
4#ifdef USE_LIBRETINY_CRASH_HANDLER
5
6#include "crash_handler.h"
7
8#if !defined(USE_BK72XX) && !defined(USE_LIBRETINY_CRASH_HANDLER_VECTOR_PATCH)
9#error "The LibreTiny crash handler has no fault capture for this chip family"
10#endif
11
12#include "core.h"
13#include <FreeRTOS.h>
14#include "esphome/core/log.h"
16
17#include <cinttypes>
18#include <cstddef>
19#include <cstdint>
20#include <cstdio>
21
22#ifdef USE_BK72XX
23extern "C" {
24#include <arm_mcu_pub.h> // MCU_REG_BACKUP_SP_*
25#include <intc.h> // struct arm_registers
26}
27
28// On a fault the SDK (boot_handlers.S, PUSH_SVC_REG) builds a struct arm_registers frame and branches
29// to bk_trap_udef/pabt/dabt, which record the crash type, print a dump sdk_silent hides and spin for
30// the watchdog. The wrappers (-Wl,--wrap) first save the fault location and a stack scan for the
31// next boot. pc is the exception LR; PUSH_SVC_REG stores pc and spsr at these word offsets.
32static_assert(sizeof(arm_registers) == 18 * sizeof(uint32_t), "SDK exception frame changed size");
33static_assert(offsetof(arm_registers, pc) == 15 * 4 && offsetof(arm_registers, spsr) == 16 * 4,
34 "SDK exception frame layout changed");
35static_assert(LT_HW_WATCHDOG, "the crash reboot relies on the hardware watchdog");
36
37// NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
38extern "C" {
39void __real_bk_trap_udef(arm_registers *regs);
40void __real_bk_trap_pabt(arm_registers *regs);
41void __real_bk_trap_dabt(arm_registers *regs);
42// Bounds of the app's flash image and its ITCM code (linker symbols).
43extern char _vector_start[];
44extern char _data_flash_begin[];
45extern char _itcmcode_ram_begin[];
46extern char _itcmcode_ram_end[];
47}
48// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
49#endif // USE_BK72XX
50
51#ifdef USE_LIBRETINY_VARIANT_RTL8720C
52// NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
53extern "C" {
54// Bounds of the code in flash (XIP) and in RAM (linker symbols, rtl8710c_ram.ld).
55extern char __xip_code_text_start__[];
56extern char __xip_code_text_end__[];
57extern char __ram_entry_text_start__[];
58extern char __ram_code_text_end__[];
59}
60// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
61#endif // USE_LIBRETINY_VARIANT_RTL8720C
62
63#ifdef USE_LIBRETINY_VARIANT_RTL8710B
64// NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
65extern "C" {
66// Bounds of the code in flash (XIP) and of the IRAM_ATTR code (linker symbols; the latter from patch_linker.py).
67extern char __flash_text_start__[];
68extern char __flash_text_end__[];
69extern char __esphome_sram_text_start[];
70extern char __esphome_sram_text_end[];
71}
72// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
73#endif // USE_LIBRETINY_VARIANT_RTL8710B
74
75#ifdef USE_LN882X
76// NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
77extern "C" {
78// Bounds of the code in flash and of the IRAM_ATTR code (linker symbols; the latter from patch_linker.py).
79extern char _stext[];
80extern char _etext[];
83}
84// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
85#endif // USE_LN882X
86
87namespace esphome::libretiny {
88
89ESPHOME_LOG_TAG(TAG, "libretiny.crash");
90
91// 0xDEAD sentinel, then the record layout version.
92static constexpr uint32_t CRASH_MAGIC_V2 = 0xDEAD0002;
93
94// BK72xx: the ARM9 exception taken.
95static constexpr uint32_t CRASH_REASON_UNDEFINED = 1;
96static constexpr uint32_t CRASH_REASON_PREFETCH_ABORT = 2;
97static constexpr uint32_t CRASH_REASON_DATA_ABORT = 3;
98// Cortex-M families: the exception number (3 to 7) plus this offset.
99static constexpr uint32_t CRASH_REASON_CORTEX_M_OFFSET = 1;
100// After the Cortex-M ones (4 to 8).
101static constexpr uint32_t CRASH_REASON_ABORT = 9;
102PROGMEM_STRING_TABLE(CrashReasonStrings, "Unknown", "Undefined instruction", "Prefetch abort", "Data abort",
103 "Hard fault", "MemManage fault", "Bus fault", "Usage fault", "Secure fault", "Abort");
104
105static constexpr size_t MAX_BACKTRACE = 8;
106// Words scanned above sp for return addresses.
107static constexpr size_t STACK_SCAN_WORDS = 64;
108
109struct CrashRecord {
110 uint32_t magic;
111 uint32_t reason;
112 uint32_t pc;
113 uint32_t lr;
114 uint32_t sp;
115 uint32_t fault_status; // Cortex-M CFSR, 0 on BK72xx
116 uint32_t fault_address; // Cortex-M BFAR or MMFAR when valid, else 0
117 uint32_t backtrace[MAX_BACKTRACE];
118};
119
120#ifdef USE_BK72XX
121// Kept in ITCM, see patch_noinit.py.script.
122#define CRASH_RECORD_SECTION ".noinit"
123#elif defined(USE_LN882X)
124// ln882hki_bsp.template.ld puts .noinit in RETENTION RAM, which startup does not clear.
125#define CRASH_RECORD_SECTION ".noinit"
126#elif defined(USE_LIBRETINY_VARIANT_RTL8710B)
127// The AmebaZ linker script puts .bfsram.data* (the FreeRTOS heap) after the .bss that startup zeroes, and the
128// image the bootloader loads ends before .bss.
129#define CRASH_RECORD_SECTION ".bfsram.data.esphome_crash"
130#else
131// rtl8710c_ram.ld keeps .ram.bss.noinit* out of the startup zeroing.
132#define CRASH_RECORD_SECTION ".ram.bss.noinit.esphome_crash"
133#endif
134// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
135__attribute__((section(CRASH_RECORD_SECTION))) static CrashRecord s_record;
136
137static bool s_record_read = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
138static bool s_record_valid = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
139
141 if (!s_record_read) {
142 s_record_read = true;
143 s_record_valid = s_record.magic == CRASH_MAGIC_V2;
144 // Clear the magic so the record is reported once.
145 s_record.magic = 0;
146 }
147 return s_record_valid;
148}
149
150// One ESP_LOGE per line: the CLI decodes per line and partial output still shows.
153 return;
154
155 ESP_LOGE(TAG, "*** CRASH DETECTED ON PREVIOUS BOOT ***");
156 ESP_LOGE(TAG, " Reason: %s", LOG_STR_ARG(CrashReasonStrings::get_log_str(s_record.reason, 0)));
157 if (s_record.fault_status != 0) {
158 ESP_LOGE(TAG, " CFSR: 0x%08" PRIX32 " Address: 0x%08" PRIX32, s_record.fault_status, s_record.fault_address);
159 }
160 ESP_LOGE(TAG, " PC: 0x%08" PRIX32 " (fault location)", s_record.pc);
161 // 0 for abort(), and for a Cortex-M frame outside SRAM
162 if (s_record.lr != 0) {
163 ESP_LOGE(TAG, " LR: 0x%08" PRIX32 " (return address)", s_record.lr);
164 }
165 ESP_LOGE(TAG, " SP: 0x%08" PRIX32, s_record.sp);
166 uint8_t count = 0;
167 for (; count < MAX_BACKTRACE && s_record.backtrace[count] != 0; count++) {
168 ESP_LOGE(TAG, " BT%d: 0x%08" PRIX32 " (stack backtrace)", count, s_record.backtrace[count]);
169 }
170 // addr2line hint with every address
171 char hint[160];
172 int pos = snprintf(hint, sizeof(hint), "Use: addr2line -pfiaC -e raw_firmware.elf 0x%08" PRIX32, s_record.pc);
173 if (s_record.lr != 0)
174 pos += snprintf(hint + pos, sizeof(hint) - pos, " 0x%08" PRIX32, s_record.lr);
175 for (uint8_t i = 0; i < count && pos < (int) sizeof(hint) - 12; i++) {
176 pos += snprintf(hint + pos, sizeof(hint) - pos, " 0x%08" PRIX32, s_record.backtrace[i]);
177 }
178 ESP_LOGE(TAG, "%s", hint);
179}
180
181// --- Crash time: exception mode, a few dozen bytes of stack: no printing, no large locals.
182
183static inline bool is_code_addr(uint32_t val) {
184 uint32_t addr = val & ~1u; // clear the Thumb bit of a return address
185#ifdef USE_BK72XX
186 return (addr >= (uint32_t) _vector_start && addr < (uint32_t) _data_flash_begin) ||
188#elif defined(USE_LIBRETINY_VARIANT_RTL8710B)
189 return (addr >= (uint32_t) __flash_text_start__ && addr < (uint32_t) __flash_text_end__) ||
191#elif defined(USE_LN882X)
192 return (addr >= (uint32_t) _stext && addr < (uint32_t) _etext) ||
194#else
195 return (addr >= (uint32_t) __xip_code_text_start__ && addr < (uint32_t) __xip_code_text_end__) ||
197#endif
198}
199
200static void fill_record(uint32_t reason, uint32_t pc, uint32_t lr, uint32_t sp, uint32_t fault_status,
201 uint32_t fault_address) {
202 s_record.reason = reason;
203 s_record.pc = pc;
204 s_record.lr = lr;
205 s_record.sp = sp;
206 s_record.fault_status = fault_status;
207 s_record.fault_address = fault_address;
208}
209
210// Return addresses above sp give the backtrace; then the magic marks the record complete.
211static void finish_record(uint32_t sp, uint32_t sram_start, uint32_t sram_end) {
212 uint32_t count = 0;
213 if (sp >= sram_start && sp < sram_end && (sp & 3) == 0) {
214 auto *scan = (const uint32_t *) sp; // NOLINT(performance-no-int-to-ptr)
215 auto *end = (const uint32_t *) sram_end; // NOLINT(performance-no-int-to-ptr)
216 for (size_t i = 0; i < STACK_SCAN_WORDS && scan < end && count < MAX_BACKTRACE; i++, scan++) {
217 uint32_t val = *scan;
218 if (is_code_addr(val) && val != s_record.lr && (val & ~1u) != s_record.pc)
219 s_record.backtrace[count++] = val;
220 }
221 }
222 if (count < MAX_BACKTRACE)
223 s_record.backtrace[count] = 0; // terminator, the reader stops at the first 0
224 s_record.magic = CRASH_MAGIC_V2;
225}
226
227#ifdef USE_BK72XX
228
229// With Wi-Fi up the boot-time watchdog no longer fires: any interrupts-off spin hangs until power is
230// cycled (BK7238 and BK7231N; cause not in the open SDK). Re-armed here, long enough for the SDK's
231// register dump when sdk_silent is off.
232static constexpr uint32_t CRASH_REBOOT_WDT_MS = 500;
233
234// SRAM: 192 KB on the BK7231N, 256 KB on the BK7238.
235static constexpr uint32_t SRAM_START = 0x00400000;
236#ifdef USE_LIBRETINY_VARIANT_BK7231N
237static constexpr uint32_t SRAM_END = 0x00430000;
238#else
239static constexpr uint32_t SRAM_END = 0x00440000;
240#endif
241
242static constexpr uint32_t CPSR_MODE_MASK = 0x1F;
243static constexpr uint32_t CPSR_MODE_USR = 0x10;
244static constexpr uint32_t CPSR_MODE_FIQ = 0x11;
245static constexpr uint32_t CPSR_MODE_IRQ = 0x12;
246static constexpr uint32_t CPSR_MODE_SVC = 0x13;
247static constexpr uint32_t CPSR_MODE_ABT = 0x17;
248static constexpr uint32_t CPSR_MODE_UND = 0x1B;
249static constexpr uint32_t CPSR_MODE_SYS = 0x1F;
250static constexpr uint32_t CPSR_THUMB = 1u << 5;
251
252// PUSH_ALL_ARM_REG (boot_handlers.S) saves every mode's registers at the arm_mcu_pub.h addresses
253// before bk_trap_*; lr (r14) follows sp (r13).
254struct SavedBank {
255 uint32_t mode;
256 uint32_t sp_addr;
257};
258static constexpr SavedBank SAVED_BANKS[] = {
259 {CPSR_MODE_SYS, MCU_REG_BACKUP_SP_SYS}, {CPSR_MODE_IRQ, MCU_REG_BACKUP_SP_IRQ},
260 {CPSR_MODE_FIQ, MCU_REG_BACKUP_SP_FIQ}, {CPSR_MODE_ABT, MCU_REG_BACKUP_SP_ABT},
261 {CPSR_MODE_UND, MCU_REG_BACKUP_SP_UND}, {CPSR_MODE_SVC, MCU_REG_BACKUP_SP_SVC},
262};
263
264// sp and lr stay 0 for an unknown mode (corrupt spsr).
265static void read_saved_sp_lr(uint32_t mode, uint32_t *sp, uint32_t *lr) {
266 for (const auto &bank : SAVED_BANKS) {
267 if (bank.mode != mode)
268 continue;
269 const auto *regs = (const volatile uint32_t *) bank.sp_addr; // NOLINT(performance-no-int-to-ptr)
270 *sp = regs[0];
271 *lr = regs[1];
272 return;
273 }
274}
275
276static void record_crash(arm_registers *regs, uint32_t reason, uint32_t pc_offset) {
277 uint32_t mode = regs->spsr & CPSR_MODE_MASK;
278 if (mode == CPSR_MODE_USR)
279 mode = CPSR_MODE_SYS; // same register bank
280 uint32_t sp = 0;
281 uint32_t lr = 0;
282 read_saved_sp_lr(mode, &sp, &lr);
283
284 fill_record(reason, regs->pc - pc_offset, lr, sp, 0, 0);
285 finish_record(sp, SRAM_START, SRAM_END);
286
287 lt_wdt_enable(CRASH_REBOOT_WDT_MS);
288}
289
290// The exception LR is past the fault: one instruction (undefined), 4 bytes (prefetch), 8 (data abort).
291// NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
292extern "C" void __wrap_bk_trap_udef(arm_registers *regs) {
293 record_crash(regs, CRASH_REASON_UNDEFINED, (regs->spsr & CPSR_THUMB) ? 2 : 4);
295}
296
297extern "C" void __wrap_bk_trap_pabt(arm_registers *regs) {
298 record_crash(regs, CRASH_REASON_PREFETCH_ABORT, 4);
300}
301
302extern "C" void __wrap_bk_trap_dabt(arm_registers *regs) {
303 record_crash(regs, CRASH_REASON_DATA_ABORT, 8);
305}
306// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
307
308#endif // USE_BK72XX
309
310#ifdef USE_LIBRETINY_CRASH_HANDLER_VECTOR_PATCH
311
312// The SDK's RAM vector table (VTOR) points the fault vectors at a handler that prints a register dump and then
313// spins: a ROM handler on the RTL8720C and RTL8710B, CmBacktrace (hal_interrupt.c) on the LN882H.
314// crash_handler_install() puts esphome_fault_entry() in front of it, as the RTL8720C SDK's own CONFIG_MIIO patch
315// (app_start.c) does.
316static_assert(LT_HW_WATCHDOG, "the crash reboot relies on the hardware watchdog");
317// The RTL8720C ROM dump takes about 0.4 s at 115200 baud; without the re-arm the reset waits for the 10 s
318// watchdog from arch_init().
319static constexpr uint32_t CRASH_REBOOT_WDT_MS = 1000;
320static constexpr uint32_t FIRST_FAULT_VECTOR = 3; // HardFault, then MemManage, BusFault, UsageFault
321#ifdef USE_LIBRETINY_VARIANT_RTL8720C
322static constexpr uint32_t FAULT_VECTOR_COUNT = 5; // and SecureFault (ARMv8-M)
323// DTCM, where the app's stacks and heap live (rtl8710c_ram.ld).
324static constexpr uint32_t SRAM_START = 0x10000000;
325static constexpr uint32_t SRAM_END = 0x1003FA00;
326#elif defined(USE_LIBRETINY_VARIANT_RTL8710B)
327static constexpr uint32_t FAULT_VECTOR_COUNT = 4;
328// All of SRAM: the heap regions span it (heap_5.c) and MSP starts at 0x1003EFFC.
329static constexpr uint32_t SRAM_START = 0x10000000;
330static constexpr uint32_t SRAM_END = 0x10040000;
331#else
332static constexpr uint32_t FAULT_VECTOR_COUNT = 4;
333// RAM0, where the stacks and heap live (ln882hki_bsp.template.ld).
334static constexpr uint32_t SRAM_START = 0x20000000;
335static constexpr uint32_t SRAM_END = 0x20049C00;
336#endif
337
338// Architectural System Control Block registers (ARMv7-M and ARMv8-M).
339static constexpr uintptr_t SCB_VTOR = 0xE000ED08;
340static constexpr uintptr_t SCB_CFSR = 0xE000ED28;
341static constexpr uintptr_t SCB_MMFAR = 0xE000ED34;
342static constexpr uintptr_t SCB_BFAR = 0xE000ED38;
343static constexpr uint32_t CFSR_MMARVALID = 1u << 7;
344static constexpr uint32_t CFSR_BFARVALID = 1u << 15;
345
346// Exception frame: r0-r3, r12, lr, pc, xPSR, then the FPU registers when EXC_RETURN says so (FPU chips).
347static constexpr uint32_t FRAME_LR = 5;
348static constexpr uint32_t FRAME_PC = 6;
349static constexpr uint32_t FRAME_XPSR = 7;
350static constexpr uint32_t FRAME_WORDS = 8;
351static constexpr uint32_t EXTENDED_FRAME_WORDS = 26;
352static constexpr uint32_t EXC_RETURN_STANDARD_FRAME = 1u << 4;
353static constexpr uint32_t XPSR_STACK_ALIGNED = 1u << 9;
354
355// The SDK handlers fault_entry() continues into, by vector.
356static uint32_t s_sdk_fault_vectors[FAULT_VECTOR_COUNT]; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
357static bool s_fault_recorded = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
358
359static inline uint32_t read_reg(uintptr_t addr) {
360 return *(const volatile uint32_t *) addr; // NOLINT(performance-no-int-to-ptr)
361}
362
363// Returns the SDK handler to continue into. pc, lr and sp stay 0 when the frame is outside SRAM.
364extern "C" __attribute__((used)) uint32_t esphome_record_fault(const uint32_t *frame, uint32_t vector,
366 // A later fault, in the recording below or in the SDK handler (CmBacktrace on the LN882H walks past the end
367 // of RAM), keeps the first record and waits for the watchdog instead of starting the dump again.
368 if (s_fault_recorded) {
369 while (true) {
370 }
371 }
372 s_fault_recorded = true;
373 lt_wdt_enable(CRASH_REBOOT_WDT_MS);
374 uint32_t cfsr = read_reg(SCB_CFSR);
376 if (cfsr & CFSR_BFARVALID) {
377 address = read_reg(SCB_BFAR);
378 } else if (cfsr & CFSR_MMARVALID) {
379 address = read_reg(SCB_MMFAR);
380 }
381 auto frame_addr = (uint32_t) frame;
382 uint32_t frame_words = (exc_return & EXC_RETURN_STANDARD_FRAME) ? FRAME_WORDS : EXTENDED_FRAME_WORDS;
386 if (frame_addr >= SRAM_START && frame_addr <= SRAM_END - frame_words * 4 && (frame_addr & 3) == 0) {
387 pc = frame[FRAME_PC];
388 lr = frame[FRAME_LR];
389 sp = frame_addr + frame_words * 4 + ((frame[FRAME_XPSR] & XPSR_STACK_ALIGNED) ? 4 : 0);
390 }
391 fill_record(vector + CRASH_REASON_CORTEX_M_OFFSET, pc, lr, sp, cfsr, address);
392 finish_record(sp, SRAM_START, SRAM_END);
393 return s_sdk_fault_vectors[vector - FIRST_FAULT_VECTOR];
394}
395
396// Fault vector: calls esphome_record_fault(frame, exception number, EXC_RETURN), then jumps to the SDK handler it
397// returns with r0-r3 and lr restored. Asm because C would push onto MSP before the frame is found, and the SDK
398// handler reads EXC_RETURN from lr.
399extern "C" __attribute__((naked, used)) void esphome_fault_entry() {
400 __asm volatile("push {r0-r3, r4, lr} \n" // r4 only keeps the stack 8-byte aligned
401 "tst lr, #4 \n"
402 "ite eq \n"
403 "mrseq r0, msp \n"
404 "mrsne r0, psp \n"
405 "it eq \n"
406 "addeq r0, r0, #24 \n" // MSP: skip the six words pushed above
407 "mrs r1, ipsr \n"
408 "ubfx r1, r1, #0, #9 \n" // exception number, 3 to 7
409 "mov r2, lr \n"
410 "bl esphome_record_fault \n"
411 "mov r12, r0 \n" // SDK handler address
412 "pop {r0-r3, r4, lr} \n"
413 "bx r12 \n");
414}
415
417 auto *vectors = (uint32_t *) read_reg(SCB_VTOR); // NOLINT(performance-no-int-to-ptr)
418 for (uint32_t i = 0; i < FAULT_VECTOR_COUNT; i++) {
419 s_sdk_fault_vectors[i] = vectors[FIRST_FAULT_VECTOR + i];
420 vectors[FIRST_FAULT_VECTOR + i] = (uint32_t) &esphome_fault_entry;
421 }
422}
423
424#endif // USE_LIBRETINY_CRASH_HANDLER_VECTOR_PATCH
425
426// newlib's abort() spins in _exit() with no record and, on the BK7238, no watchdog reset. Interrupts go off first
427// because every task's delay() feeds the watchdog.
428// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
429extern "C" [[noreturn]] void __wrap_abort() {
430 portDISABLE_INTERRUPTS();
431 lt_wdt_enable(CRASH_REBOOT_WDT_MS);
432 uint32_t sp;
433 __asm volatile("mov %0, sp" : "=r"(sp));
434 // Inside the bl that called abort(): a noreturn call can be the caller's last instruction, so the return
435 // address may already be the next function. Bit 0 is the Thumb bit.
436 fill_record(CRASH_REASON_ABORT, ((uint32_t) __builtin_return_address(0) & ~1u) - 2, 0, sp, 0, 0);
437 // Valid without a backtrace, so a fault in the stack scan still leaves this record; every entry is cleared, so
438 // a scan cut short leaves none from an earlier crash
439 for (auto &addr : s_record.backtrace)
440 addr = 0;
441 s_record.magic = CRASH_MAGIC_V2;
442 // Keeps those writes ahead of the scan's reads
443 __asm volatile("" ::: "memory");
444#ifdef USE_LIBRETINY_CRASH_HANDLER_VECTOR_PATCH
445 // A fault in the scan then spins for the watchdog instead of replacing this record or running the SDK dump
446 s_fault_recorded = true;
447#endif
448 finish_record(sp, SRAM_START, SRAM_END);
449 while (true) {
450 }
451}
452
453} // namespace esphome::libretiny
454
455#endif // USE_LIBRETINY_CRASH_HANDLER
456#endif // USE_LIBRETINY
BedjetMode mode
BedJet operating mode.
struct @66::@67 __attribute__
Wake the main loop task from an ISR. ISR-safe.
Definition main_task.h:45
unsigned count
Definition gif.cpp:51
char _stext[]
char __ram_entry_text_start__[]
void __real_bk_trap_udef(arm_registers *regs)
char _data_flash_begin[]
char _itcmcode_ram_end[]
void __real_bk_trap_dabt(arm_registers *regs)
char _etext[]
char __xip_code_text_end__[]
char _itcmcode_ram_begin[]
void __real_bk_trap_pabt(arm_registers *regs)
char _vector_start[]
char __flash_text_start__[]
char __ram_code_text_end__[]
char __esphome_sram_text_start[]
char __esphome_sram_text_end[]
char __xip_code_text_start__[]
char __flash_text_end__[]
mopeka_std_values val[3]
PROGMEM_STRING_TABLE(CrashReasonStrings, "Unknown", "Undefined instruction", "Prefetch abort", "Data abort", "Hard fault", "MemManage fault", "Bus fault", "Usage fault", "Secure fault", "Abort")
void __wrap_bk_trap_udef(arm_registers *regs)
lt_wdt_enable(CRASH_REBOOT_WDT_MS)
void crash_handler_install()
Put the crash recorder in front of the SDK's fault handlers.
void __wrap_bk_trap_dabt(arm_registers *regs)
void __wrap_bk_trap_pabt(arm_registers *regs)
void crash_handler_log()
Log crash data if a crash was detected on previous boot.
ESPHOME_LOG_TAG(TAG, "libretiny.crash")
bool crash_handler_has_data()
Returns true if crash data was found this boot, reading it first if needed.
uint32_t uint32_t exc_return
size_t size_t pos
Definition helpers.h:1333
static void uint32_t
uint8_t end[39]
Definition sun_gtil2.cpp:17