The gel file mainly includes the initialization work of PLL, DDR, etc. You can see the details by looking at the gel source code; CMD is mainly used to define the memory division and the storage location of data, code, etc.
CMD: command, as the name implies, is the command file to specify
the allocation of storage areas. The CMD of 2812 uses a paging system, where PAGE0 is used to store program space and PAGE1 is used to store data space.
1.) #pragma, CODE_SECTION and DATA_SECTION pseudo-instructions
#pragma DATA_SECTION(funcA,"dataA"); ------ Function declaration outside the function
Locate the funcA data block in the user-defined segment "dataA" ------ The physical address of the dataA segment needs to be specified in CMD
2.) MEMORY and SECTIONS are the two most commonly used pseudo-instructions in command files. The MEMORY pseudo-instruction is used to indicate the usable memory range that actually exists in the target system, where each memory has its own name, starting address and length. The SECTIONS pseudo-instruction is used to describe how the input end is combined into the output end.
There are two basic segments in the CMD file: initialization segment and non-initialization segment. The initialization segment contains code and constants that must be valid after the DSP is powered on. Therefore, the initialization block must be stored in a non-volatile memory such as on-chip FLASH. The non-initialization segment contains data that is written into variables during program execution, so the non-initialization segment must be linked to a volatile memory such as RAM.
Initialized segments: .text, .cinit, .const, .econst, ..pinit and .switch..
.text: All executable code and constants.cinit
: C initialization records for global and static variables.const
: Contains string constants and initialization and description of global and static variables initialized (by const)
.econst: Contains string constants and initialization and description of global and static variables initialized (by far const)
.pinit: Global constructor (C++) program listing.switch
: Contains a list of switch declarations
Uninitialized segments: .bss, .ebss, .stack, .sysmem, and esysmem. (To better understand, these segments are just storage space)
.bss: Space reserved for global and local variables. When the program is powered on, the data in the .cinit space is copied out and stored in the .bss space.
.ebss: Space reserved for global variables and static variables when using large register mode. When the program is powered on, the data in the cinit space is copied out and stored in .ebss.stack
: Space reserved for the system stack, used to pass variables to functions or allocate space for local variables.
.sysmem: Space reserved for dynamic storage allocation. If there is a macro function, this space is occupied by the macro function. If not, this space is reserved as 0.
.esysmem: Space reserved for dynamic storage allocation. If there is a far function, this space is occupied accordingly. If not, this space is reserved as 0.
For the program running in FLASH, it should be noted that: DSP can only provide about 120M clock frequency in FLASH at 150M clock frequency, so sometimes we want to run time-sensitive or computationally intensive subroutines (such as AD sampling) in RAM. However, all our codes are placed in FLASH, so this sensitive program in FLASH must be copied to RAM after power-on to run, speeding up the process. This is why a section must be allocated in the .CMD file to set the RAM loading and running address. The program code is as follows:
SECTIONS {………
ramfuncs : LOAD = FLASHD,
RUN = RAML0,
LOAD_START(_RamfuncsLoadStart),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
PAGE = 0
}
cmd tips:
If the .text file is too large to fit in one segment, you need to put it in two program segments
. If the longest one has a length of 0x002000 and cannot fit in one segment, you can do this:
PAGE 0 :
PRAMH0 : origin = 0x3F8002, length = 0x0014FE
L0RAM : origin = 0x008000, length = 0x001000
SECTIONS
.text:{*(.text)} >>PRAMH0|L0RAM
In this way, the .text file can be placed in two definition segments.
View the allocation and usage of segments. The linker (memory) allocation mapping file of .map describes the following: The map file can be used to view the allocation of each segment, including the starting address of the segment, the number of bytes used, etc. With the use of the cmd file, the usage of each segment can be determined, thereby ensuring the normal operation of the program and the minimum space usage.
VisualLinker Visual Linker The DSP software development environment CCS produced by TI also provides a tool for visually generating memory configuration files: VisualLinker Visual Linker. If the program originally contains a linker command file (.cmd file), the memory configuration in the original cmd file will still be used when creating a visual link file. If the reader wants to modify the memory configuration, double-click the .rcp file to open the graphical interface of the visual linker in CCS, adjust the size of each memory module until it is deemed appropriate, and then just recompile, the program will generate a new output file, repeat the above steps until a satisfactory result appears. CMD
is mainly used to allocate rom and ram space. It tells the linker how to calculate addresses and allocate space. Therefore, different chips have different sizes of rom and ram. The place to put the user program is also different. So it needs to be modified according to the chip. It is divided into two parts: MEMORY and SECTIONS.
MEMORY is used to specify the size of the chip's ROM and RAM and divide it into several intervals.
MEMORY
{
PAGE 0... ROM
PAGE 1.... RAM
}
(The interval name contained in `PAGE and the parameters following it reflect the starting address and length of the interval.)
SECTIONS
{
.vectors .............
.reset
............................. ...
}
SECTIONS: Add a segment name .XXXX (such as .vectors.) to the program to specify that the program (belonging to PAGE0) or data (belonging to PAGE1) below the segment name and above another segment name is placed in the space after the ">" symbol. Here is a simple example:
MEMORY
{
PAGE 0: VECS: origin = 00000h, length = 00040h
LOW: origin = 00040h, length = 03FC0h
SARAM: origin = 04000h, length = 00800h
B0: origin = 0FF00h, length = 00100h
PAGE 1: B0: origin = 00200h, length = 00100h
B1: origin = 00300h, length = 00100h
B2: origin = 00060h, length = 00020h
SARAM: origin = 08000h, length = 00800h
}
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
}
A CMD file consists of three parts: (1) input and output definitions; (2) MEMORY commands; and (3) SECTION commands.
Input/output definition: This part can be set through the "Build Option..." menu of ccs
. obj is the target file to be linked
. lib is the library file to be linked
. map is the cross-reference file generated
. out is the executable code generated.
MEMORY command: describes the actual hardware resources of the system
SECTION command: describes how a "segment" is located
Here is an example:
-c
-o hello.out
-m hello.map
-stack 100
-l rts2xx.lib
MEMORY
{
PAGE 0: VECT:origin=0x8000,length 0x040
PAGE 0: PROG:origin=0x8040,length 0x6000
PAGE 1: DATA:origin =0x8000,length 0x400
}
SECTIONS
{
.vextors >VECT PAGE 0
.text >PROG PAGE 0
.bss >DATA PAGE 1
.const >DATA PAGE 1
}
Storage model description:
.cinit stores the initial values and constants of variables in the program
.const stores character constants, floating-point constants, and constants declared with const in the program
.switch stores the jump address table of the switch statement in the program
.text stores program code
.bss reserves storage space for global and static variables in the program
.far reserves space for global and static variables declared with far in the program
.stack reserves storage space for the program system stack, which is used to save return addresses, pass parameters between functions, store local variables, and save intermediate results
.sysmem is used by malloc, calloc, and realoc functions in the program to dynamically allocate storage space.text executable code
|