CMD配置及解决方案
F28335.cmd
- F28335.cmd用于控制程序如何在特定的内存布局中运行,确保程序和数据按正确的顺序加载并存储在合适的区域。
MEMORY
{
PAGE 0: /* Program Memory */
/* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */
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 */
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 */
FLASHB : origin = 0x330000, 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 */
}
/* 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 : > FLASHB PAGE = 0
.pinit : > FLASHB, PAGE = 0
.text : > FLASHB PAGE = 0
codestart : > BEGIN PAGE = 0
ramfuncs : > FLASHB PAGE = 0
csmpasswds : > CSM_PWL PAGE = 0
csm_rsvd : > CSM_RSVD PAGE = 0
/* Allocate uninitalized data sections: */
.stack : > RAMM1 PAGE = 1
.ebss : > RAML5 PAGE = 1
.esysmem : > RAMM1 PAGE = 1
/* Initalized sections go in Flash */
/* For SDFlash to program these, they must be allocated to page 0 */
.econst : > FLASHB PAGE = 0
.switch : > FLASHB PAGE = 0
/* Allocate IQ math areas: */
IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD
IQmathTables2 : > IQTABLES2, PAGE = 0, TYPE = NOLOAD
FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD
.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.
//===========================================================================
*/
MEMORY 部分:定义内存的物理布局
-
PAGE 0: Program Memory
- 程序代码和启动相关数据存储的区域(图像来源: TMS320F2833x、TMS320F2823x 实时微控制器说明):

- RAML0 至 RAML3: 定义了四个内存块(L0 到 L3),每个块从不同的地址开始,大小为 4KB(0x001000)。
- FLASHH 至 FLASHA: 这些是 Flash 存储区域的定义,通常用于存储程序代码和常量数据。
- CSM_RSVD: 该区域(origin = 0x33FF80, length = 0x000076 )与加密服务模块(CSM)相关,通常用于存储安全配置或密钥。
- BEGIN: 定义了一个特定的引导地址,用于启动时跳转到 Flash 引导加载程序。
- CSM_PWL: 用于存储 CSM 密码位置。
- OTP: 一次性可编程存储区(OTP),用于存储特殊配置或厂商数据。
- ADC_CAL: 用于存储 ADC 校准数据的预留存储区域。
- IQTABLES, FPUTABLES: 存储 IQ 数学表和浮点运算表,这些通常用于信号处理或计算密集型应用。
- ROM: 启动程序的 Boot ROM,存储程序的启动代码。
- RESET 和 VECTORS: 用于存储复位向量和中断向量,启动时从这些地址开始执行。
- 程序代码和启动相关数据存储的区域(图像来源: TMS320F2833x、TMS320F2823x 实时微控制器说明):
-
PAGE 1: Data Memory
-
数据存储区域,用于存储程序运行时的变量、栈和未初始化的数据。

-
BOOT_RSVD: 用于启动时的栈空间。
-
RAMM0 至 RAMM1: 这些是额外的 RAM 区域,分别提供不同的 RAM 块,供程序运行时使用。
-
RAML4 至 RAML7: 更多的 RAM 区块,用于存储数据或缓存。
-
SECTIONS 部分:定义程序区域与内存的映射
- SECTIONS 部分定义了如何将程序的各个部分映射到这些内存区域,指定了各个代码段和数据段的具体位置。
-
程序区域(.cinit, .pinit, .text 等)
.cinit,.pinit,.text: 这些是代码和初始化数据的区域,指向 Flash 区域。- codestart: 指定了程序启动时的入口点,用来设置程序的初始化流程。
- ramfuncs: 存储一些从 Flash 加载到 RAM 执行的函数。
-
未初始化的数据区域(.stack, .ebss 等)
.stack: 用于存储栈,位于 RAMM1 区域。.ebss: 用于存储未初始化的全局变量,位于 RAML5 区域。.esysmem: 用于系统内存,存储可能需要初始化的数据。
-
初始化的数据(.econst, .switch 等)
.econst,.switch: 这些是已初始化的常量数据,存储在 Flash 中。
-
IQ 数学表区域
- IQmathTables 和 FPUmathTables 存储了用于信号处理的数学表,指向 Flash 区域并标记为
NOLOAD,意味着这些表不会在链接时加载到内存,而是由启动代码负责加载。
- IQmathTables 和 FPUmathTables 存储了用于信号处理的数学表,指向 Flash 区域并标记为
-
ADC 校准函数(.adc_cal)
- .adc_cal: 这是一个特殊的区域,用于存储由工厂预编程到 OTP 区域的 ADC 校准数据。
错误:编译器无法将你的程序放置到指定的内存区域

- 程序中添加一句printf输出后
- 程序的大小超过了目标硬件(在这个例子中是 TMS320F2812 DSP)可用的闪存空间。具体来说,
.text段的大小为0x1fcb字节,而可用的 FLASHA 空间只有0x1f80字节
>> Compilation failure
makefile:164: recipe for target 'test1.out' failed
"../CMD/F2812.cmd", line 128: error #10099-D: program will not fit into available memory. placement with alignment/blocking fails for section ".text" size 0x1fcb page 0. Available memory ranges:
FLASHA size: 0x1f80 unused: 0x1c91 max hole: 0x1c91
error #10010: errors encountered during linking; "test1.out" not built
gmake: *** [test1.out] Error 1
gmake: Target 'all' not remade because of errors.
解决方法:调整 .text 段的放置
-
目前,
.text段被放置在FLASHA中,但它的大小超出了该区域的容量。可以考虑将部分代码或数据段移动到其他可用的内存区域(或者调整现有区域的大小)。 -
修改后的 SECTIONS 部分
.text : > FLASHC PAGE = 0 /* 尝试将 .text 移动到更大的 FLASHC 区域 */
- 另外需要注意:printf的内容需要加入
/n,否则可能无法正常显示
3178

被折叠的 条评论
为什么被折叠?



