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.

CC1310的RTOS中如何配置heap,以便使用malloc()和free()

Other Parts Discussed in Thread: SYSBIOS

在.cfg中如何配置,以便使用malloc()和free();采用哪种方式

第一种:

var BIOS = xdc.useModule('ti.sysbios.BIOS');

BIOS.heapSize = 4096;
BIOS.heapSection = "systemHeap";


/* Create a heap using HeapBuf */
var heapBufParams = new HeapBuf.Params;
heapBufParams.blockSize = 128;
heapBufParams.numBlocks = 2;
heapBufParams.align = 8;
heapBufParams.sectionName = "myHeap";
Program.global.myHeap = HeapBuf.create(heapBufParams);
Memory.defaultHeapInstance = Program.global.myHeap;

第二种:

var Memory = xdc.useModule('xdc.runtime.Memory');
/*
* The Memory module itself simply provides a common interface for any
* variety of system and application specific memory management policies
* implemented by the IHeap modules(Ex. HeapMem, HeapBuf).
*/

/*
* Use HeapMem primary heap instance to use linker-defined memory region
*/
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
HeapMem.primaryHeapBaseAddr = "&__primary_heap_start__";
HeapMem.primaryHeapEndAddr = "&__primary_heap_end__";

var heapMemParams = new HeapMem.Params();
heapMemParams.usePrimaryHeap = true;
heapMemParams.size = 4096;
heapMemParams.align = 8;
heapMemParams.minBlockAlign = 16;
heapMemParams.instance.name = "heap0";
Program.global.heap0 = HeapMem.create(heapMemParams);

Memory.defaultHeapInstance = Program.global.heap0;

x 出现错误。请重试或与管理员联系。