From 5977bd37e1eaebffbe7da9dae21397d1d31a3a24 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 24 Aug 2018 11:30:16 +0200 Subject: [PATCH] Fix xdrv_99_debug.ino compilation Fix xdrv_99_debug.ino compilation error on core 2.4.2 (#3566) --- sonoff/xdrv_99_debug.ino | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sonoff/xdrv_99_debug.ino b/sonoff/xdrv_99_debug.ino index 5aa1f4231..8a167511c 100644 --- a/sonoff/xdrv_99_debug.ino +++ b/sonoff/xdrv_99_debug.ino @@ -180,6 +180,9 @@ void CpuLoadLoop() /*******************************************************************************************/ +#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) +// All version before core 2.4.2 + extern "C" { #include extern cont_t g_cont; @@ -198,6 +201,28 @@ void DebugFreeMem() AddLog(LOG_LEVEL_DEBUG); } +#else +// All version from core 2.4.2 +// https://github.com/esp8266/Arduino/pull/5018 +// https://github.com/esp8266/Arduino/pull/4553 + +extern "C" { +#include + extern cont_t* g_pcont; +} + +void DebugFreeMem() +{ +// https://github.com/esp8266/Arduino/issues/2557 + register uint32_t *sp asm("a1"); + + snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), + ESP.getFreeHeap(), 4 * (sp - g_pcont->stack), XdrvMailbox.data); + AddLog(LOG_LEVEL_DEBUG); +} + +#endif // ARDUINO_ESP8266_RELEASE_2_x_x + /*******************************************************************************************/ void DebugCfgDump(char* parms)