CMD file in DSP (to be modified)
The professional name of CMD is the linker configuration file, which stores the configuration information of the linker. The key is the use of memory and sections pseudo commands.
The DSP project folder contains two CMD files, one of which isLinker. CMD; the other is c6455.cmd.The c6455.cmd file is in the project. The. map file in the folder under the project directory contains Section allocation map to view the generated "segment ". View. in the "output section" column of the map file, the segments whose length is not 0 are actually generated by your project; the segments whose length is 0, you can delete all files from the CMD file.
DSP Memory can be divided into two types: power loss and power loss.
The compilation result of the DSP compiler is uncertain, and the DSP does not have the operating system to locate and execute the code. The Configuration Requirements of the DSP system are also different, so you need to define the code storage location. CMD allocates ROM and ram space, telling the link program how to calculate the address and allocate space. So different chips have different sizes of ROM and ram, and the locations where user programs are stored are also different. Therefore, we need to modify the chip into two parts: memory and sections.
As long as the DSP chip memory is not occupied by TI, the user can have full control. Ti designed the "cmd file" interface with users. Users can manage and allocate all physical storage and address spaces in the system by writing CMD files. The CMD file is actually the "statement" of the user, which includes two aspects:
1. Memory Resources in the entire system declared by the user. Whether it is the DSP chip or the user's external expansion, all the memory and space that can be used, need to be declared by the user one by one: what memory is available, their location and size. If some resources are not used at all, it can be regarded as non-existent and do not need to be listed; listing does not matter.
2. How do users allocate these storage resources, that is, statements about resource allocation. Based on your own needs and chip requirements, you can allocate various types of data to appropriate storage areas with proper features and length. This is the focus of writing CMD files.
After writing your own program, you need to go through the arrangement and interpretation (Compilation) of the Development Environment (compiler), convert it to the machine code that can be recognized by the chip, and finally download it to the chip for running. The CMD file is used to compile the source program and generate the machine code. As a user's command or requirement, it is assigned to the development environment (compiler) for execution!
Command file Composition
The start part of the command file is the name of each target file to be linked, so that the linker can link the target file to a file based on the target file name. The next step is the operation command of the linker, these commands are used to configure the linker. The next step isMemory and sections commands must be capitalized..
Memory: UsedSize and division of the RoM and ram of the specified Chip.Page 0 corresponds to Rom, and page 1 corresponds to ram.The interval name in the page and its subsequent parameters reflectStart addressAndLength. (Describe system hardware resources)
Memory
{
Page 0: VECs: Origin = 00000 H, length = 00040 H
Low: Origin = 00040 H, length = 03fc0h
SARAM: Origin = 04000 H, length = 00800 H
B0: Origin = 0ff00h, length = 00100 H
Page 1: B0: Origin = 00200 H, length = 00100 H
B1: Origin = 00300 H, length = 00100 H
B2: Origin = 00060 H, length = 00020 H
SARAM: Origin = 08000 H, length = 00800 H
}
Page 0: VECs (interval name): origin (Starting address) = 800000 H, length (length) = 40 h
For example, the program or data of the application field name ". vectors" will be stored in VECs, where VECs is page0, that is, the ROM space ranges from H to 40 h.
Sections: Add the following segment name in the program, such as. vectors. This parameter is used to specify the following parts. The Program (which belongs to page0) or data (which belongs to page1) with the other part names is placed in the place where the space name after the ">" symbol is located. (Describes how to locate a "segment)
Sections
{
. Vectors: {}> VECs page 0/* interrupt vector table */
. Reset :{}> VECs page 0/* reset code */
............
}
. Vectors,. Reset bothSegment name. If you do not add ".", that is, the. vectors section is ". vectors.
{} Indicates all segments. {}> VECs page 0 indicates placing all segments in the memory zone named VECs page 0.
Example:
Memory
{
Page 0: VECs: Origin = 00000 H, length = 00040 H
Low: Origin = 00040 H, length = 03fc0h
SARAM: Origin = 04000 H, length = 00800 H
B0: Origin = 0ff00h, length = 00100 H
Page 1: B0: Origin = 00200 H, length = 00100 H
B1: Origin = 00300 H, length = 00100 H
B2: Origin = 00060 H, length = 00020 H
SARAM: Origin = 08000 H, length = 00800 H
}
/*--------------------------------------------------------------------------*/
/* Sections allocation */
/*--------------------------------------------------------------------------*/
Sections
{
. Text: {}> low page 0
. Cinit: {}> low page 0
. Switch: {}> low page 0
. Const :{}> Saram page 1
. Data: {}> Saram page 1
. BSS :{}> Saram page 1
. STACK: {}> Saram page 1
. Sysmem :{}> Saram page 1
}
C6455.cmd File Content
/*************************************** *************************************/
/* C6455.cmd */
/* Copyright (c) 2010 Texas Instruments inmarshated */
/* Author: Rafael de Souza */
/**/
/* Description: This file is a sample linker command file that can be */
/* Used for linking programs built with the C compiler and */
/* Running the resulting. Out file on an c6455 */
/* Device. Use it as a guideline. You will want */
/* Change the memory layout to match your specific c6xxx */
/* Target system. You may want to change the allocation */
/* Scheme according to the size of your program .*/
/**/
/*************************************** *************************************/
-L rts64plus. Lib
Input/Output definition: For this part, you can use the "build option ........ "menu settings :. OBJ (target file of the Link ),. lib (connected library file ),. map (generated cross-index file ),. out (generated executable code ).
Memory
{
VECs: O = 0x00800000 L = 0x00000200
Boot: O = 0x00800200 L = 0x00000200
L2ram: O = 0x00800400 L = 0x001ffc00/* 2 MB L2 internal SRAM */
L1pram: O = 0x00e00000 L = 0x00008000/* 32kb L1 program SRAM/cache */
L1dram: O = 0x00f00000l = 0x00008000/* 32kb L1 data SRAM/cache */
Emifa_ce2: O = 0xa0000000 L = 0x00800000/* 8 Mb emifa CE2 */
Emifa_e3: O = 0xb0000000 L = 0x00800000/* 8 Mb emifa CE2 */
Emifa_ce4: O = 0xc0000000 L = 0x00800000/* 8 Mb emifa CE2 */
Emifa_ce5: O = 0xd0000000 L = 0x00800000/* 8 Mb emifa CE2 */
Ddr2_ce0: O = 0xe0000000 L = 0x20000000/* 512 MB emifb ce0 */
}
This is TI's official allocation method.
Sections
{
"Vectors"> VECs
"Bootload"> boot
. Csl_vect> l2ram
. Text> l2ram // contains executable assembly instruction code. If it is not declared, the Code belongs to the. Text Segment;
. Stack> l2ram // stack for storing C Language
. BSS> l2ram // defines the storage space of variables;
. CIO> l2ram // the block of the buffer used by input/output functions such as printf
. Const> l2ram // stores character constants, floating-point constants, and constants declared with const in C programs;
. Data> l2ram // usually contains constant data. For example, data used for variable initialization or a sine table;
. Switch> l2ram // store the constant table generated by the switch statement.
. Sysmem> l2ram // heap for storing C language;
. Far> l2ram // reserve space for the global and static variables in the far life in the C program;
. ARGs> l2ram
. Ppinfo> l2ram
. Ppdata> l2ram
/* Coff sections */
. Pinit> l2ram
. Cinit> l2ram // stores constants used to initialize global and static variables.
/* Eabi sections */
. Binit> l2ram
. Init_array> l2ram
. Neardata> l2ram
. Fardata> l2ram
. Rodata> l2ram
. C6xabi. exidx> l2ram
. C6xabi. extab> l2ram
}
Detailed coff file formats include segment headers, executable code and initialization data, relocated information, row number entries, symbol tables, string tables, and so on. These are the areas of concern for compiler and operating systems. At the application level, the C language of DSP should have two points:Use a pseudocommand to define segments and allocate space to them.
The process of the compiler processing segment is as follows: each source file is compiled into an independent target file (. OBJ). Each target file contains its own segments. The connector connects parts of the same segments in these target files to generate the final executable file (. out ).
1. segments are divided into two categories:Initialized segmentAndUninitialized segment.
1)The initialized segments contain real commands and data and are stored in the program storage space.The program storage space is flash in the DSP chip. When debugging code, download the code to the program bucket outside the credits-at this time, it is mostly Ram.
. Text: Contains executable Assembly command code. If it is not declared, the Code belongs to the. Text Segment;
. Data: usually contains constant data. For example, data used for variable initialization or a sine table;
. Sect: You can customize the initialized segments;
. Asect: it is similar to. sect, but has the absolute address location function.
. Cinit: constant used to initialize global and static variables.
. Switch: stores the constant table generated by the switch statement.
(1) initialized section (includingData Tables and executable code)
. Text: it contains allExecutable code and constants, Must be placed on the program page
. Cinit: it contains the initializedVariable and constant table, Must be placed on the program page
. Pinit: it includesVariable table initialized by the global Constructor (C ++), Must be placed on the program page
. Const: it includes strings, declarations, and global and static variables explicitly initialized, which must be placed at a low address.Data Page.
. Econst: used when using the large storage mode, including strings, declarations, and explicitly initialized global and static variables.Data Page.
. Switch: it contains the table set for the conversion declaration, which can be placed on the program page, or on the data page with a low address.
2) uninitialized segments only reserve the address space of the variable. uninitialized segments are stored in the data storage space. Most of the data storage space is a ram storage unit.
. BSS: defines the storage space of variables;
. Usect: You can customize uninitialized segments;
. STACK: a c-language stack;
. Sysmen: stores the C language heap;
. Const: In simple terms, it is used to store some special constants and characters.
(2) uninitialized section (Reserved space for the variables created and stored in the program running)
. BSS: it isGlobal and static variablesReserved space. When the program starts running, the C Import path copies the data from the. cinit section and then exists in the. BSS section. It is required to be placed on the low-address data page.
. Ebbs: it is used in long-distance access (C) and large-memory mode. It reserves space for global variables and static variables. when the program starts running, C imports the data from. the cinit segment is copied and then exists. in the ebss section. It can be stored anywhere on the data page.
. STACK: cSystem StackReserved space, which is used to pass declarations to functions and leave space for local variables. Data Pages with low addresses are required.
. System: Dynamic Storage allocates reserved space. This space is used by the malloc function. If the malloc function is not used, the size of this segment is 0. Data Pages with low addresses are required.
. Esystem: dynamic memory allocates reserved space. This space is used by the external malloc function. If the external malloc function is not used, the size of this segment is 0. It can be stored anywhere on the data page.
In the CMD file, page0 indicates the program space, and page1 indicates the data space.
Page0:. Text,. cinit, defined by # pragma code_section;
Page1:. Switch,. Const,. BSS,. Stack,. sysmen, and segment defined by # pragma data_section.
The CMD file supports the block annotator "/**/" in the C language, but does not support "//".
Two Functions of the CMD file: Indicate the bucket and the allocated segment to the bucket:
1) memory is used to indicate the bucket:
Memory
{
Page0: Name 0 [(ATTR)]: Origin = constant, length = constant
Pagen: Name 0 [(ATTR)]: Origin = constant, length = constant
}
2) use sections to allocate segments to the bucket:
Sections
{
Name: [property,…]
Name: [property,…]
}
(1) Name of the output end;
(2) properties of the property output segment.
A. Load: defines the keyword where the output segment is loaded. load = allocation
Allocation can be a mandatory address, for example, load = 0x100. More often, allocation is the name of the bucket.
B. Run: Define the keyword where the output segment will run. The CMD file specifies that when only one keyword load or run appears, the load address and run address overlap.
CMD file in DSP (to be modified)