cancel
Showing results for 
Search instead for 
Did you mean: 

Iar compiler for stm32f

RKade.1
Associate III

Hi,

Am using Iar IDE for stm32f072rbt6 mcu, please help to know how to check if me controllers ram and ROM and data memory is filled to what level.

Also I want to check,if my heap and stack memory is filled or not?

​Please share how to check, how much memory is occupied.

Also share how to increase ​heap and stack memory?

Rohit​

6 REPLIES 6

Try the .MAP file.

You should also be able to determine linker symbols you can use and print out from your own code.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
RKade.1
Associate III

I got following information form Map file, please help to understand it in detail.

  •  43 380 bytes of readonly code memory
  •    289 bytes of readonly data memory
  •   6 645 bytes of readwrite data memory

ROM is showing here 2 sections "Data & Code", & RAM shows only "Data"memory, please help to understand where is Heap & where is Stack memory?

Shall i combine ROM memory both sections to have total ROM memory size?

Rohit

Surely the stack and heap have symbols? See CSTACK and HEAP sections

The sizes are typically defined in the .ICF file

/*-Sizes-*/

define symbol __ICFEDIT_size_cstack__  = 0x400;

define symbol __ICFEDIT_size_heap__   = 0x200;

..

define block CSTACK  with alignment = 8, size = __ICFEDIT_size_cstack__  { };

define block HEAP   with alignment = 8, size = __ICFEDIT_size_heap__   { };

startup.s

__vector_table

    DCD   sfe(CSTACK) ; address of the end of the CSTACK segment/section

http://www.iarsys.co.jp/download/LMS2/arm/7502/ewarm7502doc/arm/doc/EWARM_DevelopmentGuide.ENU.pdf

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Gudgel.boB
Senior

Isn't heap only used if memalloc() is used ?

Ooops... I mean malloc()

Thanks for information.

I have further query.

How to decide is stack full or getting overflowed or not?

Same for Heap also , how to decide Heap full or overflowing or not?

Also how much stack memory is used and how to ensure it is not leaking?

Same for Heap?

Rohit

Statically determining the stack size is black art.

The best way is either a profiler (if the toolchain comes with one), or instrumentation.

Fill your stack in the startup code with a specific pattern, and check that memory after you are sure the executed code covered all cases and situations.

The same would go for the heap, only it is determinable beforehand, supposedly.

> ... and how to ensure it is not leaking?

Not sure if such leakage checker applications exist for bare metal applications. I know them for Unix/Linux.

You might need instrument your code as well, "leakage" in a bare metal application highly depends on context.