| |||
| Home > Configuring Custom Targets > Examples of configuring settings at the CONNECTION level > Setting top of memory | |||
This example demonstrates how you can permanently set the
top of memory for a given target using your board file. It shows
how to do this by updating the Top_memory setting in
the Connection Properties for the connection. After you have defined
the setting, it is used whenever you connect to the target with RealView Debugger.
To see the value of the top of memory, you can access the top_of_memory symbol.
For example, enter the following CLI command:
> cexpression @top_of_memory
Result is: 524288 0x00080000
See the chapter that describes embedded software development in the RealView Compilation Tools Developer Guide for more details on using top of memory and stack heap values.
The default ARM C library implementation of the function __user_intial_stack_heap makes
a semihosting call to read the debugger variable top_of_memory.
The value returned is used to locate the stack base of your application. RealView Debugger uses target-dependent
defaults for the stack and heap limits. If your application is scatterloaded,
you must define the stack and heap limits in __user_initial_stack_heap (see
the RealView Compilation Tools Developer Guide for
details).
The default value of top of memory for ARM processors is 0x80000.
Heap base is placed at end of the image, by default. The stack
and heap are immediately below the top_of_memory.
The relationship between top of memory, stack and heap is shown
in Figure 2.26.
The top_of_memory value 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 address specified by top_of_memory is
at the true top of memory. A C or assembler program can use memory
at addresses between top_of_memory and the true
top of memory.
You can set the top of memory value in a BOARD group
used to configure the target or in the CONNECTION group
you use to connect to the target. The method described here applies
to both. This example uses an Integrator/AP board with an ARM940T
core module, but the procedure for amending the settings is the
same for any target.
This example uses the connection created in Setting up an Integrator board and
core module. However, the AP, AM,
and CM940T board groups are not linked to ensure
a default memory mapping. If you do link the board groups, the contents
of the Registers pane differ from those shown here because the value
of top_of_memory is defined in the linked CM940T board
group. This value overrides any value that you define in the CONNECTION group.
To set the top of memory in the CONNECTION:
Make sure that RealView Debugger is not connected to a target.
Select Target ? Connect to Target... to display the Connection Control window.
Right-click on the MP3Player Target
Access to display the context menu.
Select Properties... from the context menu.
Expand the following entries in turn:
CONNECTION=MP3Player
Advanced_Information
Default
Select ARM_config in the left
pane.
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_memory by
checking that the words below Top_memory are
writable. It issues a warning if they are not. However, your program
might require much more RAM than the debugger checks for.
Select File ? Save and Close to save your changes and close the Connection Properties window.
Whenever you load a program compiled with the standard ARM
C library to this target, the top_of_memory value
you have set is used.