Hi ESP_iggr,ESP_igrr wrote:i don't think there's a way to do pull requests in gist, but you can "fork" any gist and do modifications in the fork, then post the link to your forked version for others to see.Just don't know how to make a pull request for your Gist.
Regarding stack size selection, indeed it is a not an easy problem, and there's no bulletproof solution.
In IDF, there are three methods for detecting stack overflows:
1. check that the stack pointer is valid when doing a context switch
2. check that stack canary is not corrupted when doing a context switch
3. set a debug watchpoint on the address at the end of the stack, this allows executing panic handler when stack overflow happens
We recommend keeping #2 and #3 enabled (which is the default behavior)
Corresponding Kconfig options are mentioned here: http://esp-idf.readthedocs.io/en/latest ... ckoverflow.
These methods are not 100% immune from failure. It is still possible to overshoot the stack end by such an amount that the canary check and watchpoint check will not be triggered. Such cases can indeed be hard to debug.
Looking forward, we plan to have more robust hardware mechanisms for stack bounds checking in future chips.
Related is a question about choosing the right stack size for a task. You need to have a stack which is large enough to allow for the worst case (deepest code path). At the same time, you don't want the stack to be much larger than required. We don't have a good method for making such choice automatically, but most often developers will use uxTaskGetStackHighWaterMark function to determine stack usage of their tasks, while testing the application to run through all possible code paths.
In the future, we are planning to look into automatic (dynamic) stack sizing through split-stacks feature of GCC. However, at the moment we don't have a timeline for such feature.
thousand Thanks for your clear answer. I will checkout my stack usage with the uxTaskGetStackHighWaterMark for this topic later. But as you see, there are many libraries (Linux) are written not that thin enough to fit into a 512KB RAM. But if I'd really start to trying something, I always start to testing libraries that I'm familiar with (which means, Linux based).
But, I'm looking forward, and trying my best to pick up many new embedded optimized / specialized libraries like mongoose to implementate my stuff.
Thanks again.
Cheers
Gfast2