1.CMD文件的作用

CMD文件的作用就像仓库的货物摆放记录一样,为程序代码数据分配指定的空间。

2.C语言生成的段

C语言生成的段大致分为两大类:初始化和未初始化,已初始化的段含有真正的指令和数据,未初始化段仅仅是保留变量的地址空间。已初始化段通常放在程序空间,未初始化段通常放在数据空间。

已初始化段:

.text——C语言编译生成的汇编指令代码存放于此

.cinit——存放初始化的全局和静态变量

.const——字符串常量和const定义的全局和静态变量

.econst——字符串常量和far const定义的全局和静态变量

.print——全局构造器(C++)程序列表

.switch——存放switch语句产生的常数表格

以.const段为例:

const int a = 10;  //注意必须是全局的 假设声明为局部const初始化变量,不会放在.const段,局部变量都是执行时放在.bss段中
char * p = "ABC";
数组和结构体的初始值——是局部变量时。产生的是.const,假设是全局变量,产生的是.cinit

未初始化段:

.bss——为全局变量和局部变量保留的空间,程序上电时,.cinit空间中的数据复制出来并存放在.bss空间中

.ebss——为使用大寄存器模式时预留的全局和局部变量空间,程序上电时,.cinit空间中的数据复制出来并存放在.bss空间中

.stack——堆栈空间,主要用于函数传递变量或为局部变量分配空间

.system——为动态存储分配保留的空间(malloc)。假设有宏函数,此空间被占用

.esystem——为动态存储分配保留的空间(far malloc)。假设有far函数,此空间会被占用

3.自己定义段

上面的都是官方预先定义好的。我们能够定义自己的段么?能够。使用例如以下语句:

#pragma CODE_SECTION(symbol, "section name");
#pragma DATA_SECTION(symbol, "section name");

symbol——符号。能够是函数名/变量名

section name——自己定义的段名

CODE_SECTION用来定义代码段

DATA_SECTION用来定义数据段

注意

不能再函数体内声明#pragma;

必须在符号被定义和使用之前声明#pragma

样例:

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

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2NvdHRseTE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

4.CMD文件

在DSP28335project文件中(不用BIOS产生CMD文件),手写CMD文件一般有两个,RAM里调试时用的两个CMD文件分别为DSP2833x_Headers_nonBIOS.cmd和28335_RAM_lnk.cmd,烧写到flash里时用的两个CMD文件分别为DSP2833x_Headers_nonBIOS.cmd和F28335.cmd,当中DSP2833x_Headers_nonBIOS.cmd文件能够在全部project文件中通用。主要作用是把外设寄存器产生的数据段映射到相应的存储空间,能够跟DSP2833x_GlobalVariableDefs.c文件对比一下看看。

在我的上一篇文章中也有提到。

事实上我们也不须要具体的知道怎样编写cmd文件,能够照着原有的改动就能够了。

以下是官方28335_RAM_lnk.cmd,普通情况下直接用TI给的,不须要做改动就可以满足调试用,模式较固定,当然你也能够做对应的改动用到哪块RAM存储空间。在CMD文件中做对应的分配就可以。

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 = 0x000D44 PAGE 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.
//===========================================================================
*/

以下是官方F28335.cmd;

编写用于flash烧写的F28335.cmd文件时相对来说较复杂些,依据不同的情况须要做一些改动。

1 不须要把部分代码copy到RAM里,普通情况不须要外扩RAM等时直接用TI的F28335.cmd就可以。

2 须要把部分代码从flash 拷贝到RAM里,如延时函数DSP2833x_usDelay.asm等。这时CMD文件须要做对应的改动,详细參考博文:http://blog.sina.com.cn/s/blog_762cf5f80101asmq.html

3 从时间开销方面考虑,须要把整个程序从flash拷贝到RAM里,这时程序及CMD文件都要做对应的改动。详细參考博文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.
//===========================================================================
*/

详细的project实例。以后会给出;

TMS320F28335项目开发记录6_28335之cmd文件具体解释的更多相关文章

  1. TMS320F28335项目开发记录1_CCS的使用介绍

    CCS使用介绍 一.前言 本系列文章记录本人实际项目开发时对ti的DSP28335,以及CCS开发环境等的学习与记录,相对于2812来说,28335的资料还是比較少的,只是原理是相通的,28335说白 ...

  2. TMS320F28335项目开发记录5_28335之CCS编程基础

    CCS开发环境已经为我们封装好了很多片内外设寄存器的结构体,我们仅仅须要包括对应的官方的头文件就能够使用了,那么它的内部详细是怎样实现的呢? 以下来一个典型的样例: 1.使用结构体和联合体 A.用st ...

  3. TMS320F28335项目开发记录2_CCS与JTAG仿真器连接问题汇总

    CCS与仿真器连接问题 实际使用过程中.仿真器和CCS连接可能出现这样或那样的问题,或许你的连接非常成功,没碰到过什么问题.但我的问题的确不少,可能与电脑配置有关吧,也可能与人品有关吧. 以下的自己的 ...

  4. TMS320F28335项目开发记录9_28335中断系统

    28335中断系统 1.中断系统 在这里我们要十分清楚DSP的中断系统. C28XX一共同拥有16个中断源,当中有2个不可屏蔽的中断RESET和NMI.定时器1和定时器2分别使用中断13和14.这样还 ...

  5. TMS320F28335项目开发记录3_28335简介

    28335特性介绍 高性能静态CMOS技术         高达150MHZ(6.67ns的周期时间):1.9V / 1.8内核 ,3.3V I/O设计 高性能32位CPU         IEEE- ...

  6. Anytime项目开发记录0

    Anytime,中文名:我很忙. 开发者:孤独的猫咪神. 这个项目会持续更新,直到我决定不再维护这个APP. 2014年3月10日:近日有事,暂时断更.希望可以会尽快完事. 2014年3月27日:很抱 ...

  7. Android项目开发填坑记-so文件引发的攻坚战

    故事的最初 我负责的项目A要求有播放在线视频的功能,当时从别人的聊天记录的一瞥中发现百度有相关的SDK,当时找到的是Baidu-T5Player-SDK-Android-1.4s,项目中Demo的so ...

  8. Unity3D Demo项目开发记录

    前言 经过一段时间的学习与实际开发,unity3D也勉强算是强行入门了,正所谓好记性不如烂笔头,更何况本人并非专业从事unity3D开发,会一点C#但也并不熟悉,为了避免后期遗忘,因此特意整理了一个D ...

  9. Excel vba中访问ASP.NET MVC项目,记录访问时间,文件名称

    每30秒连接一次服务器,连接成功单元格变绿色,连接失败变红色,状态单元格为17行,2列 1,打开excel文件,进入vba编辑器,新建一个modules模块,在里面先写一个每30秒执行一次ConnSe ...

随机推荐

  1. java_线程分类

    线程分为守护线程和用户线程,如java虚拟机的回收机制就是守护线程,线程开始运行它就启动,线程结束它就结束 用户线程变守护线程:Thread(线程).setDaemon(true)

  2. Danfoss Motor - Automotive Motor: What Sensors Are There?

    The   Danfoss Motor     states that the motor sensor control system is the heart of the entire autom ...

  3. 自动下载相对应的jar包

    一.去到需要的 maven下载地址 http://mvnrepository.com/artifact/org.apache.struts/struts2-core/2.5.13 二.然后去到 pom ...

  4. Linux下启动tomcat报java.lang.OutOfMemoryError: PermGen space

    一.错误信息 java.lang.reflect.InvocationTargetException    at sun.reflect.NativeMethodAccessorImpl.invoke ...

  5. Samba 学习笔记

    这个网站不错.https://www.ibm.com/developerworks/cn/linux/l-lpic3-311-1/

  6. linux下nginx、php和mysql安装配置

    一.安装nginx 安装nginx yum install -y epel-release yum install nginx -y 查看nginx软件包包括了哪些文件 rpm -ql nginx 启 ...

  7. ELK6.3.2+filebeat部署过程

    ELK安装部署 elk作为公司的日志收集检索的方案的首选,是必要的工具,下面介绍一下elk的安装部署方法,以及一些报错的解决方法:(使用的是ubuntu16.04,jdk使用1.8,ELK的版本为6. ...

  8. windows下mysql 5.7版本中修改编码为utf-8的方法

    方法如下 首先通过 show variables like 'character_set_%';查看mysql字符集情 默认编码为 latin1 然后关闭数据库 在mysql安装目录下找到my.ini ...

  9. Zoj 3781(构造)

    Zoj 3781(构造) Zoj 3781 As we all know, Coach Gao is a talented chef, because he is able to cook M dis ...

  10. SpringBoot第十六篇:自定义starter

    作者:追梦1819 原文:https://www.cnblogs.com/yanfei1819/p/11058502.html 版权声明:本文为博主原创文章,转载请附上博文链接! 前言   这一段时间 ...