SNTP task crash
Posted: Fri May 03, 2024 12:00 pm
Hi, I have successfully integrated SNTP as per github sample (https://github.com/espressif/esp-idf/tr ... ocols/sntp).
I'm using default options, without SNTP over DHCP with pool.ntp.org as unique time server.
On WiFi connection I start an rtos task to monitor time acquisition.
The task method is the following:
Sometimes it takes some times to synchronize time (10/15s) after wifi connection. When this happen and the task code reach the vTaskDelete instruction the firmware reboot with this exception:
assert failed: heap_caps_free heap_caps.c:387 (heap != NULL && "free() target pointer is outside heap areas")
Backtrace: 0x40081aea:0x3ffbb390 0x40089ed9:0x3ffbb3b0 0x40091221:0x3ffbb3d0 0x400823a3:0x3ffbb4f0 0x40091269:0x3ffbb510 0x4015f16a:0x3ffbb530 0x4008af01:0x3ffbb550 0x4008afc7:0x3ffbb570 0x4008b0a7:0x3ffbb590 0x4008c8b9:0x3ffbb5b0
0x40081aea: panic_abort at /Users/paolo/esp/esp-idf/components/esp_system/panic.c:452
0x40089ed9: esp_system_abort at /Users/paolo/esp/esp-idf/components/esp_system/port/esp_system_chip.c:84
0x40091221: __assert_func at /Users/paolo/esp/esp-idf/components/newlib/assert.c:81
0x400823a3: heap_caps_free at /Users/paolo/esp/esp-idf/components/heap/heap_caps.c:387 (discriminator 1)
0x40091269: _free_r at /Users/paolo/esp/esp-idf/components/newlib/heap.c:49
0x4015f16a: _reclaim_reent at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/reent/reent.c:87
0x4008af01: prvDeleteTCB at /Users/paolo/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4913
0x4008afc7: prvCheckTasksWaitingTermination at /Users/paolo/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4621
0x4008b0a7: prvIdleTask at /Users/paolo/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4278 (discriminator 1)
0x4008c8b9: vPortTaskWrapper at /Users/paolo/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162
If time acquisition is fast (2/3s) no exception will be throw.
Can someone help me to understand what is happeing and how can i deebug further?
IDF-Version: 5.1.1
board: esp32 wroom
Thank you.
I'm using default options, without SNTP over DHCP with pool.ntp.org as unique time server.
On WiFi connection I start an rtos task to monitor time acquisition.
The task method is the following:
- static void wifi_manager_sync_time_task(void *arg) {
- time_t now = 0;
- struct tm timeinfo = { 0 };
- while (esp_netif_sntp_sync_wait(3000 / portTICK_PERIOD_MS) != ESP_OK) {
- ESP_LOGI(TAG, "Waiting for system time to be set...");
- }
- time(&now);
- localtime_r(&now, &timeinfo);
- char strftime_buf[64];
- strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
- ESP_LOGI(TAG, "The current UTC date/time is: %s", strftime_buf);
- vTaskDelete(NULL);
- }
assert failed: heap_caps_free heap_caps.c:387 (heap != NULL && "free() target pointer is outside heap areas")
Backtrace: 0x40081aea:0x3ffbb390 0x40089ed9:0x3ffbb3b0 0x40091221:0x3ffbb3d0 0x400823a3:0x3ffbb4f0 0x40091269:0x3ffbb510 0x4015f16a:0x3ffbb530 0x4008af01:0x3ffbb550 0x4008afc7:0x3ffbb570 0x4008b0a7:0x3ffbb590 0x4008c8b9:0x3ffbb5b0
0x40081aea: panic_abort at /Users/paolo/esp/esp-idf/components/esp_system/panic.c:452
0x40089ed9: esp_system_abort at /Users/paolo/esp/esp-idf/components/esp_system/port/esp_system_chip.c:84
0x40091221: __assert_func at /Users/paolo/esp/esp-idf/components/newlib/assert.c:81
0x400823a3: heap_caps_free at /Users/paolo/esp/esp-idf/components/heap/heap_caps.c:387 (discriminator 1)
0x40091269: _free_r at /Users/paolo/esp/esp-idf/components/newlib/heap.c:49
0x4015f16a: _reclaim_reent at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/reent/reent.c:87
0x4008af01: prvDeleteTCB at /Users/paolo/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4913
0x4008afc7: prvCheckTasksWaitingTermination at /Users/paolo/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4621
0x4008b0a7: prvIdleTask at /Users/paolo/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4278 (discriminator 1)
0x4008c8b9: vPortTaskWrapper at /Users/paolo/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162
If time acquisition is fast (2/3s) no exception will be throw.
Can someone help me to understand what is happeing and how can i deebug further?
IDF-Version: 5.1.1
board: esp32 wroom
Thank you.