esp_ping default stack is insufficient
esp_ping default stack is insufficient
Using ESP IDF 5.4.1 and esp_modem with the esp_ping reference code. The default ping task stack size using ESP_PING_DEFAULT_CONFIG() is 2.5K and with that stack size, I frequently get exceptions on ping_end (as the stack unwinds). Increasing the stack size to 4K completely eliminates the exceptions. Is there a way to determine the proper stack size?
-
MicroController
- Posts: 2661
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: esp_ping default stack is insufficient
uxTaskGetStackHighWaterMark() may help.Is there a way to determine the proper stack size?
Re: esp_ping default stack is insufficient
Thanks for the suggestion; I added the following to the esp_ping_thread()
Then printed the high water mark in my on_ping_end callback:
With the default stack size (2048+512), the code generally fails:
When I extend the stack by 64 bytes, it works and shows 20-28 bytes of stack remaining:
Code: Select all
if (ep->on_ping_end) {
// Check stack usage
UBaseType_t uxHighWaterMark;
uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );
ep->on_ping_end((esp_ping_handle_t)ep, (void *)uxHighWaterMark);
}
Code: Select all
printf("%lu packets transmitted, %lu received, time %lums hwm=%u\r\n", transmitted, received, total_time_ms, (unsigned int)args);
Code: Select all
64 bytes from 69.147.92.12 icmp_seq=1 ttl=58 time=204 ms
64 bytes from 69.147.92.12 icmp_seq=2 ttl=58 time=279 ms
64 bytes from 69.147.92.12 icmp_seq=3 ttl=58 time=230 ms
64 bytes from 69.147.92.12 icmp_seq=4 ttl=58 time=521 ms
64 bytes from 69.147.92.12 icmp_seq=5 ttl=58 time=217 ms
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x00060723 PS : 0x00060830 A0 : 0x8008b434 A1 : 0x3ffc9930
A2 : 0x3ffc8f90 A3 : 0x00000000 A4 : 0x3ffb36d0 A5 : 0x00060023
A6 : 0x00000001 A7 : 0x00000040 A8 : 0x80106e6c A9 : 0x3ffc9910
A10 : 0x3ffc8f90 A11 : 0x00000014 A12 : 0x3ffb0108 A13 : 0x0000001c
A14 : 0x3ffc8f90 A15 : 0x0000001c SAR : 0x0000001b EXCCAUSE: 0x00000014
EXCVADDR: 0x00060720 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffc
Backtrace: 0x00060720:0x3ffc9930 0x4008b431:0x3ffc9980
Code: Select all
ping_config.task_stack_size = 2624;
Code: Select all
64 bytes from 69.147.92.11 icmp_seq=1 ttl=58 time=218 ms
64 bytes from 69.147.92.11 icmp_seq=2 ttl=58 time=272 ms
64 bytes from 69.147.92.11 icmp_seq=3 ttl=58 time=231 ms
64 bytes from 69.147.92.11 icmp_seq=4 ttl=58 time=271 ms
64 bytes from 69.147.92.11 icmp_seq=5 ttl=58 time=231 ms
5 packets transmitted, 5 received, time 1223ms hwm=20
Who is online
Users browsing this forum: ChatGPT-User, Google [Bot], PerplexityBot and 11 guests