8000 Reduce mem footprint of ESP.getResetInfo() (#7030) · esp8266/Arduino@158039e · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 158039e

Browse files
dirkmuellerearlephilhower
authored andcommitted
Reduce mem footprint of ESP.getResetInfo() (#7030)
This function has excessively long datastrings that can better be stored in flash, reducing runtime memory footprint. Also detailed formatting only makes sense when there is an exception or a watchdog. In other cases instead of printing an unhelpful "flag: 0" we can just return the ResetReason, which is much more readable. Saves about 120 bytes of (data) memory.
1 parent 00440cd commit 158039e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cores/esp8266/Esp.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,12 +490,14 @@ String EspClass::getResetReason(void) {
490490
}
491491

492492
String EspClass::getResetInfo(void) {
493-
if(resetInfo.reason != 0) {
493+
if (resetInfo.reason >= REASON_WDT_RST && resetInfo.reason <= REASON_SOFT_WDT_RST) {
494494
char buff[200];
495-
sprintf(&buff[0], "Fatal exception:%d flag:%d (%s) epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, (resetInfo.reason == 0 ? "DEFAULT" : resetInfo.reason == 1 ? "WDT" : resetInfo.reason == 2 ? "EXCEPTION" : resetInfo.reason == 3 ? "SOFT_WDT" : resetInfo.reason == 4 ? "SOFT_RESTART" : resetInfo.reason == 5 ? "DEEP_SLEEP_AWAKE" : resetInfo.reason == 6 ? "EXT_SYS_RST" : "???"), resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
495+
sprintf_P(buff, PSTR("Fatal exception:%d flag:%d (%s) epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x"),
496+
resetInfo.exccause, resetInfo.reason, getResetReason().c_str(),
497+
resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
496498
return String(buff);
497499
}
498-
return String("flag: 0");
500+
return getResetReason();
499501
}
500502

501503
struct rst_info * EspClass::getResetInfoPtr(void) {

0 commit comments

Comments
 (0)
0