mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
read the rst reason from the SDK if stored.
add String getResetInfo(void); and struct rst_info * getResetInfoPtr(void);
This commit is contained in:
parent
1d2b85ec0e
commit
dc52cf82c5
@ -22,6 +22,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
|
||||
extern struct rst_info resetInfo;
|
||||
}
|
||||
|
||||
//extern "C" void ets_wdt_init(uint32_t val);
|
||||
@ -279,3 +281,16 @@ uint32_t EspClass::getFlashChipSizeByChipId(void) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
String EspClass::getResetInfo(void) {
|
||||
if(resetInfo.reason != 0) {
|
||||
char buff[150];
|
||||
sprintf(&buff[0], "Fatal exception:%d flag:%d epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
|
||||
return String(buff);
|
||||
}
|
||||
return String("flag: 0");
|
||||
}
|
||||
|
||||
struct rst_info * EspClass::getResetInfoPtr(void) {
|
||||
return &resetInfo;
|
||||
}
|
||||
|
@ -98,6 +98,9 @@ class EspClass {
|
||||
FlashMode_t getFlashChipMode(void);
|
||||
uint32_t getFlashChipSizeByChipId(void);
|
||||
|
||||
String getResetInfo(void);
|
||||
struct rst_info * getResetInfoPtr(void);
|
||||
|
||||
inline uint32_t getCycleCount(void);
|
||||
};
|
||||
|
||||
|
@ -34,6 +34,8 @@ extern "C" {
|
||||
#define LOOP_TASK_PRIORITY 0
|
||||
#define LOOP_QUEUE_SIZE 1
|
||||
|
||||
struct rst_info resetInfo;
|
||||
|
||||
int atexit(void (*func)()) {
|
||||
return 0;
|
||||
}
|
||||
@ -124,6 +126,15 @@ void user_rf_pre_init() {
|
||||
|
||||
extern "C" {
|
||||
void user_init(void) {
|
||||
uart_div_modify(0, UART_CLK_FREQ / (74480));
|
||||
|
||||
system_rtc_mem_read(0, &resetInfo, sizeof(struct rst_info));
|
||||
if(resetInfo.reason == WDT_RST_FLAG || resetInfo.reason == EXCEPTION_RST_FLAG) {
|
||||
os_printf("Last Reset:\n - flag=%d\n - Fatal exception (%d):\n - epc1=0x%08x,epc2=0x%08x,epc3=0x%08x,excvaddr=0x%08x,depc=0x%08x\n", resetInfo.reason, resetInfo.exccause, resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
|
||||
}
|
||||
struct rst_info info = { 0 };
|
||||
system_rtc_mem_write(0, &info, sizeof(struct rst_info));
|
||||
|
||||
uart_div_modify(0, UART_CLK_FREQ / (115200));
|
||||
|
||||
init();
|
||||
|
Loading…
x
Reference in New Issue
Block a user