LF2407A的CMD文件写法

来源:互联网 发布:软件开发计划书范例 编辑:程序博客网 时间:2024/05/01 03:50
       

DSP的存储器的地址范围,CMD是主要是根据那个来编的。

CMD 它是用来分配rom和ram空间用的,告诉链接程序怎样计算地址和分配空间.

所以不同的芯片就有不同大小的rom和ram.放用户程序的地方也不尽相同.所以要根据芯片进行修改.分两部分.MEMORY和SECTIONS.

MEMORY

{ PAGE 0 ..........

PAGE 1.........

}

SECTIONS

{SECTIONS

{

.vectors .................

.reset .................

................

}

MEMORY是用来指定芯片的rom和ram的大小和划分出几个区间.

PAGE 0 对应rom PAGE 1对应ram

PAGE 里包含的区间名字与其后面的参数反映了该区间的起始地址和长度.

SECTIONS:(在程序里添加下面的段名如.vectors.用来指定该段名以下,

另一个段名以上的程序(属于PAGE0)或数据(属于PAGE1)放到“>”符号后的空间名字所在的地方。

SECTIONS

{

.vectors : { } > VECS PAGE 0 /* Interrupt vector table */

.reset : { } > VECS PAGE 0 /* Reset code */

............

............

..........

}

eg:

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

}

例如:

/*--------------------------------------------------------------------*/
/*  LINKER COMMAND FILE - MEMORY SPECIFICATION for the F2407a           */
/*--------------------------------------------------------------------*/
MEMORY
{
    PAGE 0 :       VECS   : origin = 0000h , length =0040h            /* VECTORS */
                ENCPT  : origin = 0040h , length =4            /* 用于2407A 的加密字 */
                PROG   : origin = 0044h , length =07fffh           /* PROGRAM */

    PAGE 1 :       MMRS   : origin =    0h , length =060h             /* MMRS    */
                   B2     : origin = 0060h , length =020h             /* DARAM   */
                   B0     : origin = 0200h , length =0100h            /* DARAM   */
                   B1     : origin = 0300h , length =0100h            /* DARAM   */
}

/*--------------------------------------------------------------------*/
/* SECTIONS ALLOCATION                                                */
/*--------------------------------------------------------------------*/
SECTIONS
{
    .vectors : { } > VECS      PAGE 0   /* Interrupt vector table     */
    .Encrypt : { } > ENCPT     PAGE 0 /* 加密段 */
    .text    : { } > PROG      PAGE 0   /* Code                       */
    .data    : { } > PROG      PAGE 0   /* Initialization data tables */
    .mmrs    : { } > MMRS      PAGE 1   /* Memory mapped registers    */
    .bss     : { } > B2        PAGE 1   /* Block B2                   */
    .blk0    : { } > B0        PAGE 1   /* Block B0                   */
    .blk1    : { } > B1        PAGE 1   /* Block B1                   */
    .blk2    : { } > B2        PAGE 1   /* Block B2                   */

}

原创粉丝点击