CMD file parsing in CCS

Source: Internet
Author: User
Tags reserved

Gel files mainly include the PLL, DDR and other initialization work, specifically can see the gel source code to understand, CMD is mainly used to define the partition of memory, and data, code and other storage location.

The Cmd:command command, as the name implies, is the allocation of the storage area specified by the command file. The 2812 CMD uses a paging system where PAGE0 is used to store the program space and PAGE1 is used to hold the data space.  1.) #pragma, code_section and data_section pseudo-directive #pragma data_section (Funca, "Dataa"); ------out-of-function declarations to locate Funca data blocks in user-defined segment "DATAA"------need to specify the physical address of the DATAA segment in cmd
2.) Memory and sections are the most commonly used two pseudo-directives in the command file. The memory pseudo-instruction is used to denote the actual existence of a memory range that can be used in the target system, where each memory has its own name, start address, and length. The sections pseudo-directive is used to describe how the input is combined into the output terminal. There are two basic segments in the cmd file: initialization segment and non-initialized segment. The initialization segment contains the number of codes and constants that must be valid after the DSP has been power on. Therefore, the initialization block must be persisted such as on-chip flash and other non-lost memory, the non-initialized section contains in the program run process to write data inside the variable, so the non-initialized segment must be linked to volatile memory such as RAM.   Initialized segment:. Text,.cinit,.const,.econst,.. Pinit and. Switch.  .text: All code and constants that can be executed  . Cinit: C initialization record for global variables and static variables. Const: Initialization of global variables and static variables (by const) that contain string constants and initializations and description  . Econst: Initialization and description of the global variables and static variables (by far const) that contain string constants and initializations  . Pinit: Global Constructor (c + +) program list  .switch: List with switch declarations Non-initialized segments:. Bss,.ebss,.stack,.sysmem, and Esysmem. (A better understanding is that these are storage spaces)    . BSS: space reserved for global variables and local variables, The data in the Cinit space is copied and stored in the. BSS space when the program is power-up.  . EBSS: For space reserved for global variables and static variables when using large register mode, the data in the Cinit space is copied and stored in the. EBSS  .stack: space reserved for the system stack when the program is power-up. Used to pass variables to and from functions, or to allocate space for local variables.  . SYSMEM: Allocate reserved space for dynamic storage. If there is a macro function, this space is occupied by the macro function, and if not, this space is reserved as 0. ESYSMEM: Allocates reserved space for dynamic storage. If there is a far function, this space is occupied accordingly, and if not, this space is reserved as 0. For programs to run in Flash, it's important to note that the DSP can only provide about 120M of 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. ButAll of our code is in Flash, and this has to be done by copying the sensitive program in Flash to ram to speed up the power-up. This is in the. The cmd file must be divided into a set of loading and running addresses for RAM. The program code is as follows:  SECTIONS {.........     ramfuncs      :   LOAD = flashd,                                 run = RAML0,                                  load_start (_RamfuncsLoadStart),                                 load_end (_ramfuncsloadend),                               &nBsp; run_start (_ramfuncsrunstart),                                 page = 0   }

Cmd tip: If the. text file is too big to fit in a section, it needs to be placed in one of the longest length=0x002000 in two program segments, and not fit. Can be handled as follows: PAGE 0:              pramh0     : origin = 0x3F8002, length = 0X0014FE
            L0RAM      &NBSP: origin = 0x008000, length = 0x001000   SECTIONS                .text:{* (. Text)} >>pramh0| L0ram this allows the. text file to be placed in two definition segments.

View the allocation and usage of the segment. Map of the linker (memory) Allocation map file, the linker's map file describes the following:  through the map file can see the distribution of each segment, including the starting address of the segment, the number of bytes used and other uses of the cmd file, The use of each segment can be determined to ensure proper operation of the program and minimum space use.  
Visuallinker Visual linker TI's DSP software development environment CCS also provides a tool for visualizing the generation of memory Profiles: Visuallinker Visual linker. If the program originally contained a linker command file (. cmd file), the memory configuration in the original CMD file will still be used when creating the 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, resize each memory module until it is considered appropriate, and then only need to re-connect, the program can generate a new output file, repeat the above steps until a satisfactory result appears.

CMD is primarily used to allocate ROM and ram space, and it tells the linker how to calculate the address and allocate space. So different chips have different sizes of ROM and ram. The places where the user program is placed are not the same. So we have to modify it according to the chip. Memory and sections.

Memory is used to specify the size of the chip's ROM and ram and to divide out several intervals.

MEMORY

{

PAGE 0 ... Rom
PAGE 1 .... Ram
}

(' page contains the interval name and its subsequent parameters reflect the beginning address and length of the interval.)


SECTIONS
{
.... Vectors ....... .....
. Reset ........ .....
................
}

SECTIONS: Add a segment name to the program, XXXX (e.g.. Vectors.) Used to specify that the paragraph name is below, the other segment name is above the program (belongs to PAGE0) or the data (belonging to the PAGE1) place the space name after the ">" symbol. A simple example is given below:

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

}

The cmd file consists of three parts: (1) input and output definition, (2) memory command; (3) Section command.

Input/Output Definition: This section can be set through the CCS "Build Option ..." menu
。 Obj-linked target file
。 Lib Linked library file
。 Map-generated cross-index files
。 Out-generated executable code

Memory command: Describes the actual hardware resources of the system

Section command: Describes how "segment" is positioned

An example is given below:

-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
}

Description of the storage model:

. Cinit variable values and constants in the storage program

. const store character constants, floating-point constants, and constants declared with const

Jump Address Table for switch statements in the. Switch Store program

. Text Store Program code

. BSS preserves storage space for global and static variables in programs

. Far reserve space for programs with global and static variables declared in far

. Stack reserves storage space for the program system stack for storing return addresses, parameter passing between functions, storing local variables, and saving intermediate results

. Sysmem is used to dynamically allocate storage space for malloc, calloc, and REALOC functions in programs. Text Executable code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.