Part Number:TMS320F280049COther Parts Discussed in Thread:SFRA
内存分配例程有吗,对应的cmd的堆的例子有相关的例程吗?
Green Deng:
你好,我了解的使用malloc函数不需要对cmd文件做特别的修改,只需要给cmd中的heap段分配足够的大小就可以了。
因为动态内存是分配在heap中的,如果heap分配的空间太小,分配过程中也会产生溢出。
除了在cmd文件中修改heap段的大小之外,还需要在CCS中Project -> Properties -> Build ->C2000 Linker -> Basic Options -> Heap size for …中修改加大一下分配的heap地址空间
,
user5086476:
您看,配置好了大小,还要在cmd设置这个,我这个不太会设置
,
user5086476:
我现在就是只改了CCS中Project -> Properties -> Build ->C2000 Linker -> Basic Options -> Heap size for,但是分配失败,仿真返回为空
,
Green Deng:
额,你是说你只是修改了CCS中的heap大小,没有更改cmd文件中的heap大小吗?方便把cmd中heap这部分包括前后段程序发过来看一下吗
,
user5086476:
MEMORY{ PAGE 0: /* Program Memory */ PAGE 1: /* Data Memory */ BEGIN : origin = 0x00080000, length = 0x00000002 BOOT_RSVD : origin = 0x00000002, length = 0x00000126
/* RAMLS5 : origin = 0x0000A800, length = 0x00000800 *//* RAMLS6 : origin = 0x0000B000, length = 0x00000800 *//* RAMLS7 : origin = 0x0000B800, length = 0x00000800 */ RAMLS567 : origin = 0x0000A600, length = 0x00001A00
/* Flash sectors */ /* BANK 0 *//* FLASHBANK0_SECT0 : origin = 0x00080002, length = 0x00000FFE */ FLASHBANK0_BOOT : origin = 0x00080002, length = 0x00000FFE /* remote update *//* FLASHBANK0_SECT1 : origin = 0x00081000, length = 0x00001000 *//* FLASHBANK0_SECT2 : origin = 0x00082000, length = 0x00001000 *//* FLASHBANK0_SECT3 : origin = 0x00083000, length = 0x00001000 *//* FLASHBANK0_SECT4 : origin = 0x00084000, length = 0x00001000 *//* FLASHBANK0_SECT5 : origin = 0x00085000, length = 0x00001000 *//* FLASHBANK0_SECT6 : origin = 0x00086000, length = 0x00001000 *//* FLASHBANK0_SECT7 : origin = 0x00087000, length = 0x00001000 *//* FLASHBANK0_SECT8 : origin = 0x00088000, length = 0x00001000 *//* FLASHBANK0_SECT9 : origin = 0x00089000, length = 0x00001000 *//* FLASHBANK0_SECT10 : origin = 0x0008A000, length = 0x00001000 *//* FLASHBANK0_SECT11 : origin = 0x0008B000, length = 0x00001000 *//* FLASHBANK0_SECT12 : origin = 0x0008C000, length = 0x00001000 *//* FLASHBANK0_SECT13 : origin = 0x0008D000, length = 0x00001000 */ FLASHBANK0_CODE : origin = 0x00081000, length = 0x0000D000 /* control code */
/* FLASHBANK0_SECT14 : origin = 0x0008E000, length = 0x00001000 */ FLASHBANK0_DATA : origin = 0x0008E000, length = 0x00001000 /* constant data */
FLASHBANK0_SECT15 : origin = 0x0008F000, length = 0x000FF0 FLASHBANK0_SEC15_RSVD : origin = 0x08FFF0, length = 0x000010 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
BOOTROM : origin = 0x003F0000, length = 0x00008000 BOOTROM_EXT : origin = 0x003F8000, length = 0x00007FC0 RESET : origin = 0x003FFFC0, length = 0x00000002
RAMM0S : origin = 0x00000128, length = 0x00000118 /* stack, on-chip RAM block M0 part */ RAMM1D : origin = 0x00000240, length = 0x000005B8 /* on-chip RAM block M0 part & M1 */ RAMM1_RSVD : origin = 0x000007F8, length = 0x00000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
RAMGS0 : origin = 0x0000C000, length = 0x00002000 /**8*16K*/ RAMGS1 : origin = 0x0000E000, length = 0x00002000 /**8*16K*/ RAMGS2 : origin = 0x00010000, length = 0x00002000 /**8*16K*/ RAMGS3 : origin = 0x00012000, length = 0x00001FF8 /**8*16K*/// RAMGS3_RSVD : origin = 0x013FF8, length = 0x000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */ RAMLS4 : origin = 0x0000A000, length = 0x00000600}
SECTIONS{ .reset : > RESET, TYPE = DSECT codestart : > BEGIN, ALIGN(4)
GROUP {#if defined(SFRA_ENABLE) .TI.ramfunc { -l sfra_f32_tmu_eabi.lib<sfra_f32_tmu_collect.obj> (.text) -l sfra_f32_tmu_eabi.lib<sfra_f32_tmu_inject.obj> (.text) }#else .TI.ramfunc#endif ramfuncs /* Digital Controller Library functions */ dclfuncs dcl32funcs } LOAD = FLASHBANK0_CODE RUN = RAMLS567, LOAD_START(RamfuncsLoadStart), LOAD_SIZE(RamfuncsLoadSize), LOAD_END(RamfuncsLoadEnd), RUN_START(RamfuncsRunStart), RUN_SIZE(RamfuncsRunSize), RUN_END(RamfuncsRunEnd), ALIGN(2)
ctrlfuncs : { } LOAD = FLASHBANK0_CODE RUN = RAMLS567, LOAD_START(ctrlfuncsLoadStart), LOAD_SIZE(ctrlfuncsLoadSize), LOAD_END(ctrlfuncsLoadEnd), RUN_START(ctrlfuncsRunStart), RUN_SIZE(ctrlfuncsRunSize), RUN_END(ctrlfuncsRunEnd), ALIGN(2)
.text : > FLASHBANK0_CODE, ALIGN(8) .cinit : > FLASHBANK0_CODE, ALIGN(4) .switch : > FLASHBANK0_CODE, ALIGN(4) .cio : > FLASHBANK0_CODE .pinit : > FLASHBANK0_CODE, ALIGN(4) .const : > FLASHBANK0_CODE, ALIGN(4) .init_array : > FLASHBANK0_CODE, ALIGN(4)
.stack : > RAMM0S .bss : > RAMM1D .bss:output : > RAMM1D .bss:cio : > RAMM1D .data : > RAMM1D .sysmem : > RAMGS1
est_data : > RAMLS4}
SECTIONS{ prms_data : > FLASHBANK0_DATA
GROUP { user_data foc_data } LOAD = RAMM1D LOAD_START(ctrlVarsLoadStart), LOAD_SIZE(ctrlVarsLoadSize), LOAD_END(ctrlVarsLoadEnd)
GROUP { sys_data ctrl_data motor_data } LOAD = RAMGS0 LOAD_START(motorVarsLoadStart), LOAD_SIZE(motorVarsLoadSize), LOAD_END(motorVarsLoadEnd)
GROUP { vibc_data dmaBuf_data
datalog_data graph_data
sfra_data SFRA_F32_Data } LOAD = RAMGS0 LOAD_START(extVarsLoadStart), LOAD_SIZE(extVarsLoadSize), LOAD_END(extVarsLoadEnd)
GROUP { jpf_data } LOAD = RAMGS1 LOAD_START(jpfVarsLoadStart), LOAD_SIZE(jpfVarsLoadSize), LOAD_END(jpfVarsLoadEnd)}
这是我的CMD文件,.sysmem 不是堆的大小嘛?还需要增加别的说明堆的大小嘛?我看手册说声明那个全局变量,那个怎么弄呢?
,
user5086476:
麻烦在帮我看下
,
Green Deng:
抱歉我看了一下几个官方cmd文件,里面也没涉及heap段的配置,这个问题我可能要再咨询一下其他工程师。
目前你的程序调用malloc函数是会出现什么问题呢?
,
user5086476:
调用malloc有时候会进入异常,没有分配到,返回中为空。而且我看map文件,没有找到堆的起始和结束地址
,
Green Deng:
收到,我这边咨询收到回复会尽快反馈给你。
,
user5086476:
好的,谢谢您
,
Green Deng:
CCS中–heap_size设置的是多少?
CCS中,console的信息都有些什么?
你附上的cmd文件,工程师唯一发现的问题是 sysmem 和 jpf_data 都在 GSRAM1 中。 尝试将sysmem 移动到 LSRAMx。
,
user5086476:
堆的大小设置成了0x100,我把。sysmen弄到了lsram1可以了,这是为啥?不能放到gsram嘛?
,
Green Deng:
原则上可以把sysmem放在GSRAM中,但是某种情况下GSRAM1可能因为某种原因被CPU访问阻塞了。