Something is wrong with the design intent of my program. I can’t seem to make the stacks and heaps play together correctly.
Here is my program layout:
I am running the same executable on 5 cores of a C6678 DSP EVM. This executable initializes the network stack based on the helloWorldUDP example. It initializes the SRIO based on the DIOIsrExample. This is done by Core 0 only. Core 0 initializes both comms then starts the network task. From the network task (NetworkOpen())it starts its own worker task.
Cores 1 to 4 do not do any initialization but just start the worker task.
Right now, in the worker task, Core 0 only will wait for an SRIO doorbell to determine that there is new data available. Depending on what doorbell it is it sets a flag in the shared mem for the other cores. The other cores wait for the flag to be set and then act on the data by manipulating it to be in a certain form with memcpy.
Before I integrated the network example, the program worked fine. However it was running from MCMSRAM. After integration of the network example, changing interrupts and event managers, ensure that the qmss and cppi initializations weren’t duplicated or destroying each, combining the memory maps etc. the program now runs from DDR3.
Now when I run the application, Cores 1 to 4 almost always have a stack overflow error.
[C66xx_3] ti.sysbios.knl.Task: line 330: E_stackOverflow: Task 0x80000408 stack overflow.
[C66xx_3] xdc.runtime.Error.raise: terminating execution
[C66xx_1] ti.sysbios.knl.Task: line 330: E_stackOverflow: Task 0x80000408 stack overflow.
[C66xx_2] ti.sysbios.knl.Task: line 330: E_stackOverflow: Task 0x80000408 stack overflow.
[C66xx_4] ti.sysbios.knl.Task: line 330: E_stackOverflow: Task 0x80000408 stack overflow.
[C66xx_1] xdc.runtime.Error.raise: terminating execution
[C66xx_2] xdc.runtime.Error.raise: terminating execution
[C66xx_4] xdc.runtime.Error.raise: terminating execution
So I increased this parameter in my cfg to be very large.
Task.defaultStackSize = 64*1024;//4096;
I still get an overflow.
Then I use the ROV tool, it tells me that my tasks (which were created dynamically and not statically in the cfg) are using the system heap as their stack and they indeed are using all of this very large default stack size.
The tool also says that the network task is using all of its stack too.
Then I am trying to think what I must be missing. The default system heap is also already quite large. But I made it larger to test.
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var heapMemParams = new HeapMem.Params();
heapMemParams.size = 0x300000+64*1024;
heapMemParams.sectionName = "systemHeap";
Program.global.heap0 = HeapMem.create(heapMemParams);
It does not work either, still there a stack overflow.
I try another idea and create a separate heap for these tasks and attempt to assign it in the taskparams like so:
cfg
Program.sectMap[".myHeapSection"] = "L2SRAM";
var heapMemParams = new HeapMem.Params;
heapMemParams.size = 5*1024;//0x100;
heapMemParams.sectionName = ".myHeapSection";
Program.global.myHeap0 = HeapMem.create(heapMemParams);
application
taskParams.stackHeap = HeapMem_Handle_to_xdc_runtime_IHeap(myHeap0);
Task_Params_init(&taskParams);
Task_create(dioExampleTask, &taskParams, NULL);
Still I fail. In this case, it never gets assigned to this heap and still goes to the system heap.
I feel like I must have a fundamental design flaw here and I can’t figure out what it is.
I would appreciate some advice!
Thanks,
Brandy
Here is my .cfg file:
/*
* Copyright 2009 by Texas Instruments Incorporated.
*
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*
*/
/* THIS FILE WAS GENERATED BY ti.sysbios.genx */
/*
* ======== loopbackDioIsr.cfg ========
*
*/
environment['xdc.cfg.check.fatal'] = 'false';
/* Load and use the various BIOS modules. */
var Memory = xdc.useModule('xdc.runtime.Memory');
var BIOS = xdc.useModule('ti.sysbios.BIOS');
var HWI = xdc.useModule('ti.sysbios.family.c64p.Hwi');
var CPINTC = xdc.useModule('ti.sysbios.family.c66.tci66xx.CpIntc');
var ECM = xdc.useModule('ti.sysbios.family.c64p.EventCombiner');
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
var SEM = xdc.useModule('ti.sysbios.knl.Semaphore');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
var Log = xdc.useModule('xdc.runtime.Log');
var Diags = xdc.useModule('xdc.runtime.Diags');
/* Load and use the CSL, CPPI, QMSS and SRIO packages */
var cslSettings = xdc.useModule ('ti.csl.Settings');
var Timestamp = xdc.useModule('xdc.runtime.Timestamp');
var Cppi = xdc.loadPackage('ti.drv.cppi');
var Qmss = xdc.loadPackage('ti.drv.qmss');
var Srio = xdc.loadPackage('ti.drv.srio');
/* Load the PA package */
var Pa = xdc.useModule('ti.drv.pa.Settings');
/* Load the Platform/NDK Transport packages */
var PlatformLib = xdc.loadPackage('ti.platform.evmc6678l');
var NdkTransport = xdc.loadPackage('ti.transport.ndk');
/*
** Use this load to configure NDK 2.2 and above using RTSC. In previous versions of
** the NDK RTSC configuration was not supported and you should comment this out.
*/
var Global = xdc.useModule('ti.ndk.config.Global');
/*
** This allows the heart beat (poll function) to be created but does not generate the stack threads
**
** Look in the cdoc (help files) to see what CfgAddEntry items can be configured. We tell it NOT
** to create any stack threads (services) as we configure those ourselves in our Main Task
** thread hpdspuaStart.
*/
Global.enableCodeGeneration = false;
/* Load and use the System Package */
var System = xdc.useModule('xdc.runtime.System');
SysStd = xdc.useModule('xdc.runtime.SysStd');
System.SupportProxy = SysStd;
/*
* Enable Event Groups here and registering of ISR for specific GEM INTC is done
* using EventCombiner_dispatchPlug() and Hwi_eventMap() APIs
*/
ECM.eventGroupHwiNum[0] = 7;
ECM.eventGroupHwiNum[1] = 8;
ECM.eventGroupHwiNum[2] = 9;
ECM.eventGroupHwiNum[3] = 10;
/* Load and use the IPC packages */
var Ipc = xdc.useModule('ti.sdo.ipc.Ipc');
var Settings = xdc.module('ti.sdo.ipc.family.Settings');
var ListMP = xdc.useModule('ti.sdo.ipc.ListMP');
var GateMP = xdc.useModule('ti.sdo.ipc.GateMP');
var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
var HeapMemMP = xdc.useModule('ti.sdo.ipc.heaps.HeapMemMP');
var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
/* Configure the shared memory heap for shared memory allocations required by the
* CPPI and QMSS Libraries */
SharedRegion.translate = false;
var memmap = Program.cpu.memoryMap;
Startup = xdc.useModule('xdc.runtime.Startup');
Startup.firstFxns.$add('&myStartupFxn');
MultiProc.setConfig(null, ["CORE0", "CORE1", "CORE2", "CORE3", "CORE4"]);
/* Synchronize all processors (this will be done in Ipc_start) */
Ipc.procSync = Ipc.ProcSync_ALL;
/* To avoid wasting shared memory for Notify and MessageQ transports */
for (var i = 0; i < MultiProc.numProcessors; i++) {
Ipc.setEntryMeta({
remoteProcId: i,
setupNotify: false,
setupMessageQ: false,
});
}
/* Create a shared memory */
SharedRegion.setEntryMeta(0,
{ base: 0x0C010000,
len: 0x00100000,
ownerProcId: 0,
isValid: true,
name: "sharemem",
});
/* Create a default system heap using ti.bios.HeapMem. */
//var heapMemParams1 = new HeapMem.Params;
//heapMemParams1.size = 32768;
//heapMemParams1.sectionName = "systemHeap";
//Program.global.heap0 = HeapMem.create(heapMemParams1);
/* This is the default memory heap. */
//Memory.defaultHeapInstance = Program.global.heap0;
//Program.sectMap["systemHeap"] = Program.platform.stackMemory;
/*
** Create a Heap.
*/
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var heapMemParams = new HeapMem.Params();
heapMemParams.size = 0x300000+64*1024;
heapMemParams.sectionName = "systemHeap";
Program.global.heap0 = HeapMem.create(heapMemParams);
/* This is the default memory heap. */
Memory.defaultHeapInstance = Program.global.heap0;
Program.sectMap["sharedL2"] = "DDR3";
Program.sectMap["systemHeap"] = "DDR3";
Program.sectMap[".sysmem"] = "DDR3";
Program.sectMap[".args"] = "DDR3";
Program.sectMap[".cio"] = "L2SRAM";
Program.sectMap[".far"] = "DDR3";
Program.sectMap[".rodata"] = "DDR3";
Program.sectMap[".neardata"] = "DDR3";
Program.sectMap[".bss"] = "DDR3";
Program.sectMap[".cppi"] = "DDR3";
Program.sectMap[".init_array"] = "DDR3";
Program.sectMap[".qmss"] = "DDR3";
Program.sectMap[".cinit"] = "DDR3";
Program.sectMap[".const"] = "DDR3";
Program.sectMap[".text"] = "DDR3";
Program.sectMap[".code"] = "DDR3";
Program.sectMap[".switch"] = "DDR3";
Program.sectMap[".data"] = "DDR3";
Program.sectMap[".fardata"] = "DDR3";
Program.sectMap[".args"] = "DDR3";
Program.sectMap[".vecs"] = "DDR3";
Program.sectMap["platform_lib"] = "DDR3";
Program.sectMap[".far:taskStackSection"] = "L2SRAM";
Program.sectMap[".stack"] = "L2SRAM";
Program.sectMap[".nimu_eth_ll2"] = "L2SRAM";
Program.sectMap[".myLocalMemory"] = "L2SRAM";
Program.sectMap[".myHeapSection"] = "L2SRAM";
Program.sectMap[".resmgr_memregion"] = {loadSegment: "L2SRAM", loadAlign:128}; /* QMSS descriptors region */
Program.sectMap[".resmgr_handles"] = {loadSegment: "L2SRAM", loadAlign:16}; /* CPPI/QMSS/PA Handles */
Program.sectMap[".resmgr_pa"] = {loadSegment: "L2SRAM", loadAlign:8}; /* PA Memory */
Program.sectMap[".far:IMAGEDATA"] = {loadSegment: "L2SRAM", loadAlign: 8};
Program.sectMap[".far:NDK_OBJMEM"] = {loadSegment: "L2SRAM", loadAlign: 8};
Program.sectMap[".far:NDK_PACKETMEM"] = {loadSegment: "L2SRAM", loadAlign: 128};
//Program.sectMap[".srioSharedMem"] = new Program.SectionSpec();
Program.sectMap[".srioSharedMem"] = "MSMCSRAM";
//Program.sectMap[".qmss"] = new Program.SectionSpec();
//Program.sectMap[".qmss"] = "MSMCSRAM";
//Program.sectMap[".cppi"] = new Program.SectionSpec();
//Program.sectMap[".cppi"] = "MSMCSRAM";
Program.sectMap[".windowData"] = new Program.SectionSpec();
Program.sectMap[".windowData"].loadAddress = 0x80400000;
//Program.sectMap[".windowData"] = "DDR3";
//var heapMemParams = new HeapMem.Params;
//heapMemParams.size = 5*1024;//0x100;
//heapMemParams.sectionName = ".myHeapSection";
//Program.global.myHeap0 = HeapMem.create(heapMemParams);
/*
* @(#) ti.sysbios.genx; 2, 0, 0, 0,275; 4-29-2009 15:45:06; /db/vtree/library/trees/avala/avala-k25x/src/
*/
Task.defaultStackSize = 64*1024;//4096;
BIOS.heapSection = null;
Task.common$.namedInstance = true;
var task0Params = new Task.Params();
task0Params.instance.name = "task0";
Program.global.task0 = Task.create("&myTaskTest", task0Params);


