Detailed description of CMD file in 6_28335 project development record

Source: Internet
Author: User
1. Role of the CMD file

The CMD file serves as a warehouse goods placement record.Program codeAndDataAllocate the specified space.

2. CIDR blocks generated in C Language

Segments generated by C language are roughly divided into two categories: initialization and uninitialized. initialized segments contain real commands and data. uninitialized segments only reserve the variable address space.

Initialized segment:

. Text -- the assembly instruction code generated by C language compilation is stored here

. Cinit -- stores initialized global and static variables

. Const -- string constants and global and static variables defined by const

. Econst -- Global and static variables defined by string constants and far const

. Print -- Global Constructor (C ++) program list

. Switch -- store the constant table generated by the switch statement

Take the. Const section as an example:

Const int A = 10; // note that it must be global. If it is declared as a local const initialization variable, it will not be placed in. const segment, local variables are put at runtime. in the BSS segment, char * P = "ABC"; the initial values of arrays and struct -- are local variables, which are generated. const. If it is a global variable, it is generated. cinit

Uninitialized segment:

. BSS -- space reserved for global and local variables. When the program is powered on, data in the. cinit space is copied and stored in the. BSS space.

. Ebss -- global and local variable space reserved for using the large register mode. When the program is powered on, data in the. cinit space is copied and stored in. BSS space.

. Stack -- stack space, which is mainly used to pass variables by functions or allocate space for local variables.

. System -- allocate reserved space (malloc) for dynamic storage. If there is a macro function, this space is occupied.

. Esystem-allocate reserved space (far malloc) for dynamic storage. If far function is available, this space will be occupied.


3. Custom segments

The above are pre-defined officially. Can we define our own segments? Yes. Use the following statement:

#pragma CODE_SECTION(symbol, "section name");#pragma DATA_SECTION(symbol, "section name");
Symbol -- symbol, which can be a function name or variable name

Section name -- custom segment name

Code_section is used to define code segments.

Data_section is used to define data segments.

Note::

No more function body declaration # pragma;

It must be declared before the symbol is defined and used # pragma

Example:

#pragma DATA_SECTION(data, "data_name");char data[100];


4. CMD file

In the dsp28335 project file (CMD files are generated without BIOS), there are generally two handwritten CMD files. The two CMD files used for debugging in RAM are dsp2833x_headers_nonbios.cmd and 28335_ram_lers_nk.cmd, respectively, the two CMD files used for flash writing are dsp2833x_headers_nonbios.cmd and f28335.cmd. The dsp2833x_headers_nonbios.cmd files can be used in all engineering files, the main function is to map the data fields generated by the peripheral registers to the corresponding storage space. You can check them against the dsp2833x_globalvariabledefs.c file. This is also mentioned in my previous article.

In fact, we do not need to know in detail how to compile the CMD file, you can follow the original modification.

The following is the official 28335_ram_lnk.cmd. In general, Ti is used directly, and debugging can be completed without modification. The mode is relatively fixed. Of course, you can also modify which Ram bucket to use, make the appropriate allocation in the CMD file.

MEMORY{PAGE 0 :   /* BEGIN is used for the "boot to SARAM" bootloader mode      */   BEGIN      : origin = 0x000000, length = 0x000002     /* Boot to M0 will go here                      */   RAMM0      : origin = 0x000050, length = 0x0003B0   RAML0      : origin = 0x008000, length = 0x001000   RAML1      : origin = 0x009000, length = 0x001000   RAML2      : origin = 0x00A000, length = 0x001000   RAML3      : origin = 0x00B000, length = 0x001000   ZONE7A     : origin = 0x200000, length = 0x00FC00    /* XINTF zone 7 - program space */   CSM_RSVD   : origin = 0x33FF80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */   CSM_PWL    : origin = 0x33FFF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA            */   ADC_CAL    : origin = 0x380080, length = 0x000009   RESET      : origin = 0x3FFFC0, length = 0x000002   IQTABLES   : origin = 0x3FE000, length = 0x000b50   IQTABLES2  : origin = 0x3FEB50, length = 0x00008c   FPUTABLES  : origin = 0x3FEBDC, length = 0x0006A0   BOOTROM    : origin = 0x3FF27C, length = 0x000D44PAGE 1 :   /* BOOT_RSVD is used by the boot ROM for stack.               */   /* This section is only reserved to keep the BOOT ROM from    */   /* corrupting this area during the debug process              */   BOOT_RSVD  : origin = 0x000002, length = 0x00004E     /* Part of M0, BOOT rom will use this for stack */   RAMM1      : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */   RAML4      : origin = 0x00C000, length = 0x001000   RAML5      : origin = 0x00D000, length = 0x001000   RAML6      : origin = 0x00E000, length = 0x001000   RAML7      : origin = 0x00F000, length = 0x001000   ZONE7B     : origin = 0x20FC00, length = 0x000400     /* XINTF zone 7 - data space */}SECTIONS{   /* Setup for "boot to SARAM" mode:      The codestart section (found in DSP28_CodeStartBranch.asm)      re-directs execution to the start of user code.  */   codestart        : > BEGIN,     PAGE = 0   ramfuncs         : > RAML0,     PAGE = 0   .text            : > RAML1,     PAGE = 0   .cinit           : > RAML0,     PAGE = 0   .pinit           : > RAML0,     PAGE = 0   .switch          : > RAML0,     PAGE = 0   .stack           : > RAMM1,     PAGE = 1   .ebss            : > RAML4,     PAGE = 1   .econst          : > RAML5,     PAGE = 1   .esysmem         : > RAMM1,     PAGE = 1   IQmath           : > RAML1,     PAGE = 0   IQmathTables     : > IQTABLES,  PAGE = 0, TYPE = NOLOAD   /* Uncomment the section below if calling the IQNexp() or IQexp()      functions from the IQMath.lib library in order to utilize the      relevant IQ Math table in Boot ROM (This saves space and Boot ROM      is 1 wait-state). If this section is not uncommented, IQmathTables2      will be loaded into other memory (SARAM, Flash, etc.) and will take      up space, but 0 wait-state is possible.   */   /*   IQmathTables2    : > IQTABLES2, PAGE = 0, TYPE = NOLOAD   {              IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)   }   */   FPUmathTables    : > FPUTABLES, PAGE = 0, TYPE = NOLOAD   DMARAML4         : > RAML4,     PAGE = 1   DMARAML5         : > RAML5,     PAGE = 1   DMARAML6         : > RAML6,     PAGE = 1   DMARAML7         : > RAML7,     PAGE = 1   ZONE7DATA        : > ZONE7B,    PAGE = 1   .reset           : > RESET,     PAGE = 0, TYPE = DSECT /* not used                    */   csm_rsvd         : > CSM_RSVD   PAGE = 0, TYPE = DSECT /* not used for SARAM examples */   csmpasswds       : > CSM_PWL    PAGE = 0, TYPE = DSECT /* not used for SARAM examples */   /* Allocate ADC_cal function (pre-programmed by factory into TI reserved memory) */   .adc_cal     : load = ADC_CAL,   PAGE = 0, TYPE = NOLOAD}/*//===========================================================================// End of file.//===========================================================================*/


Below is the official f28335.cmd;

Compiling the f28335.cmd file used for flash burning is relatively more complex and requires some modifications based on different situations.

1. You do not need to copy part of the code to ram. In general, you do not need to use TI's f28335.cmd to expand Ram.

2 need to copy part of the code from flash to ram, such as the delay function dsp2833x_usdelay.asm, etc., then CMD file needs to make the corresponding modifications, specific reference blog: http://blog.sina.com.cn/s/blog_762cf5f80101asmq.html

3 from the time overhead, need to copy the entire program from flash to ram, then the program and CMD file to make the corresponding modifications, specific reference blog http://blog.sina.com.cn/s/blog_762cf5f80101apfx.html

MEMORY{PAGE 0:    /* Program Memory */           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */   ZONE0       : origin = 0x004000, length = 0x001000     /* XINTF zone 0 */   RAML0       : origin = 0x008000, length = 0x001000     /* on-chip RAM block L0 */   RAML1       : origin = 0x009000, length = 0x001000     /* on-chip RAM block L1 */   RAML2       : origin = 0x00A000, length = 0x001000     /* on-chip RAM block L2 */   RAML3       : origin = 0x00B000, length = 0x001000     /* on-chip RAM block L3 */   ZONE6       : origin = 0x0100000, length = 0x100000    /* XINTF zone 6 */    ZONE7A      : origin = 0x0200000, length = 0x00FC00    /* XINTF zone 7 - program space */    FLASHH      : origin = 0x300000, length = 0x008000     /* on-chip FLASH */   FLASHG      : origin = 0x308000, length = 0x008000     /* on-chip FLASH */   FLASHF      : origin = 0x310000, length = 0x008000     /* on-chip FLASH */   FLASHE      : origin = 0x318000, length = 0x008000     /* on-chip FLASH */   FLASHD      : origin = 0x320000, length = 0x008000     /* on-chip FLASH */   FLASHC      : origin = 0x328000, length = 0x008000     /* on-chip FLASH */   FLASHA      : origin = 0x338000, length = 0x007F80     /* on-chip FLASH */   CSM_RSVD    : origin = 0x33FF80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */   BEGIN       : origin = 0x33FFF6, length = 0x000002     /* Part of FLASHA.  Used for "boot to Flash" bootloader mode. */   CSM_PWL     : origin = 0x33FFF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA */   OTP         : origin = 0x380400, length = 0x000400     /* on-chip OTP */   ADC_CAL     : origin = 0x380080, length = 0x000009     /* ADC_cal function in Reserved memory */      IQTABLES    : origin = 0x3FE000, length = 0x000b50     /* IQ Math Tables in Boot ROM */   IQTABLES2   : origin = 0x3FEB50, length = 0x00008c     /* IQ Math Tables in Boot ROM */     FPUTABLES   : origin = 0x3FEBDC, length = 0x0006A0     /* FPU Tables in Boot ROM */   ROM         : origin = 0x3FF27C, length = 0x000D44     /* Boot ROM */           RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM  */   VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM  */PAGE 1 :   /* Data Memory */           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */           /* Registers remain on PAGE1                                                  */      BOOT_RSVD   : origin = 0x000000, length = 0x000050     /* Part of M0, BOOT rom will use this for stack */   RAMM0       : origin = 0x000050, length = 0x0003B0     /* on-chip RAM block M0 */   RAMM1       : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */   RAML4       : origin = 0x00C000, length = 0x001000     /* on-chip RAM block L1 */   RAML5       : origin = 0x00D000, length = 0x001000     /* on-chip RAM block L1 */   RAML6       : origin = 0x00E000, length = 0x001000     /* on-chip RAM block L1 */   RAML7       : origin = 0x00F000, length = 0x001000     /* on-chip RAM block L1 */   ZONE7B      : origin = 0x20FC00, length = 0x000400     /* XINTF zone 7 - data space */   FLASHB      : origin = 0x330000, length = 0x008000     /* on-chip FLASH */}/* Allocate sections to memory blocks.   Note:         codestart user defined section in DSP28_CodeStartBranch.asm used to redirect code                    execution when booting to flash         ramfuncs  user defined section to store functions that will be copied from Flash into RAM*/  SECTIONS{    /* Allocate program areas: */   .cinit              : > FLASHA      PAGE = 0   .pinit              : > FLASHA,     PAGE = 0   .text               : > FLASHA      PAGE = 0   codestart           : > BEGIN       PAGE = 0   ramfuncs            : LOAD = FLASHD,                          RUN = RAML0,                          LOAD_START(_RamfuncsLoadStart),                         LOAD_END(_RamfuncsLoadEnd),                         RUN_START(_RamfuncsRunStart),                         PAGE = 0   csmpasswds          : > CSM_PWL     PAGE = 0   csm_rsvd            : > CSM_RSVD    PAGE = 0      /* Allocate uninitalized data sections: */   .stack              : > RAMM1       PAGE = 1   .ebss               : > RAML4       PAGE = 1   .esysmem            : > RAMM1       PAGE = 1   /* Initalized sections go in Flash */   /* For SDFlash to program these, they must be allocated to page 0 */   .econst             : > FLASHA      PAGE = 0   .switch             : > FLASHA      PAGE = 0         /* Allocate IQ math areas: */   IQmath              : > FLASHC      PAGE = 0                  /* Math Code */   IQmathTables     : > IQTABLES,  PAGE = 0, TYPE = NOLOAD       /* Uncomment the section below if calling the IQNexp() or IQexp()      functions from the IQMath.lib library in order to utilize the       relevant IQ Math table in Boot ROM (This saves space and Boot ROM       is 1 wait-state). If this section is not uncommented, IQmathTables2      will be loaded into other memory (SARAM, Flash, etc.) and will take      up space, but 0 wait-state is possible.   */   /*   IQmathTables2    : > IQTABLES2, PAGE = 0, TYPE = NOLOAD    {                 IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)      }   */      FPUmathTables    : > FPUTABLES, PAGE = 0, TYPE = NOLOAD             /* Allocate DMA-accessible RAM sections: */   DMARAML4         : > RAML4,     PAGE = 1   DMARAML5         : > RAML5,     PAGE = 1   DMARAML6         : > RAML6,     PAGE = 1   DMARAML7         : > RAML7,     PAGE = 1      /* Allocate 0x400 of XINTF Zone 7 to storing data */   ZONE7DATA        : > ZONE7B,    PAGE = 1   /* .reset is a standard section used by the compiler.  It contains the */    /* the address of the start of _c_int00 for C Code.   /*   /* When using the boot ROM this section and the CPU vector */   /* table is not needed.  Thus the default type is set here to  */   /* DSECT  */    .reset              : > RESET,      PAGE = 0, TYPE = DSECT   vectors             : > VECTORS     PAGE = 0, TYPE = DSECT      /* Allocate ADC_cal function (pre-programmed by factory into TI reserved memory) */   .adc_cal     : load = ADC_CAL,   PAGE = 0, TYPE = NOLOAD}/*//===========================================================================// End of file.//===========================================================================*/

The specific project instance will be provided later;



Detailed description of CMD file in 6_28335 project development record

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.