How can I increase the stack size in my linker file??

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How can I increase the stack size in my linker file??

4,807件の閲覧回数
clivepalmer
Contributor III

Hi,

I am using a KL02Z32 (although will be using a KL02Z16) soon. I seem to have hit a limit on my stack size. If I increase it then I will get a link error (overflow) because it will not fit into m_data2.

I have messed around and to date have failed miserably with what I thought was a simple task. I'm sure I am being a little stupid. How do I increase my heap / stack allocation?

I cannot work with the stack this small.

Any help much appreciated.

A snippet of my linker file is:-

/* Generate a link error if heap and stack don't fit into RAM */
__heap_size = 0x100;    /* required amount of heap  */
__stack_size = 0x100;     /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
  m_interrupts (rx) : ORIGIN = 0x00000000, LENGTH = 0xC0
  m_cfmprotrom  (rx) : ORIGIN = 0x00000400, LENGTH = 0x10
  m_text   (rx) : ORIGIN = 0x00000800, LENGTH = 32K - 0x800
  m_data     (rwx) : ORIGIN = 0x1FFFFC00, LENGTH = 1K   /* Lower SRAM */
  m_data2    (rwx) : ORIGIN = 0x20000000, LENGTH = 4K   /* Upper SRAM */
}

0 件の賞賛
返信
4 返答(返信)

3,511件の閲覧回数
clivepalmer
Contributor III

Thanks. I have attached my linker file (hopefully) if this helps.

0 件の賞賛
返信

3,511件の閲覧回数
clivepalmer
Contributor III

I think I sorted it Bob. I have reduced my lower SRAM start value and then adjusted the start of upper SRAM start accordingly. By making it bigger it seems to allow me to increase my stack.

0 件の賞賛
返信

3,511件の閲覧回数
bobpaddock
Senior Contributor III

The linker scripts linage vary so we can't really help without seeing the part that deals with the heap and stack at the end of the linker script.

Here is a snipped of mine, for a different part:

MEMORY
{
/*
* The linker will place into the text memory region every section which
* is not explicitly mapped into a memory region, and is either
* read-only or executable.
*/
  VECTORS   (rx)   : ORIGIN = 0x0,         LENGTH = 0x000000C0
  FLASHCFG  (rx)   : ORIGIN = 0x00000400,  LENGTH = 16
  FLASH     (rx)   : ORIGIN = 0x00000410,  LENGTH = 128K - 1K - 0x410 /* Flash size - EEPROM Sim size - vectors and Flash Config bytes */
  EEPROMSIM (rx)   : ORIGIN = 0x0001FC00,  LENGTH = 1K /* Smallest sector size that can be erased on this part.  Place to store simulated EEPROM constants */
/*
  NOINIT   (rwx)  : ORIGIN = 0x1FFFF000,  LENGTH = 0x200
*/
  RAM      (rwx)  : ORIGIN = 0x1FFFF000,  LENGTH = 16K /* Internal SRAM.  flash_kinetis_cmd executes out of RAM */
}

[everything else here that consumes Flash or RAM]

    .heap :
    {
       . = ALIGN(4);
        __end__ = .;
        end = __end__;
        __heap_start = .;
        *(.heap*)
        . = ALIGN(4);
        __heap_end = .;
    } > RAM

    /* Set stack top to end of RAM */
    __StackTop = ORIGIN(RAM) + LENGTH(RAM);
    __StackLimit = __StackTop - 1k;
    PROVIDE(__stack = __StackTop);

    /* Check if data + heap + stack exceeds RAM limit: */
    ASSERT(__StackLimit >= __heap_end, "Region RAM overflowed with stack")

3,511件の閲覧回数
clivepalmer
Contributor III

I should add that I'm not using processor expert.

0 件の賞賛
返信