fayes:
Hi all, I think have the same problem with the sprintf as discuss previously in this forum. Using the development boar from ALIMEX, SAM-PXXX, ARM-USB-OCD jtag. At the last discussion, mentioned about changing the size of stack. How do I do so ?
At the moment I am using sample program from James P Lynch for the testing. I try to find the stack size definition in “crt.s” and found as bellow :
/* Stack Sizes */
.set UND_STACK_SIZE, 0x00000010 /* stack for “undefined instruction” interrupts is 16 bytes */
.set ABT_STACK_SIZE, 0x00000010 /* stack for “abort” interrupts is 16 bytes */
.set FIQ_STACK_SIZE, 0x00000080 /* stack for “FIQ” interrupts is 128 bytes */
.set IRQ_STACK_SIZE, 0X00000080 /* stack for “IRQ” normal interrupts is 128 bytes */
.set SVC_STACK_SIZE, 0x00000080 /* stack for “SVC” supervisor mode is 128 bytes */
My question is which stack location which the sprintf function use ?
How do I sure when changing the stack size, will not overflow ?
Thanks all
fayes
What you have shown only defines some of the stack sizes, but not their actual placement in memory. As for which stack sprintf is using, it depends on which mode you are actually running in, which you have not shown. When your code sets up the stack locations, that defines the starting point for each stack you set up, and then it will grow downwards from that point as your code uses it. I normally define the stack for the mode that I will run in last, so that it can grow downward toward the heap. That will give the running mode stack the largest size possible. That still leaves the possibility of stacks corrupting each other though.
You are probably running in USER mode, SYSTEM mode, or SUPERVISOR mode, but you have only shown the definition of SUPERVISOR mode. The mode that you are actually going to run in does not actually need to have a size definition if it is placed below the other stacks, since it will just grow down toward the heap. That sort of implies that you are actually running in USER mode or SYSTEM mode if your startup defines stacks with the running mode stack at the lowest position. That would be where sprintf is using stack space, unless you are calling it from an interrupt service routine, which is something that I would not want to do myself.
As for your last question, only you can know how much data you are placing on your stacks with local variables and calls, so you would need to calculate your stack sizes based on your knowledge of what your code is doing.
–Dave