| |||
Home > Configuring Custom Targets > Example descriptions > Setting top of memory and stack heap values |
This example demonstrates how you can set permanent top of
memory and stack heap values for a given target using your board
file. It shows how to do this by updating the information in the Advanced_Information
block.
After you have defined the settings, they are used whenever you
connect to the target with RealView Debugger.
This example uses the MCUeval
board with
a core module, but the procedure for amending the settings is the
same for any target.
The top_of_memory
variable is used to enable
the semihosting mechanism to return the top of stack. You can create
your own settings to specify the bottom of the stack address, the
size of the stack, the bottom of the heap address, and the size
of the heap. If you do not set these values manually, RealView Debugger uses
the target-dependent defaults. If your application is scatterloaded,
you must define the stack and heap limits.
The value of top_of_memory
must be higher
than the sum of the program base address, program code size, and
program data size. If set incorrectly, the program might crash because
of stack corruption or because the program overwrites its own code.
There is no requirement that the top of memory address is at the true top of memory. A C or assembler program can use memory at higher addresses.
The default value of top_of_memory
for
ARM processors is 0x20000
. You can set the value
of top_of_memory
in a BOARD
description
of the target or in the CONNECTION
you use to
connect to the target.
To set the top of memory and stack heap values in the CONNECTION
:
Ensure that RealView Debugger is not connected to a target.
Expand the following entries of the selected board group:
CONNECTION=RVI-ME
Advanced_Information
Default
ARM_config
Set the value of Top_memory
,
in the right pane, as required. For example, set it to 0x40000
if
your target has 256KB of RAM starting at location 0
.
Be sure to specify a value that is supported by your debug target.
When you load a program, the debugger sanity-checks top_of_memory
by
checking that the words below top_of_memory
are
writable. It issues a warning if they are not. However, your program
might require much more RAM than the debugger checks for.
Double-click on the Stack_Heap
group,
in the right pane, to display the contents (Figure 17.25).
This shows the currently selected size and location of the
stack and heap. A blank or zero Heap_base
value
is modified by the ARM C library runtime code, setting it to the address
of the end of program data space (Figure 17.26).
If you require more control over the stack and heap location for a semihosted program, set the values as required.
If your application requires control over the stack and heap
location, or if the application is scatterloaded, the application
must include a user-defined function, __user_initial_stackheap,
that
defines the stack and heap limits.
Select File → Save and Close to close the Connection Properties window.
Whenever you load a program compiled with the standard ARM C library to this target, the top of memory, stack, and heap values you have set are used. For details on how to connect, see Connecting to a target.