I have read the example in S32DS including 57xx_flash.ld & startup.S.
At the beginning of '57xx_flash.ld":
/* define heap and stack size */
__HEAP_SIZE = 0 ;
__STACK_SIZE = 4096 ;
At the end of "startup.S" is the "Configure Stack":
;#****************************** Configure Stack ******************************/
e_lis r1, __SP_INIT@h ;# Initialize stack pointer r1 to
e_or2i r1, __SP_INIT@l ;# value in linker command file.
e_lis r13, _SDA_BASE_@h ;# Initialize r13 to sdata base
e_or2i r13, _SDA_BASE_@l ;# (provided by linker).
e_lis r2, _SDA2_BASE_@h ;# Initialize r2 to sdata2 base
e_or2i r2, _SDA2_BASE_@l ;# (provided by linker).
e_stwu r0,-64(r1) ;# Terminate stack.
And my questions are:
1) what is the stack use for? what is the heap use for? And why the HEAP SIZE is defined to zero?
2) I have seen __SP_INIT defined in the link file, but I have not seen any _SDA_BASE_ or _SDA2_BASE_ definition, other than the extern define in "startup.S", and I search the project , there is no definition for _SDA_BASE_ or _SDA2_BASE_.
So why the compiler or linker tell any error when I build the project? And the program works well.
3) what is the meaning of the "Configure Stack" in "startup.S"? Is r1 used for stack pointer when the program running?
And what r2 & r13 use for ? and what about r0?
Thanks a lot
Hello Jerry,
1) here is simple comparison of STACK and HEAP
Stack:
Heap:
delete
, delete[]
, or free
.new
or malloc
respectively.In embedded systems it is not common to use dynamic memory allocation, so HEAP is by default set to 0, but you have the possibility to increase it and use the dynamic allocation.
2) These are the symbols automatically generated by linker file.
3) Please read the EABI document I am attaching you to this post.
Regards,
Martin
Thanks for your reply, now I see.