This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BIOS.heapSize分配堆的大小

Other Parts Discussed in Thread: SYSBIOS

请问一下,利用如下代码在cfg文件分配BIOS.heapSize时候,会跳出一条警告,然后我用的malloc函数也算不能使用的,执行程序就会跳入exit.c不知道什么原因

/*
* The BIOS module will create the default heap for the system.
* Specify the size of this default heap.
*/
BIOS.heapSize =0x00100000;
BIOS.heapSection = "systemHeap";

产生的warning如下:

Description Resource Path Location Type
#10247-D null: creating output section "systemHeap" without a SECTIONS specification 716_algorithm C/C++ Problem

  • 从报错信息看,cmd文件里没有定义systemHeap,请检查一下您的cmd文件。
  • cmd文件如下,显示 .sysmem: load > DDR
    SECTIONS
    {
    .text: load >> DDR
    .ti.decompress: load > DDR
    .stack: load > DDR
    GROUP: load > DDR
    {
    .bss:
    .neardata:
    .rodata:
    }
    .cinit: load > DDR
    .pinit: load >> DDR
    .init_array: load > DDR
    .const: load >> DDR
    .data: load >> DDR
    .fardata: load >> DDR
    .switch: load >> DDR
    .sysmem: load > DDR
    .far: load >> DDR
    .args: load > DDR align = 0x4, fill = 0 {_argsize = 0x0; }
    .cio: load >> DDR
    .ti.handler_table: load > DDR
    .c6xabi.exidx: load > DDR
    .c6xabi.extab: load >> DDR
    .vecs: load > DDR
    xdc.meta: load > DDR, type = COPY

    }

    然后在map文件里面,
    systemHeap
    * 0 11700000 00100000 UNINITIALIZED
    11700000 00100000 app_pe674.oe674 (systemHeap)
    但是一执行malloc就出错
  • SEGMENT ALLOCATION MAP

    run origin load origin length init length attrs members
    ---------- ----------- ---------- ----------- ----- -------
    11700000 11700000 00100000 00000000 rw-
    11700000 11700000 00100000 00000000 rw- systemHeap
    c0000000 c0000000 0005e4b4 00000000 rw-
    c0000000 c0000000 0005e4b4 00000000 rw- .far
    c005e4b8 c005e4b8 00000008 00000008 r--
    c005e4b8 c005e4b8 00000008 00000008 r-- .const.1
    c005e4c0 c005e4c0 0004fb4e 0004fb4e r-x
    c005e4c0 c005e4c0 0004bae0 0004bae0 r-x .text
    c00a9fa0 c00a9fa0 0000406e 0000406e r-- .const.2
    c00ae010 c00ae010 00004b04 00000000 rw-
    c00ae010 c00ae010 00002800 00000000 rw- .stack
    c00b0810 c00b0810 00002304 00000000 rw- .fardata
    c00b2b14 c00b2b14 00000388 00000388 r--
    c00b2b14 c00b2b14 00000388 00000388 r-- .switch
    c00b2ea0 c00b2ea0 0000026c 00000000 rw-
    c00b2ea0 c00b2ea0 00000084 00000000 rw- .bss
    c00b2f28 c00b2f28 000001e4 00000000 rw- .neardata
    c00b3110 c00b3110 00000050 00000000 r--
    c00b3110 c00b3110 00000050 00000000 r-- .rodata
    c00b3160 c00b3160 00000120 00000000 rw-
    c00b3160 c00b3160 00000120 00000000 rw- .cio
    c00b3400 c00b3400 00001fa8 00001fa8 r-x
    c00b3400 c00b3400 00000200 00000200 r-x .vecs
    c00b3600 c00b3600 00001da8 00001da8 r-- .cinit

    systemHeap被分配到了L2ROM里面,可是L2ROM用户自己不是没法使用嘛,而且我的平台配置文件都是把程序数据堆栈都放到了DDR里面,但是systemHeap怎么跑到L2ROM里面去了呢?
  • 在cmd文件里没看到分配systemHeap,在cfg文件里分配systemHeap试试。
    Program.sectMap["systemHeap"] = "DDR2";
  • 感谢,systemHeap已经分配到DDR里面了
    systemHeap: load > DDR

    map文件中也有了相应的段,但是我单步调试malloc函数还是会调进exit.c,console提示ti.sysbios.gates.GateMutex: line 99: assertion failure: A_badContext: bad calling context. See GateMutex API doc for details.我的malloc函数是在串口中断的中断服务函数里面写的
    xdc.runtime.Error.raise: terminating execution

    systemHeap
    * 0 c0000000 00100000 UNINITIALIZED
    c0000000 00100000 app_pe674.oe674 (systemHeap)
  • 请问malloc函数放在中断外会有这个问题吗?