m_data region overflowed on KL25Z

cancel
Showing results for 
Search instead for 
Did you mean: 

m_data region overflowed on KL25Z

878 Views
mr_max
Contributor IV

Hello community Smiley Happy

I am currently working on project which use KSDKv2 and FreeRTOS on FRDM-KL25Z.  So everything look good until I got this error message on console :

... arm-none-eabi/bin/ld.exe: KL25Z-KSDK2_mvp_v0-2.elf section `.stack' will not fit in region `m_data'

... arm-none-eabi/bin/ld.exe: region m_data overflowed with stack and heap

... arm-none-eabi/bin/ld.exe: region `m_data' overflowed by 8 bytes

No joke, I overflowed m_data space of the freedom board. So, I checked the linker file MKL25Z128xxx4_flash.ld and found these lines :

/* Specify the memory areas */

MEMORY

{

  m_interrupts          (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00000200

  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010

  m_text                (RX)  : ORIGIN = 0x00000410, LENGTH = 0x0001FBF0

  m_data                (RW)  : ORIGIN = 0x1FFFF000, LENGTH = 0x00004000

}

My first thought was to increase m_data LENGTH. And after modification, the compile occurred with no error but I am not very sure if it is the best way. Because between m_data ORIGIN and LENGTH there is by default a gap of 16 384 which is the RAM size of the my Freedom board (KL25) ...

So if I increase the LENGTH it will not be what I have in my RAM in reality.  Am I Right ?

Does someone can confirm this please ?

0 Kudos
3 Replies

100 Views
scottm
Senior Contributor I

You're right that you can't extend LENGTH because there's no more RAM there.  Even on other Kinetis parts that have a block of memory past the 0x2000 0000 boundary you have to be careful that nothing spans the boundary since they're separate blocks of RAM.  Not an issue here, but watch out if you upgrade.

You're just out of memory.  First thing to do is to check the linker map file and see what's taking up all of the space.  You should be able to find it in the same directory as the .elf file.

Scott

0 Kudos

100 Views
bobpaddock
Senior Contributor II

Actually the best approach would be to reduce the size of RAM being used.

What is consuming so much of the RAM?  Large arrays?

Even if the program compiled without error, after reducing RAM usage by eight bytes as the error message indicates, the system would crash as there is no RAM left for the stack.  Estimating stack size is always a problem, unless you read lots of academic papers about the subject, until actually usage can be measured.  Stack size always depends on the application.    Figure at least 1K as a minimum starting stack size.

0 Kudos

100 Views
mr_max
Contributor IV

up :smileylaugh: !

0 Kudos