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.
in startup.s EXPORT __inital_sp EXPORT __heap_base
In c file int main() { extern uint32_t __inital_sp; extern uint32_t __heap_base; printf("%08x : %08x\r\n",__initial_sp,__heap_base); }
output is:
0x20000208 : 0x20000008
The size of my heap is actually 0 (I use no heap) and the stack size is 0x0200. You can see in the map file the __heap_base is 0x20000008 and __heap_limit is 0x20000008.
You should be able to see these in your map file and the values they contain.
Still not sure how you determined that your __initial_sp variable contained 0x0AAA7655.
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.