2020-06-25 10:44 AM
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
2020-06-25 10:51 AM
Try the .MAP file.
You should also be able to determine linker symbols you can use and print out from your own code.
2020-06-25 11:16 AM
I got following information form Map file, please help to understand it in detail.
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
2020-06-25 12:22 PM
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
2020-06-25 10:49 PM
Isn't heap only used if memalloc() is used ?
Ooops... I mean malloc()
2020-06-25 11:32 PM
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
2020-06-26 12:00 AM
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.