Hello, I want to track boundaries for Heap and Stack in my RAM, I tried reading .axf file using 'readelf' but unable to find.
Please find screenshot of readelf output and memory map of MCU arm cortex m4 in below links.
https://ibb.co/ctmtvcS https://ibb.co/98fh6z5
Thanks
Please explain what you mean by that?
If you want to monitor Stack & Heap usage in real time as the code runs, the AXF file is not going to help you with that ...
The AXF file just reflects what you configured in your Project:
www.keil.com/.../armlink_pge1362065977713.htm
Does this help you: http://www.keil.com/appnotes/files/apnt_316.pdf ?
You're going to need to look at the exported symbols, not the sections in the .ELF/AXF file Perhaps review the .MAP file, where the linker tells you where it put stuff. You define the stack/heap size in the startup_stm32xxx.s file
EXPORT Stack_Size EXPORT Stack_Mem Stack_Size EQU 0x1000 AREA STACK, NOINIT, READWRITE, ALIGN=3 Stack_Mem SPACE Stack_Size __initial_sp ... Heap_Size EQU 0x200 AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit
You could export the heap base/size. You could walk the allocation structures. You can dynamically check the maximal stack depth
I want to know allocated boundaries of heap and stack in RAM. How can I get those address.
During run time I can track heap using __heapstats(),Do we have any things for tracking stack in real time?
In my .map file I can't find combined allocated address for heap and stack. Any help.
So can you find them separately?
Can you find the symbols mentioned in Westonsupermare's post?
Have you studied the documents I posted earlier?
Have you tried searching? eg, searching for "keil linker map file" found this:
http://www.keil.com/forum/63417/map-file/ - which gives several references about the Map file ...
From .MAP, with names EXPORTed
HEAP 0x20000028 Section 32768 startup_stm32f767xx.o(HEAP) STACK 0x20008028 Section 4096 startup_stm32f767xx.o(STACK) ... __Vectors_Size 0x000001f8 Number 0 startup_stm32f767xx.o ABSOLUTE Stack_Size 0x00001000 Number 0 startup_stm32f767xx.o ABSOLUTE __Vectors 0x08000000 Data 4 startup_stm32f767xx.o(RESET) ... __heap_base 0x20000028 Data 0 startup_stm32f767xx.o(HEAP) Stack_Mem 0x20008028 Data 4096 startup_stm32f767xx.o(STACK) __heap_limit 0x20008028 Data 0 startup_stm32f767xx.o(HEAP) __initial_sp 0x20009028 Data 0 startup_stm32f767xx.o(STACK)
Couldn't you measure stack usage by counting up unused words from the bottom? Zero or write a pattern you can check for later, use that to figure high/low water marks. For the heap walk the allocator structures/pointers. Are these concepts not explained in micro-controller programming courses?
Dynamic stack use tracking & watermarking is covered in the App Note I linked earlier ...