DSP中的CMD文件是链接命令文件(Linker Command File),以.cmd为后缀。
在分析cmd文件之前,必需先了解
(1)DSP具体芯片的内存映射(Memory Map)
(2)知道点链接的知识,知道C程序中段的概念
(3)知道RAM,Flash等存储模块的区别
======================================================================
1. coff目标文件
======================================================================
coff是一种流行的二进制可执行文件格式,在CCS v5中扩展名为.out,可以直接
下载到芯片中。可执行文件包括段头、可执行代码、初始化数据、可重定位信息
和符号表字符串表等信息。
编译器处理段的过程为:
(1)把每个源文件都编译成独立目标文件(.obj),每个目标文件都有自己的段
(2)链接器将目标文件中相同段名的部分连接在一起,生成最终的coff可执行文件
CCS v5中的Compile Files完成功能(1),Build完成功能(2)。
======================================================================
2. TMS320C6713内存映射
======================================================================
======================================================================
3. 自定义代码段和数据段
======================================================================
// 将symbol分配到section name指示的数据段
#pragma DATA_SECTION(symbol, "section name");
// 将symbol分配到section name指示的代码段
#pragma CODE_SECTION(symbol, "section name");
常常结合结构体定义symbol,如下,
volatile struct Symbol symbol; // Symbol预先定义好的描述特定外设的结构
比如,对于C6713中的Timer0外设,做如下定义,
<span style="line-height: 1.5;">struct Timer0 { </span>
...
}
#pragma DATA_SECTION(C6713_Timer0, "C6713_Timer0_cmd");
volatile struct Timer0 C6713_Timer0;
"C6713_Timer0_cmd"将在cmd文件中分配空间。
<span style="line-height: 1.5;">/****************************************************************************/ </span>
/* C6713.cmd */
/* Copyright (c) 2010 Texas Instruments Incorporated */
/* */
/* 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 TMS320C6713 */
/* device. Use it as a guideline. You will want to */
/* 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. */
/* */
/****************************************************************************/
-stack 0x2000
-heap 0x8000
MEMORY
{
IRAM o = 0x00000000 l = 0x00030000 /* 192kB - Internal RAM */
L2RAM o = 0x00030000 l = 0x00010000 /* 64kB - Internal RAM/CACHE */
EMIFCE0 o = 0x80000000 l = 0x10000000 /* SDRAM in 6713 DSK */
EMIFCE1 o = 0x90000000 l = 0x10000000 /* Flash/CPLD in 6713 DSK */
EMIFCE2 o = 0xA0000000 l = 0x10000000 /* Daughterboard in 6713 DSK */
EMIFCE3 o = 0xB0000000 l = 0x10000000 /* Daughterboard in 6713 DSK */
}
SECTIONS
{
.text > IRAM
.stack > IRAM
.bss > IRAM
.cio > IRAM
.const > IRAM
.data > IRAM
.switch > IRAM
.sysmem > IRAM
.far > IRAM
.args > IRAM
.ppinfo > IRAM
.ppdata > IRAM
/* COFF sections */
.pinit > IRAM
.cinit > IRAM
/* EABI sections */
.binit > IRAM
.init_array > IRAM
.neardata > IRAM
.fardata > IRAM
.rodata > IRAM
.c6xabi.exidx > IRAM
.c6xabi.extab > IRAM
}
一周热门 更多>