Skip to content

Commit a588d15

Browse files
author
Cruz Monrreal
authored
Merge pull request #7194 from mikaleppanen/lwip_debug_stack
Increased LWIP main worker thread stack size for debug builds
2 parents baf5637 + 48825aa commit a588d15

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

features/FEATURE_LWIP/lwip-interface/lwipopts.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,22 @@
9090
#define DEFAULT_RAW_RECVMBOX_SIZE 8
9191
#define DEFAULT_ACCEPTMBOX_SIZE 8
9292

93+
// Thread stacks use 8-byte alignment
94+
#define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
95+
9396
// Thread stack size for lwip tcpip thread
9497
#ifndef MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE
9598
#define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200
9699
#endif
97100

98101
#ifdef LWIP_DEBUG
99-
#define TCPIP_THREAD_STACKSIZE MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2
102+
// For LWIP debug, double the stack
103+
#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8)
104+
#elif MBED_DEBUG
105+
// When debug is enabled on the build increase stack 25 percent
106+
#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE + MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE / 4, 8)
100107
#else
101-
#define TCPIP_THREAD_STACKSIZE MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE
108+
#define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE, 8)
102109
#endif
103110

104111
#define TCPIP_THREAD_PRIO (osPriorityNormal)
@@ -114,11 +121,11 @@
114121
#endif
115122

116123
#ifdef LWIP_DEBUG
117-
#define DEFAULT_THREAD_STACKSIZE MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2
118-
#define PPP_THREAD_STACK_SIZE MBED_CONF_LWIP_PPP_THREAD_STACKSIZE*2
124+
#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8)
125+
#define PPP_THREAD_STACK_SIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_PPP_THREAD_STACKSIZE*2, 8)
119126
#else
120-
#define DEFAULT_THREAD_STACKSIZE MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE
121-
#define PPP_THREAD_STACK_SIZE MBED_CONF_LWIP_PPP_THREAD_STACKSIZE
127+
#define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE, 8)
128+
#define PPP_THREAD_STACK_SIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_PPP_THREAD_STACKSIZE, 8)
122129
#endif
123130

124131
#define MEMP_NUM_SYS_TIMEOUT 16

0 commit comments

Comments
 (0)