remove crash recorder from safeboot (#21332)

* remove crash recorder from safeboot

* small refactor
This commit is contained in:
Jason2866 2024-05-03 14:47:14 +02:00 committed by GitHub
parent 6f20dcd0ed
commit 9b8cd42e5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 3 deletions

View File

@ -1,5 +1,7 @@
Import('env') Import('env')
build_flags = " ".join(env.GetProjectOption("build_flags"))
# #
# Dump build environment (for debug) # Dump build environment (for debug)
#print env.Dump() #print env.Dump()
@ -8,6 +10,10 @@ Import('env')
flags = " ".join(env['LINKFLAGS']) flags = " ".join(env['LINKFLAGS'])
flags = flags.replace("-u _printf_float", "") flags = flags.replace("-u _printf_float", "")
flags = flags.replace("-u _scanf_float", "") flags = flags.replace("-u _scanf_float", "")
if "FIRMWARE_SAFEBOOT" in build_flags:
# Crash Recorder is not included in safeboot firmware -> remove Linker wrap
flags = flags.replace("-Wl,--wrap=panicHandler", "")
flags = flags.replace("-Wl,--wrap=xt_unhandled_exception", "")
newflags = flags.split() newflags = flags.split()
env.Replace( env.Replace(

View File

@ -812,7 +812,9 @@ void CmndStatus(void)
if (payload > MAX_STATUS) { return; } // {"Command":"Error"} if (payload > MAX_STATUS) { return; } // {"Command":"Error"}
if (!Settings->flag.mqtt_enabled && (6 == payload)) { return; } // SetOption3 - Enable MQTT if (!Settings->flag.mqtt_enabled && (6 == payload)) { return; } // SetOption3 - Enable MQTT
if (!TasmotaGlobal.energy_driver && (9 == payload)) { return; } if (!TasmotaGlobal.energy_driver && (9 == payload)) { return; }
#ifndef FIRMWARE_SAFEBOOT
if (!CrashFlag() && (12 == payload)) { return; } if (!CrashFlag() && (12 == payload)) { return; }
#endif // FIRMWARE_SAFEBOOT
if (!Settings->flag3.shutter_mode && (13 == payload)) { return; } if (!Settings->flag3.shutter_mode && (13 == payload)) { return; }
char stemp[200]; char stemp[200];
@ -1042,6 +1044,7 @@ void CmndStatus(void)
CmndStatusResponse(11); CmndStatusResponse(11);
} }
#ifndef FIRMWARE_SAFEBOOT
if (CrashFlag()) { if (CrashFlag()) {
if ((0 == payload) || (12 == payload)) { if ((0 == payload) || (12 == payload)) {
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS12_STATUS "\":")); Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS12_STATUS "\":"));
@ -1050,6 +1053,7 @@ void CmndStatus(void)
CmndStatusResponse(12); CmndStatusResponse(12);
} }
} }
#endif // FIRMWARE_SAFEBOOT
#ifdef USE_SHUTTER #ifdef USE_SHUTTER
if ((0 == payload) || (13 == payload)) { if ((0 == payload) || (13 == payload)) {
@ -1252,6 +1256,7 @@ void CmndRestart(void)
TasmotaGlobal.restart_deepsleep = true; TasmotaGlobal.restart_deepsleep = true;
ResponseCmndChar(PSTR("Go to sleep")); ResponseCmndChar(PSTR("Go to sleep"));
break; break;
#ifndef FIRMWARE_SAFEBOOT
case -1: case -1:
CmndCrash(); // force a crash CmndCrash(); // force a crash
break; break;
@ -1261,6 +1266,7 @@ void CmndRestart(void)
case -3: case -3:
CmndBlockedLoop(); CmndBlockedLoop();
break; break;
#endif // FIRMWARE_SAFEBOOT
case 99: case 99:
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
EspRestart(); EspRestart();

View File

@ -17,6 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FIRMWARE_SAFEBOOT
// Generate a crash to test the crash recorder // Generate a crash to test the crash recorder
void CmndCrash(void) void CmndCrash(void)
{ {
@ -359,5 +361,7 @@ void CrashDump(void)
{ {
} }
#endif #endif
#endif #endif
#endif // FIRMWARE_SAFEBOOT

View File

@ -1159,7 +1159,9 @@ void WifiDisable(void) {
void EspRestart(void) { void EspRestart(void) {
ResetPwm(); ResetPwm();
WifiShutdown(true); WifiShutdown(true);
#ifndef FIRMWARE_SAFEBOOT
CrashDumpClear(); // Clear the stack dump in RTC CrashDumpClear(); // Clear the stack dump in RTC
#endif // FIRMWARE_SAFEBOOT
#ifdef CONFIG_IDF_TARGET_ESP32C3 #ifdef CONFIG_IDF_TARGET_ESP32C3
GpioForceHoldRelay(); // Retain the state when the chip or system is reset, for example, when watchdog time-out or Deep-sleep GpioForceHoldRelay(); // Retain the state when the chip or system is reset, for example, when watchdog time-out or Deep-sleep

View File

@ -1018,9 +1018,12 @@ void MqttConnected(void) {
} }
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
Response_P(PSTR("{\"Info3\":{\"" D_JSON_RESTARTREASON "\":")); Response_P(PSTR("{\"Info3\":{\"" D_JSON_RESTARTREASON "\":"));
#ifndef FIRMWARE_SAFEBOOT
if (CrashFlag()) { if (CrashFlag()) {
CrashDump(); CrashDump();
} else { } else
#endif // FIRMWARE_SAFEBOOT
{
ResponseAppend_P(PSTR("\"%s\""), GetResetReason().c_str()); ResponseAppend_P(PSTR("\"%s\""), GetResetReason().c_str());
} }
ResponseAppend_P(PSTR(",\"" D_JSON_BOOTCOUNT "\":%d}}"), Settings->bootcount +1); ResponseAppend_P(PSTR(",\"" D_JSON_BOOTCOUNT "\":%d}}"), Settings->bootcount +1);