Skip to main content
RKade.1
Associate III
June 25, 2020
Question

Iar compiler for stm32f

  • June 25, 2020
  • 6 replies
  • 1256 views

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​

This topic has been closed for replies.

6 replies

Tesla DeLorean
Guru
June 25, 2020

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
RKade.1
RKade.1Author
Associate III
June 25, 2020

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

Tesla DeLorean
Guru
June 25, 2020

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
RKade.1
RKade.1Author
Associate III
June 26, 2020

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

Ozone
Principal
June 26, 2020

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.

Gudgel.boB
Senior
June 26, 2020

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

Ooops... I mean malloc()