Skip to content

Add the ability to be called back when the device is about to reset #1012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from Nov 15, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cores/esp8266/core_esp8266_postmortem.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ static void uart1_write_char_d(char c);
static void print_stack(uint32_t start, uint32_t end);
//static void print_pcs(uint32_t start, uint32_t end);

extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) {
}

extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback")));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've aped the style used elsewhere in this project, though I must admit I don't know the reason for the alias (my guess is that it makes for less confusion when looking at stack dumps).


void __wrap_system_restart_local() {
register uint32_t sp asm("a1");

Expand Down Expand Up @@ -92,6 +97,9 @@ void __wrap_system_restart_local() {

// print_pcs(sp + offset, stack_end);
print_stack(sp + offset, stack_end);

custom_crash_callback( &rst_info, sp + offset, stack_end );

delayMicroseconds(10000);
__real_system_restart_local();
}
Expand Down