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

Accessing initial_sp and heap_base at run time?

Hello,

We are currently working on stack and heap management on STM32F10x. Is there a way to access then __initial_sp and __heap_base values in the start up file at runtime.

We have found that when tracing the stack, that some code changes effect the position of both these values and rather then having to manual check after each build if the address has change we would like to do this at runtime.

Any suggestion on this can be achieved?

Cheers.

Parents
  • Just in case anybody else stumbles over this problem, the correct way to get the real values should be:

    int main()
    {
        extern uint32_t __heap_base;
        extern uint32_t __heap_limit;
    
        uint32_t heap_base = (uint32_t)&__heap_base;
        uint32_t heap_limit = (uint32_t)&__heap_limit;
        ...
    }

    Without these extra &s in assignment compiler will _always_ try to get the value at the label and not its address.

Reply
  • Just in case anybody else stumbles over this problem, the correct way to get the real values should be:

    int main()
    {
        extern uint32_t __heap_base;
        extern uint32_t __heap_limit;
    
        uint32_t heap_base = (uint32_t)&__heap_base;
        uint32_t heap_limit = (uint32_t)&__heap_limit;
        ...
    }

    Without these extra &s in assignment compiler will _always_ try to get the value at the label and not its address.

Children
No data