SPRU513Y August 2001 – June 2022 SM320F28335-EP
The MEMORY directive identifies ranges of memory that are physically present in the target system and can be used by a program. Each range has several characteristics:
The MEMORY directive also allows you to use the GROUP keyword to create logical groups of memory ranges for use with Cyclic Redundancy Checks (CRC). See Section 9.10.2 for how to compute CRCs over memory ranges using the GROUP syntax.
TMS320C28x devices have separate memory spaces (pages) that occupy the same address ranges (overlay). In the default memory map, one space is dedicated to the program area, while a second is dedicated to the data area. (For detailed information about overlaying pages, see Section 9.6.5.2.7.)
In the linker command file, you configure the address spaces separately by using the MEMORY directive's PAGE option. The linker treats each page as a separate memory space. The TMS320C28x supports up to 255 address spaces, but the number of address spaces available depends on the customized configuration of your device (see the TMS320C2xx User's Guide for more information.)
When you use the MEMORY directive, be sure to identify all memory ranges that are available for the program to access at run time. Memory defined by the MEMORY directive is configured; any memory that you do not explicitly account for with MEMORY is unconfigured. The linker does not place any part of a program into unconfigured memory. You can represent nonexistent memory spaces by simply not including an address range in a MEMORY directive statement.
The MEMORY directive is specified in a command file by the word MEMORY (uppercase), followed by a list of memory range specifications enclosed in braces. The MEMORY directive in The MEMORY Directive defines a system that has 4K words of slow external memory at address 0x0000 0C00 in program memory, 32 words of fast external memory at address 0x0000 0060 in data memory, and 512 words of slow external memory at address 0x0000 0200 in data memory. It also demonstrates the use of memory range expressions as well as start/end/size address operators (see Origin and Length as Expressions).
/****************************************************************************/
/* Sample command file with MEMORY directive */
/****************************************************************************/
file1.c.obj file2.c.obj /* Input files */
--output_file=prog.out /* Options */
#define BUFFER 0
MEMORY
{
PAGE 0: PROG: origin = 0x00000C00, length = 0x00001000 + BUFFER
PAGE 1: SCRATCH: origin = 0x00000060, length = 0x00000020
RAM1: origin = end(SCRATCH,1) + 0x00000180, length = 0x00000200
}
The general syntax for the MEMORY directive is: | |
MEMORY | |
{ | |
[PAGE 0:] name 1 [(attr )] : origin = expr , length = expr [, fill = constant] [ LAST(sym )] | |
[PAGE 1:] name 2 [(attr )] : origin = expr , length = expr [, fill = constant] [ LAST(sym )] | |
. | |
. | |
[PAGEn:] name n [( attr )] : origin = expr , length = expr [, fill = constant] [ LAST(sym )] | |
} |
PAGE | identifies a memory space. You can specify up to 32 767 pages. Usually, PAGE 0 specifies program memory, and PAGE 1 specifies data memory. Each PAGE represents a completely independent address space. Configured memory on PAGE 0 can overlap configured memory on PAGE 1 and so on. If you do not specify PAGE for a memory space, the linker defaults to PAGE 0. If you do not specify PAGE in your allocation (see Section 9.6.5), the linker allocates initialized sections to PAGE 0 and uninitialized sections to PAGE 1. | |
name | names a memory range. A memory name can be one to 64 characters; valid characters include A-Z, a-z, $, ., and _. The names have no special significance to the linker; they simply identify memory ranges. Memory range names are internal to the linker and are not retained in the output file or in the symbol table. All memory ranges must have unique names and must not overlap. | |
attr | specifies one to four attributes associated with the named range. Attributes are optional; when used, they must be enclosed in parentheses. Attributes restrict the allocation of output sections into certain memory ranges. If you do not use any attributes, you can allocate any output section into any range with no restrictions. Any memory for which no attributes are specified (including all memory in the default model) has all four attributes. Valid attributes are: | |
R | specifies that the memory can be read. | |
W | specifies that the memory can be written to. | |
X | specifies that the memory can contain executable code. | |
I | specifies that the memory can be initialized. | |
origin | specifies the starting address of a memory range; enter as origin, org, or o. The value, specified in bytes, is a 32-bit integer constant expression, which can be decimal, octal, or hexadecimal. | |
length | specifies the length of a memory range; enter as length, len, or l. The value, specified in bytes, is a 22-bit integer constant expression, which can be decimal, octal, or hexadecimal. | |
fill | specifies a fill character for the memory range; enter as fill or f. Fills are optional. The value is an integer constant and can be decimal, octal, or hexadecimal. The fill value is used to fill areas of the memory range that are not allocated to a section. (See Section 9.6.10.3 for virtual filling of memory ranges when using Error Correcting Code (ECC).) | |
LAST | optionally specifies a symbol that can be used at run-time to find the address of the last allocated byte in the memory range. See Section 9.6.11.8. |
Filling Memory Ranges: If you specify fill values for large memory ranges, your output file will be very large because filling a memory range (even with 0s) causes raw data to be generated for all unallocated blocks of memory in the range.
The following example specifies a memory range with the R and W attributes and a fill constant of 0FFFFFFFFh:
MEMORY
{
RFILE (RW) : o = 0x00000020, l = 0x00001000, f = 0xFFFFFFFF
}
You normally use the MEMORY directive in conjunction with the SECTIONS directive to control placement of output sections. For more information about the SECTIONS directive, see Section 9.6.5.
Figure 9-2 illustrates the memory map shown in The MEMORY Directive