This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Stack Tracing with softdevice

Hi,

I want to implement stack tracing to check stack overflow and remaining stack. I followed the implementation given in example github.com/.../memory_watcher.

Memory watcher code is not working when I am using softdevice S120 along with my application. But when I am using the same application without softdevice memory watcher code is working fine. Even GET_SP() is not working with softdevice. My application uses SDK 8.0.0., Softdevice S120 2.0.0 and ARMCC compilerV5.05.

Thanks

Parents
  • Hi Aryan,

    I found that Keil startup files do not expose the stack nor the heap location in memory. Till now the solution i implemented is:

    int main(void)
    {
    register uint32_t __regProcessStackPointer  __ASM("msp");
    	 stackStart = (uint32_t )__regProcessStackPointer;
    	 stackEnd = stackStart - 0x800; //stack size 2048
    }
    
    uint32_t getRemainingStack(void)
    {
    	uint32_t currentSP;
    	uint32_t stack;
    	register uint32_t __regProcessStackPointer  __ASM("msp");
    	 currentSP = (uint32_t )__regProcessStackPointer;
    	 stack = currentSP - stackEnd;
    	return (stack);
      while(1)
    {
      ////
    }
    return 0;
    }
    

    To get the stack usage periodically, getRemainingStack handler is called by app timer every 10ms. It is polling method. but idea was have get an exception whenever stack overflow happens.

    Thanks

Reply
  • Hi Aryan,

    I found that Keil startup files do not expose the stack nor the heap location in memory. Till now the solution i implemented is:

    int main(void)
    {
    register uint32_t __regProcessStackPointer  __ASM("msp");
    	 stackStart = (uint32_t )__regProcessStackPointer;
    	 stackEnd = stackStart - 0x800; //stack size 2048
    }
    
    uint32_t getRemainingStack(void)
    {
    	uint32_t currentSP;
    	uint32_t stack;
    	register uint32_t __regProcessStackPointer  __ASM("msp");
    	 currentSP = (uint32_t )__regProcessStackPointer;
    	 stack = currentSP - stackEnd;
    	return (stack);
      while(1)
    {
      ////
    }
    return 0;
    }
    

    To get the stack usage periodically, getRemainingStack handler is called by app timer every 10ms. It is polling method. but idea was have get an exception whenever stack overflow happens.

    Thanks

Children
No Data
Related