Increase stack size to 8192 bytes #8652
-
I have developed a tiny but powerful script language for the ESP8266 (supporting grammars and bult-in functions for int, double, unsigned, string and many other features). This little shell program works great. I use Arduino IDE and release 3.0.2. I am facing a problem related to the stack size. The standard size of the stack (4096 bytes) limits the power of the shell program. :stack_top :0x3fffefc0 My design is very optimized in terms of memory, but parsers and lexical analyzers in general make massive use of function calls and even frequently use recursion. So I would like to know if there is a way for increasing the dimension of the stack. I think that 8192 bytes would allow very decent levels of recursion for my program. I would have no problem to modify some parameters or files in the .arduino15 structure in order to define the new stack size, but I need some help in order to locate the place where I have to modify the source files (maybe a #define would be enough). Thanks in advance for your help, Luis |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
-edit, wrong core! - What I do for BearSSL which needs 6K+ of stack, is to just allocate a per-module stack and use stack thunking to swap stacks on-the-fly. Regular code runs normally. but when you call the SSL commands (or, say, your global parser routine) the SP is set to a new value in DRAM, the routine is called, and then the SP is reset back to the original value. See https://github.com/esp8266/Arduino/blob/master/cores/esp8266/StackThunk.cpp and https://github.com/esp8266/Arduino/blob/master/cores/esp8266/StackThunk.h |
Beta Was this translation helpful? Give feedback.
-edit, wrong core! -
What I do for BearSSL which needs 6K+ of stack, is to just allocate a per-module stack and use stack thunking to swap stacks on-the-fly. Regular code runs normally. but when you call the SSL commands (or, say, your global parser routine) the SP is set to a new value in DRAM, the routine is called, and then the SP is reset back to the original value.
See https://github.com/esp8266/Arduino/blob/master/cores/esp8266/StackThunk.cpp and https://github.com/esp8266/Arduino/blob/master/cores/esp8266/StackThunk.h