Page 1 of 1

Stack pointer initialization and heap bounds

Posted: 28 Mar 2017, 11:36
by a_ziliu
Stack pointer initialization and heap bounds

The C library requires you to specify where the stack pointer begins. If you intend to use ARM library functions that use the heap, for example, malloc(), calloc(), or if you define argc and argv command-line arguments for main(), the C library also requires you to specify which region of memory the heap is initially expected to use.

You must always specify where the stack pointer begins. The initial stack pointer must be aligned to a multiple of eight bytes.

You might have to configure the heap if, for example:
◾You intend to use ARM library functions that use the heap, for example, malloc(), calloc().
◾You define argc and argv command-line arguments for main()

If you are using the C library's initialization code, use any of the following methods to configure the stack and heap:
◾Use the symbols __initial_sp, __heap_base, and __heap_limit.
◾Use a scatter file to define ARM_LIB_STACKHEAP, ARM_LIB_STACK, or ARM_LIB_HEAP regions.
◾Implement __user_setup_stackheap() or __user_initial_stackheap().

refer from keil websit