Keil Logo

ARM: Setting flashloader stack size with STACK_SIZE define not working


Information in this knowledgebase article applies to:

  • MDK-ARM

SYMPTOM

I develop a custom flash programming algorithms. The functions of the algorithm require a certain stack size while they run, so I need to specify the stack size somewhere in the algorithm source.

In some of the example/supplied algorithms there is a STACK_SIZE define, which seems to be used to do this. But when I use it in my flash loader, it has no effect. What is the problem?

CAUSE

µVision looks for a symbol "STACK_SIZE" in the debug information of the flash loader file. However, for a #define, the current toolchain does not generate the required symbol. So, µVision will not recognize the STACK_SIZE define and assumes the default stack size of 64 bytes.

RESOLUTION

This can be solved by increasing the RAM used for the algorithm. Stack is placed at the end of the RAM the algorithm uses, so rather than using the minimum RAM size detected by µVision, specify a larger area to accommodate extra stack. Make sure, however, there is enough RAM for stack > 64 bytes.

If the stack size check is important and/or to avoid mysterious errors while flash programming, the required symbol can be created by using a small assembler file containing:

    EXPORT STACK_SIZE
STACK_SIZE EQU 0x1000
    END

as part of the algorithm project to specify a custom stack size. With this, µVision can check for the desired stack size when loading the algorithm to the target.

MORE INFORMATION

Last Reviewed: Tuesday, April 4, 2017


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.