This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Tracking Heap and Stack (ARM Cortex M4)

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

Parents
  • 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?

Reply
  • 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?

Children