ESP_Sprite wrote: ↑
Thu May 16, 2019 2:02 am
Not really... usually, when a stack overflow happens, it is detected after the fact and random data from other tasks or the OS already has been overwritten. This means the stability of the system can't be relied upon anymore and it would not be a smart idea to do complicated stuff like uploading logs. Instead, I'd suggest you just allow the ESP32 to crash but to configure the panic handler in such a way that it writes a core dump to flash. Then, after the reboot, detect that the core dump is there and upload it to a server.
I only need to save it in variable to AFTER reboot, log. Please, tell me if this can interfere in something.
I did some test's and worked nicelly, but if you know something interference (in panic handler/etc) what this can do in, tell me.
Code: Select all
volatile RTC_NOINIT_ATTR int16_t lt_sys_reset;//Global var
RTC_NOINIT_ATTR char lt_sys_tsk_ovf;//Global var
extern "C" void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )
snprintf(lt_sys_tsk_ovf, 16, "%s", pcTaskName);
lt_sys_reset = 21;
ets_printf("***ERROR*** A stack overflow in task ");
ets_printf(" has been detected.\r\n");
1. When overflow occur, this hook (I found in panic.c) is called and has weak attribute, then, I modified to my main.c .
2. Changed panicPutStr() to ets_printf()
3. Added 2 lines to copy task name and reset reason to RTC_NOINIT_ATTR global vars (21 = task overflow in my code).
4. After restart (abort()), RTC_NOINIT still intact (by my CRC) and will LOG in flash reset reason is task overflow and name. See image bellow that all worked:
This changeds lines can bug sw DURING panic handler?