Hello everyone,I'm encountering a new failure in my application running on NIOS-II/e (DE-1 EP2C20). As my app grows (every time I add a new function), some parts of my app will go fail during run-time (Its totally random), and there is no warning or error during compilation nor by JTAG-Debugger. Even when I change the position of functions dentition in my code, failures change during run-time. My code is more than 2000 physical lines of code. I doubt that maybe during run-time, return stack or data stack is overwritten. I did NOT use dynamic memory allocation nor recursive functions in my app. Optimization setting is set on SIZE. If I change it, my program will not fit in the memory (16384 Bytes). Please help me if you have any idea or solved this issue before. Warm regards, Amir.
A common technique to test for a stack and heap collision is to fill up the memory where the stack and heap reside with a known pattern like 0x5A5A5A5A before your code goes to access data on the stack and heap. Then you let the processor run for a bit and stop it, take a peak at the memory to see if your pattern can be found anywhere. If you can't find the pattern then the stack and heap probably collided and resulted in the CPU going off into the weeds.Have you attempted other code footprint reduction optimizations? Download the software manual for Nios II and search for "footprint". There should be a section that talks about other things you can do to the BSP to reduce the code size further at the expense of functionality/speed.