版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接: https://blog.csdn.net/scottly1/article/details/40380077
            </div><!--一个博主专栏付费入口--><!--一个博主专栏付费入口结束--><link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-4a3473df85.css"><link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-4a3473df85.css"><div class="htmledit_views" id="content_views">

1.CMD文件的作用

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

2.C语言生成的段

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

已初始化段:

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

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

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

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

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

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

以.const段为例:

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

未初始化段:

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

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

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

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

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

3.自定义段

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

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

symbol——符号,可以是函数名/变量名

section name——自定义的段名

CODE_SECTION用来定义代码段

DATA_SECTION用来定义数据段

注意

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

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

例子:

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

4.CMD文件

在DSP28335工程文件里(不用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文件可以在所有工程文件中通用,主要作用是把外设寄存器产生的数据段映射到对应的存储空间,可以跟DSP2833x_GlobalVariableDefs.c文件对照一下看看。在我的上一篇文章中也有提到。

其实我们也不需要详细的知道如何编写cmd文件,可以照着原有的修改就可以了。

下面是官方28335_RAM_lnk.cmd,一般情况下直接用TI给的,不需要做修改即可满足调试用,模式较固定,当然你也可以做相应的修改用到哪块RAM存储空间,在CMD文件里做相应的分配即可。

  1. MEMORY
  2. {
  3. PAGE 0 :
  4. /* BEGIN is used for the "boot to SARAM" bootloader mode */
  5. BEGIN : origin = 0x000000, length = 0x000002 /* Boot to M0 will go here */
  6. RAMM0 : origin = 0x000050, length = 0x0003B0
  7. RAML0 : origin = 0x008000, length = 0x001000
  8. RAML1 : origin = 0x009000, length = 0x001000
  9. RAML2 : origin = 0x00A000, length = 0x001000
  10. RAML3 : origin = 0x00B000, length = 0x001000
  11. ZONE7A : origin = 0x200000, length = 0x00FC00 /* XINTF zone 7 - program space */
  12. CSM_RSVD : origin = 0x33FF80, length = 0x000076 /* Part of FLASHA. Program with all 0x0000 when CSM is in use. */
  13. CSM_PWL : origin = 0x33FFF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */
  14. ADC_CAL : origin = 0x380080, length = 0x000009
  15. RESET : origin = 0x3FFFC0, length = 0x000002
  16. IQTABLES : origin = 0x3FE000, length = 0x000b50
  17. IQTABLES2 : origin = 0x3FEB50, length = 0x00008c
  18. FPUTABLES : origin = 0x3FEBDC, length = 0x0006A0
  19. BOOTROM : origin = 0x3FF27C, length = 0x000D44
  20. PAGE 1 :
  21. /* BOOT_RSVD is used by the boot ROM for stack. */
  22. /* This section is only reserved to keep the BOOT ROM from */
  23. /* corrupting this area during the debug process */
  24. BOOT_RSVD : origin = 0x000002, length = 0x00004E /* Part of M0, BOOT rom will use this for stack */
  25. RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
  26. RAML4 : origin = 0x00C000, length = 0x001000
  27. RAML5 : origin = 0x00D000, length = 0x001000
  28. RAML6 : origin = 0x00E000, length = 0x001000
  29. RAML7 : origin = 0x00F000, length = 0x001000
  30. ZONE7B : origin = 0x20FC00, length = 0x000400 /* XINTF zone 7 - data space */
  31. }
  32. SECTIONS
  33. {
  34. /* Setup for "boot to SARAM" mode:
  35. The codestart section (found in DSP28_CodeStartBranch.asm)
  36. re-directs execution to the start of user code. */
  37. codestart : > BEGIN, PAGE = 0
  38. ramfuncs : > RAML0, PAGE = 0
  39. .text : > RAML1, PAGE = 0
  40. .cinit : > RAML0, PAGE = 0
  41. .pinit : > RAML0, PAGE = 0
  42. .switch : > RAML0, PAGE = 0
  43. .stack : > RAMM1, PAGE = 1
  44. .ebss : > RAML4, PAGE = 1
  45. .econst : > RAML5, PAGE = 1
  46. .esysmem : > RAMM1, PAGE = 1
  47. IQmath : > RAML1, PAGE = 0
  48. IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD
  49. /* Uncomment the section below if calling the IQNexp() or IQexp()
  50. functions from the IQMath.lib library in order to utilize the
  51. relevant IQ Math table in Boot ROM (This saves space and Boot ROM
  52. is 1 wait-state). If this section is not uncommented, IQmathTables2
  53. will be loaded into other memory (SARAM, Flash, etc.) and will take
  54. up space, but 0 wait-state is possible.
  55. */
  56. /*
  57. IQmathTables2 : > IQTABLES2, PAGE = 0, TYPE = NOLOAD
  58. {
  59. IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)
  60. }
  61. */
  62. FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD
  63. DMARAML4 : > RAML4, PAGE = 1
  64. DMARAML5 : > RAML5, PAGE = 1
  65. DMARAML6 : > RAML6, PAGE = 1
  66. DMARAML7 : > RAML7, PAGE = 1
  67. ZONE7DATA : > ZONE7B, PAGE = 1
  68. .reset : > RESET, PAGE = 0, TYPE = DSECT /* not used */
  69. csm_rsvd : > CSM_RSVD PAGE = 0, TYPE = DSECT /* not used for SARAM examples */
  70. csmpasswds : > CSM_PWL PAGE = 0, TYPE = DSECT /* not used for SARAM examples */
  71. /* Allocate ADC_cal function (pre-programmed by factory into TI reserved memory) */
  72. .adc_cal : load = ADC_CAL, PAGE = 0, TYPE = NOLOAD
  73. }
  74. /*
  75. //===========================================================================
  76. // End of file.
  77. //===========================================================================
  78. */

下面是官方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

  1. MEMORY
  2. {
  3. PAGE 0: /* Program Memory */
  4. /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */
  5. ZONE0 : origin = 0x004000, length = 0x001000 /* XINTF zone 0 */
  6. RAML0 : origin = 0x008000, length = 0x001000 /* on-chip RAM block L0 */
  7. RAML1 : origin = 0x009000, length = 0x001000 /* on-chip RAM block L1 */
  8. RAML2 : origin = 0x00A000, length = 0x001000 /* on-chip RAM block L2 */
  9. RAML3 : origin = 0x00B000, length = 0x001000 /* on-chip RAM block L3 */
  10. ZONE6 : origin = 0x0100000, length = 0x100000 /* XINTF zone 6 */
  11. ZONE7A : origin = 0x0200000, length = 0x00FC00 /* XINTF zone 7 - program space */
  12. FLASHH : origin = 0x300000, length = 0x008000 /* on-chip FLASH */
  13. FLASHG : origin = 0x308000, length = 0x008000 /* on-chip FLASH */
  14. FLASHF : origin = 0x310000, length = 0x008000 /* on-chip FLASH */
  15. FLASHE : origin = 0x318000, length = 0x008000 /* on-chip FLASH */
  16. FLASHD : origin = 0x320000, length = 0x008000 /* on-chip FLASH */
  17. FLASHC : origin = 0x328000, length = 0x008000 /* on-chip FLASH */
  18. FLASHA : origin = 0x338000, length = 0x007F80 /* on-chip FLASH */
  19. CSM_RSVD : origin = 0x33FF80, length = 0x000076 /* Part of FLASHA. Program with all 0x0000 when CSM is in use. */
  20. BEGIN : origin = 0x33FFF6, length = 0x000002 /* Part of FLASHA. Used for "boot to Flash" bootloader mode. */
  21. CSM_PWL : origin = 0x33FFF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */
  22. OTP : origin = 0x380400, length = 0x000400 /* on-chip OTP */
  23. ADC_CAL : origin = 0x380080, length = 0x000009 /* ADC_cal function in Reserved memory */
  24. IQTABLES : origin = 0x3FE000, length = 0x000b50 /* IQ Math Tables in Boot ROM */
  25. IQTABLES2 : origin = 0x3FEB50, length = 0x00008c /* IQ Math Tables in Boot ROM */
  26. FPUTABLES : origin = 0x3FEBDC, length = 0x0006A0 /* FPU Tables in Boot ROM */
  27. ROM : origin = 0x3FF27C, length = 0x000D44 /* Boot ROM */
  28. RESET : origin = 0x3FFFC0, length = 0x000002 /* part of boot ROM */
  29. VECTORS : origin = 0x3FFFC2, length = 0x00003E /* part of boot ROM */
  30. PAGE 1 : /* Data Memory */
  31. /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */
  32. /* Registers remain on PAGE1 */
  33. BOOT_RSVD : origin = 0x000000, length = 0x000050 /* Part of M0, BOOT rom will use this for stack */
  34. RAMM0 : origin = 0x000050, length = 0x0003B0 /* on-chip RAM block M0 */
  35. RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
  36. RAML4 : origin = 0x00C000, length = 0x001000 /* on-chip RAM block L1 */
  37. RAML5 : origin = 0x00D000, length = 0x001000 /* on-chip RAM block L1 */
  38. RAML6 : origin = 0x00E000, length = 0x001000 /* on-chip RAM block L1 */
  39. RAML7 : origin = 0x00F000, length = 0x001000 /* on-chip RAM block L1 */
  40. ZONE7B : origin = 0x20FC00, length = 0x000400 /* XINTF zone 7 - data space */
  41. FLASHB : origin = 0x330000, length = 0x008000 /* on-chip FLASH */
  42. }
  43. /* Allocate sections to memory blocks.
  44. Note:
  45. codestart user defined section in DSP28_CodeStartBranch.asm used to redirect code
  46. execution when booting to flash
  47. ramfuncs user defined section to store functions that will be copied from Flash into RAM
  48. */
  49. SECTIONS
  50. {
  51. /* Allocate program areas: */
  52. .cinit : > FLASHA PAGE = 0
  53. .pinit : > FLASHA, PAGE = 0
  54. .text : > FLASHA PAGE = 0
  55. codestart : > BEGIN PAGE = 0
  56. ramfuncs : LOAD = FLASHD,
  57. RUN = RAML0,
  58. LOAD_START(_RamfuncsLoadStart),
  59. LOAD_END(_RamfuncsLoadEnd),
  60. RUN_START(_RamfuncsRunStart),
  61. PAGE = 0
  62. csmpasswds : > CSM_PWL PAGE = 0
  63. csm_rsvd : > CSM_RSVD PAGE = 0
  64. /* Allocate uninitalized data sections: */
  65. .stack : > RAMM1 PAGE = 1
  66. .ebss : > RAML4 PAGE = 1
  67. .esysmem : > RAMM1 PAGE = 1
  68. /* Initalized sections go in Flash */
  69. /* For SDFlash to program these, they must be allocated to page 0 */
  70. .econst : > FLASHA PAGE = 0
  71. .switch : > FLASHA PAGE = 0
  72. /* Allocate IQ math areas: */
  73. IQmath : > FLASHC PAGE = 0 /* Math Code */
  74. IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD
  75. /* Uncomment the section below if calling the IQNexp() or IQexp()
  76. functions from the IQMath.lib library in order to utilize the
  77. relevant IQ Math table in Boot ROM (This saves space and Boot ROM
  78. is 1 wait-state). If this section is not uncommented, IQmathTables2
  79. will be loaded into other memory (SARAM, Flash, etc.) and will take
  80. up space, but 0 wait-state is possible.
  81. */
  82. /*
  83. IQmathTables2 : > IQTABLES2, PAGE = 0, TYPE = NOLOAD
  84. {
  85. IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)
  86. }
  87. */
  88. FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD
  89. /* Allocate DMA-accessible RAM sections: */
  90. DMARAML4 : > RAML4, PAGE = 1
  91. DMARAML5 : > RAML5, PAGE = 1
  92. DMARAML6 : > RAML6, PAGE = 1
  93. DMARAML7 : > RAML7, PAGE = 1
  94. /* Allocate 0x400 of XINTF Zone 7 to storing data */
  95. ZONE7DATA : > ZONE7B, PAGE = 1
  96. /* .reset is a standard section used by the compiler. It contains the */
  97. /* the address of the start of _c_int00 for C Code. /*
  98. /* When using the boot ROM this section and the CPU vector */
  99. /* table is not needed. Thus the default type is set here to */
  100. /* DSECT */
  101. .reset : > RESET, PAGE = 0, TYPE = DSECT
  102. vectors : > VECTORS PAGE = 0, TYPE = DSECT
  103. /* Allocate ADC_cal function (pre-programmed by factory into TI reserved memory) */
  104. .adc_cal : load = ADC_CAL, PAGE = 0, TYPE = NOLOAD
  105. }
  106. /*
  107. //===========================================================================
  108. // End of file.
  109. //===========================================================================
  110. */

具体的工程实例,以后会给出;

TMS320F28335项目开发记录6_28335之cmd文件详解相关推荐

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

    TMS320F28335项目开发记录9_28335之中断系统 2014年11月08日 12:00:12 阅读数:3104 28335中断系统 1.中断系统 在这里我们要十分清楚DSP的中断系统.C28 ...

  2. CMD文件详解与DSP存储空间

    CMD文件详解与DSP存储空间 CMD的全称为链接命令配置文件.以ROM/FLASH和RAM两类存储器为对象,用户通过编写CMD文件,来管理和分配系统中的所有物理存储器和地址空间.DSP芯片的片内存储 ...

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

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

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

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

  5. F28335之cmd文件详解

    1.CMD文件的作用 CMD文件的作用就像仓库的货物摆放记录一样,为程序代码和数据分配指定的空间. 2.C语言生成的段 C语言生成的段大致分为两大类:初始化和未初始化,已初始化的段含有真正的指令和数据 ...

  6. [CMD] DSP CMD文件详解

    目录 1. CMD文件是什么? 2. CMD文件的功能 3. CMD文件的使用方法 MEMORY伪指令--指示存储空间 SECTIONS伪指令--分配段到存储空间 4. 注意事项 1. CMD文件是什 ...

  7. TMS320F28335项目开发记录10_28335之SCI模块

    28335之SCI模块 1.介绍 TMS320F28335内部有三个SCI模块,SCIA.SCIB.SCIC. 每一个SCI模块都有一个接收器和发送器,SCI的接收器和发送器各有一个16级的FIFO( ...

  8. 无人机项目跟踪记录八十一----电机驱动电路详解

    电机驱动电路进行了更改如下图所示: 在电路中加入了,肖特基续流二极管和滤波电容,作用是防止电机被击穿和当电源断开时,将电机上的电流释放的作用. 然后利用mos管可以驱动大电流的特点作为驱动元件.R16 ...

  9. 无人机项目跟踪记录八十----陀螺仪电路详解

    陀螺仪模块请参看以下连接:https://blog.csdn.net/wyssailing/article/details/121506972

最新文章

  1. composer更新_深入学习Composer原理(四)
  2. flex的12个属性
  3. 远程连接Oracle 数据库连接报错ORA-12638身份检索失败
  4. bzoj2721樱花——质因数分解
  5. php while结束循环吗,php while循环退不出是什么有关问题
  6. c语言~符号_条件编译指令(符号),C语言条件编译指令完全攻略
  7. Improving Opencv 2:The Core Functionality :How to scan images, lookup tables
  8. php 修改 wordpress,wordpress如何修改php.ini
  9. pandas DataFrame 分组求和
  10. ARM 汇编详解 -- 体系结构与编程
  11. vue 关于数组的固定随机排序
  12. PDF附加字体和不附加字体
  13. 1995-2013年RSA大会历届主题回顾
  14. JVM与Java体系结构
  15. RabbitMQ的安装教程
  16. Masonry 设置宽高比例
  17. Centos7 源码安装 Apache
  18. windpy 连接数据库_python wind数据库
  19. Ubuntu的搜狗输入法卡角落不显示
  20. 交换机进行syslog服务器设置

热门文章

  1. linux expr字符串,linux expr 命令
  2. 移动互联网创业最终要围绕四个bing来进行
  3. 每日新闻 | 耐克发布新鞋:可通过苹果Siri语音控制系鞋带
  4. 五星元老大飞哥,教半年Java实习生小飞飞:优雅解决历史代码中的新需求
  5. 奥运英语[2] 你好! 早上好!Hi! Good Morning.
  6. html缩放背景不缩放_如何将缩放背景更改为有趣的照片或视频
  7. 我在建站过程中的一点心得体会
  8. C++入门——实现贪吃蛇游戏
  9. 程序设计模式————编程模式
  10. continue的使用