Skip to content

Commit b31d0ce

Browse files
committed
Merge pull request esp8266#1012 from CanTireInnovations/custom_crash_callback
Add the ability to be called back when the device is about to reset
2 parents 6d1d0ab + baa13f8 commit b31d0ce

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cores/esp8266/core_esp8266_postmortem.c

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ static void uart1_write_char_d(char c);
3737
static void print_stack(uint32_t start, uint32_t end);
3838
//static void print_pcs(uint32_t start, uint32_t end);
3939

40+
extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) {
41+
}
42+
43+
extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback")));
44+
4045
void __wrap_system_restart_local() {
4146
register uint32_t sp asm("a1");
4247

@@ -92,6 +97,9 @@ void __wrap_system_restart_local() {
9297

9398
// print_pcs(sp + offset, stack_end);
9499
print_stack(sp + offset, stack_end);
100+
101+
custom_crash_callback( &rst_info, sp + offset, stack_end );
102+
95103
delayMicroseconds(10000);
96104
__real_system_restart_local();
97105
}

0 commit comments

Comments
 (0)