
Detecting stackoverflow on AVR MCUs is hard. Especially since it causes undefined behaviour, its hard to specifically tell that the problem was because of a stack overflow issue.
[Backstory]
A while ago i was trying to write driver code from scratch for a SSD_1306 display module and I was facing some issues. A deep dive made me find out that it was the main() function allocating a large amount of stack that it collided with the .bss section of the SRAM, corrupting framebuffer values that was meant to be sent to the display.
So, I built a CLI based static stack analyzer for AVR MCUs which generates function call graph and static stack usage by analyzing assembly codes.
Currently it only can :
- Generate plain stack usage (doesnt take into account of function call depth atm)
- Detect and Simulate Recursion Call depth
- Generate function call graph
Note : the CLI doesnt specifically tell you that you got a stack overflow. It only tells you the stack usage.
You can check out the repo at : IsaacAneek/avrstkchk: A simple static stack analyzer for AVR microcontrollers
any feedback would be heavily appreciated