There are some codes in the "Startup.s" for "User Initial Stack & Heap".
And, as per this URL http://www.keil.com/support/man/docs/armlib/armlib_chdegjfd.htm
There are another codes for "Sets up the heap and stack".
It makes me a little confused.
What is the relationship between these two "Stack & Heap Initialization"?
Are they duplicated works, or they have different and important meanings?
Hi John,
> But I do not understand why it needs two "Stack & Heap Initialization".
What "two" initialization are you talking about? Could you be more precise? The only "duplication" I see in LPC2300.s is conditionally compiled code depending on whether you use Microlib or the normal C library. There should be one user mode (application) stack and a few exception mode stacks. __user_initial_stack_heap() configures the application stack and passes that information back to the C library. Different libraries do not need their own stacks. Neither do they need a separate heap if they rely on C library functions for heap management.
Regards Marcus http://www.doulos.com/arm/
Hi Marcus,
Many Thanks to your help.
About the "duplication", now I understand I mistaken something.
At that moment, I learned the startup procedure of the LPC23xx with KEIL MDK-ARM is:
Startup.s -> __main -> __rt_entry -> C main().
I saw the codes in the "Startup.s" for User Initial Stack & Heap. And KEIL's Document says __rt_entry will set up the heap and stack, so I "assumed" there are another codes for "Sets up the heap and stack".
Now I guess that, __user_initial_stackheap() is equivalent to __rt_stackheap_init(). And the __user_initial_stackheap() located in Startup.s will only be executed when it is called by __rt_entry.
Hi Per,
Many Thanks to your explanations.
Though I need some time to completely understand these concepts, but I think I've already got some key points.
> Now I guess that, __user_initial_stackheap() is > equivalent to __rt_stackheap_init().
Not really. You have to reimplement (MDK has done that for you) __user_initial_stackheap() to place stack and heap regions.
As far as I understand things, __rt_stackheap_init() needs to be changed if you prefer to implement an entirely new stack/heap management.
I have never had to touch __rt_stackheap_init().