2024-11-10 06:16 PM
I'm using STM32CubeIDE to develop a FreeRTOS application. Sometimes FreeRTOS reports stack overflow for a task at run time.
STM32CubeIDE's Static Stack Analyzer is very useful for analyzing the problem. Even so, I would prefer avoiding the problem at compile time. I need the compile tools to report a warning when a task function's maximum stack usage exceeds a value.
Is Static Stack Analyzer implemented in STM32CubeIDE, or is it implemented in a standalone tool like gcc/objdump/readelf? How to enable the warning if a function's maximum stack usage exceeds a value, either via graphic or command line option? Thanks very much.
2024-11-11 12:52 AM
Hello @fzl ,
Static Stack Analyzer in STM32CubeIDE is a post-compilation tool and does not provide compile-time warnings. GCC's -fstack-usage flag can be used to generate stack usage information during compilation.
to activate it do the follwing steps.
In STM32CubeIDE, you can add this flag by:
Regards
2024-11-11 04:13 PM
Thanks for the reply. -fstack-usage is already checked by default in STM32CubeIDE. From my understanding, gcc -fstack-usage reports the stack usage of single functions, not including the stack used by subfunction calls. STM32CubeIDE may have a plugin that analyzes the .su files generated by gcc -fstack-usage, sums up the stack usage in function call chains, and calculates the maximum stack usage. I think it will be very nice to have an option to enable the warning if this tool finds out a maximum stack usage that exceeds a value.