Skip to content

Commit 2bb78a9

Browse files
feat(udp): Allow to change the async_udp task stack size (#12003)
Example: `-D CONFIG_ARDUINO_UDP_TASK_STACK_SIZE=2048` The default is to much conservative since a correctly developed app probably won't allocate too much on stack on the callbacks. I currently see a wast of memory: `I (1222501) MONITOR: async_udp (p=3) 3416 bytes`
1 parent af4dbf9 commit 2bb78a9

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Kconfig.projbuild

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ config ARDUINO_UDP_TASK_PRIORITY
147147
help
148148
Select at what priority you want the UDP task to run.
149149

150+
config ARDUINO_UDP_TASK_STACK_SIZE
151+
int "UDP task stack size"
152+
default 4096
153+
help
154+
Amount of stack available for the UDP task.
155+
150156
config ARDUINO_ISR_IRAM
151157
bool "Run interrupts in IRAM"
152158
default "n"

libraries/AsyncUDP/src/AsyncUDP.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@ extern "C" {
1515

1616
#include "lwip/priv/tcpip_priv.h"
1717

18+
#ifndef CONFIG_ARDUINO_UDP_TASK_STACK_SIZE
19+
#define CONFIG_ARDUINO_UDP_TASK_STACK_SIZE 4096
20+
#endif
21+
#ifndef ARDUINO_UDP_TASK_STACK_SIZE
22+
#define ARDUINO_UDP_TASK_STACK_SIZE CONFIG_ARDUINO_UDP_TASK_STACK_SIZE
23+
#endif
24+
25+
#ifndef CONFIG_ARDUINO_UDP_TASK_PRIORITY
26+
#define CONFIG_ARDUINO_UDP_TASK_PRIORITY 3
27+
#endif
28+
#ifndef ARDUINO_UDP_TASK_PRIORITY
29+
#define ARDUINO_UDP_TASK_PRIORITY CONFIG_ARDUINO_UDP_TASK_PRIORITY
30+
#endif
31+
32+
#ifndef CONFIG_ARDUINO_UDP_RUNNING_CORE
33+
#define CONFIG_ARDUINO_UDP_RUNNING_CORE -1
34+
#endif
35+
#ifndef ARDUINO_UDP_RUNNING_CORE
36+
#define ARDUINO_UDP_RUNNING_CORE CONFIG_ARDUINO_UDP_RUNNING_CORE
37+
#endif
38+
1839
#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING
1940
#define UDP_MUTEX_LOCK() \
2041
if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) { \
@@ -189,7 +210,7 @@ static bool _udp_task_start() {
189210
}
190211
if (!_udp_task_handle) {
191212
xTaskCreateUniversal(
192-
_udp_task, "async_udp", 4096, NULL, CONFIG_ARDUINO_UDP_TASK_PRIORITY, (TaskHandle_t *)&_udp_task_handle, CONFIG_ARDUINO_UDP_RUNNING_CORE
213+
_udp_task, "async_udp", ARDUINO_UDP_TASK_STACK_SIZE, NULL, ARDUINO_UDP_TASK_PRIORITY, (TaskHandle_t *)&_udp_task_handle, ARDUINO_UDP_RUNNING_CORE
193214
);
194215
if (!_udp_task_handle) {
195216
return false;

0 commit comments

Comments
 (0)