To All,
I am using development kit DK-LM3S9B96 (Stellaris LM3S9B96 Microcontroller). Code Composer Studio Version: 4.1.0.02000.
Q.1 Is there a way to specify heap and stack section in the .cmd file at a specific location in internal RAM? If yes how can it be done?
The map file defines following variable.
20017f80 __STACK_END
00004000 __STACK_SIZE
20017f80 __STACK_TOP
00008000 __SYSMEM_SIZE
ARM Optimizing C/C++ Compiler v4.6 User's Guide says followin about the above variable.
6.1.2 C/C++ System Stack
The C/C++ compiler uses a stack to:
• Allocate local variables
• Pass arguments to functions
• Save register contents
The run-time stack grows from the high addresses to the low addresses. The compiler uses the R13
register to manage this stack. R13 is the stack pointer (SP), which points to the next unused location on
the stack.
The linker sets the stack size, creates a global symbol, __STACK_SIZE, and assigns it a value equal to
the stack size in bytes. The default stack size is 2048 bytes. You can change the stack size at link time by
using the --stack_size option with the linker command. For more information on the --stack_size option,
see Section 4.2.
6.1.3 Dynamic Memory Allocation
The run-time-support library supplied with the ARM compiler contains several functions (such as malloc,
calloc, and realloc) that allow you to allocate memory dynamically for variables at run time.
Memory is allocated from a global pool, or heap, that is defined in the .sysmem section. You can set the
size of the .sysmem section by using the --heap_size=size option with the linker command. The linker also
creates a global symbol, __SYSMEM_SIZE, and assigns it a value equal to the size of the heap in bytes.
The default size is 2048 bytes. For more information on the --heap_size option, see Section 4.2.
Q.2 Can the global variables __STACK_END, __STACK_SIZE, __STACK_TOP, __SYSMEM_SIZE created and listed in load map, be access within the C coe or in assembly language? If yes, how this can be done?
Q.3 Is there a way to create a global variable similar to __STACK_TOP and __STACK_END for start of heap and end of heap?
Q.4 Is heap storage area is part of .sysmem or .bss?
The stack is clearly specified in the .map file as follows.
20013f80 20013f80 00004000 00000000 rw- .stack 60000000 60000000 0001c8d0 0001c8d0 r-x I don't see the same thing for heap. See below part of the load map.
****************************************************************************** TMS470 Linker PC v4.6.1 ****************************************************************************** >> Linked Mon Jul 19 20:24:30 2010 OUTPUT FILE NAME: <Beta.out> ENTRY POINT SYMBOL: "_c_int00" address: 60015d71 MEMORY CONFIGURATION name origin length used unused attr fill ---------------------- -------- --------- -------- -------- ---- -------- FLASH 00000000 00040000 00000000 00040000 R X SRAM 20000120 00017e60 00012275 00005beb RW X XSRAM 60000000 00100000 0001c8cc 000e3734 RW X SEGMENT ALLOCATION MAP run origin load origin length init length attrs members ---------- ----------- ---------- ----------- ----- ------- 20000120 20000120 00008000 00000000 rw- 20000120 20000120 00008000 00000000 rw- .sysmem 20008400 20008400 00005c00 00000000 rw- 20008400 20008400 00005c00 00000000 rw- .bss 2000e000 2000e000 00000675 00000675 rw- 2000e000 2000e000 00000675 00000675 rw- .data 20013f80 20013f80 00004000 00000000 rw- 20013f80 20013f80 00004000 00000000 rw- .stack 60000000 60000000 0001c8d0 0001c8d0 r-x 60000000 60000000 00000120 00000120 r-- .intvecs 60000120 60000120 00016cda 00016cda r-x .text 60016dfc 60016dfc 0000581a 0000581a r-- .const 6001c618 6001c618 000002b8 000002b8 r-- .cinit Q.5 How can I find out which section the heap defined looking at tthe map file? Any help on this will be very much appereciated. Thanks in advance for assistacne. Al Modi