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.

RTOS/TMS320F28069: RTOS/TMS320F28069:

Part Number: TMS320F28069
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hi,

I am using Sys Bios 6.45.1.29 and Code Composer Studio, Version: 7.0.0.00043 on TMS320F28069. 

I am using the following .cfg file.

I want to increase stack size and heap size. I have sufficient memory e.g. I use just 25% of RAM as shown in Memory Allocation. But if I increase stack size from 256 to 512, strangely the stack overflows.

What should I check. I will highly appreciate any directions, links etc. 

Thanks 

Jawwad

---------------------------------------------------------------------

var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Diags = xdc.useModule('xdc.runtime.Diags');
var Error = xdc.useModule('xdc.runtime.Error');
var Log = xdc.useModule('xdc.runtime.Log');
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
var Main = xdc.useModule('xdc.runtime.Main');
var SysMin = xdc.useModule('xdc.runtime.SysMin');
var System = xdc.useModule('xdc.runtime.System');
var Text = xdc.useModule('xdc.runtime.Text');

var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');

var Hwi = xdc.useModule('ti.sysbios.family.c28.Hwi');
var Boot = xdc.useModule('ti.catalog.c2800.init.Boot');

/*
* Uncomment this line to globally disable Asserts.
* All modules inherit the default from the 'Defaults' module. You
* can override these defaults on a per-module basis using Module.common$.
* Disabling Asserts will save code space and improve runtime performance.
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
*/

/*
* Uncomment this line to keep module names from being loaded on the target.
* The module name strings are placed in the .const section. Setting this
* parameter to false will save space in the .const section. Error and
* Assert messages will contain an "unknown module" prefix instead
* of the actual module name.
Defaults.common$.namedModule = false;
*/

/*
* Minimize exit handler array in System. The System module includes
* an array of functions that are registered with System_atexit() to be
* called by System_exit().
*/
System.maxAtexitHandlers = 4;

/*
* Uncomment this line to disable the Error print function.
* We lose error information when this is disabled since the errors are
* not printed. Disabling the raiseHook will save some code space if
* your app is not using System_printf() since the Error_print() function
* calls System_printf().
Error.raiseHook = null;
*/

/*
* Uncomment this line to keep Error, Assert, and Log strings from being
* loaded on the target. These strings are placed in the .const section.
* Setting this parameter to false will save space in the .const section.
* Error, Assert and Log message will print raw ids and args instead of
* a formatted message.
Text.isLoaded = false;
*/

/*
* Uncomment this line to disable the output of characters by SysMin
* when the program exits. SysMin writes characters to a circular buffer.
* This buffer can be viewed using the SysMin Output view in ROV.
SysMin.flushAtExit = false;
*/

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

/*
* Build a custom SYS/BIOS library from sources.
*/
BIOS.libType = BIOS.LibType_Custom;

/* System stack size (used by ISRs and Swis) */
Program.stack = 0x400;

/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x400;

/*
* Create and install logger for the whole system
*/
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 32;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;

System.SupportProxy = SysMin;

Task.defaultStackSize = 256;
Boot.bootFromFlash = true;
Boot.configurePll = false;
BIOS.cpuFreq.lo = 90000000;
Hwi.dispatcherAutoNestingSupport = false;

  • Are you using Tools->ROV to see the stack overflow? Can you raise the stack to something really big (e.g. 2048 or 4096) and run the application again? Then look at ROV (note you have to halt the target for ROV to work). What's the peak (ROV->Tasks->Detailed)? What about the Hwi stack (ROV->Hwi->Module)? Note: you need to enable the stack initialization to get this feature. It's on by default though, so based on the the .cfg you pasted, it is on.

    Are you providing the stacks for the tasks? If so, your heap might be too small.

    Note: Task.defaultStackSize = 256; is only used if you don't specify a size in the Task_create's Task_Params. Can you paste the code you use to create the task?

    Todd
  • Hi,

    Thank you so much for the detailed reply. Much appreciate. 

    Currently I use 3 Tasks. This number will go to about a dozen. I chose to create these tasks during run time instead of static creation using .cfg editor of ccs.

    I check ROV and Memory usage continuously. The max stack used by any task is about 188 bytes. Right now  I have no stack over flow. The software runs fine. But if I increase Task.defaultStackSize = 256 to Task.defaultStackSize = 512 in the cfg file, the stack overflow error starts to occur.

    I will test the stack overflow in tasks by doing some recursive calls. But I am also not clear about how the stack is allocated in a task. Does it come from Heap area. etc. Can I control the max limit of it. Can I put per task stack max limit etc. are some questions that come to my mind.

    Really appreciate your help

    Regards

    ----------------------------------------------------------------------------------------------------------------------------

    //Task creation 

    HVACSem = Semaphore_create(1, NULL, NULL);
    sem1 = Semaphore_create(1, NULL, NULL);
    ConsoleSemi = Semaphore_create(1, NULL, NULL);

    //The tasks are triggered by a timer

    Clock_Params_init(&clkParams);
    clkParams.period = 40; // every 4 Clock ticks
    clkParams.startFlag = TRUE; // start immediately
    Clock_create(clk0Fxn, 2, &clkParams, NULL);

    Task_Params_init(&taskParams);
    taskParams.priority = 1;
    tsk1 = Task_create (task1, &taskParams, NULL);

    Task_Params_init(&taskParams);
    taskParams.priority = 2;
    HVACTaskH = Task_create (HVACTask, &taskParams, NULL);

    Task_Params_init(&taskParams);
    taskParams.priority = 3;
    CTaskH = Task_create (CTask, &taskParams, NULL);

    BIOS_start(); /* does not return */

  • There are two parameters you are not setting in the taskParams variable
    taskParams.stack
    taskParams.stackSize

    Since you are not setting the stackSize parameter, it will get the default (namely the Task.defaultStackSize value). Since you are not setting the stack parameter, the Task module will allocate a stack for you. It comes from the default system heap (unless you set Task.defaultStackHeap. Then it will be allocated from that heap).

    It sounds like if you increase the stack size, you are getting an memory allocation error...not a stack overflow. For memory allocation errors, you need to increase BIOS.heapSize or reduce the amount of allocation you are doing.
  • Hi,

    Thank you so much. Now its quite clear. The default stack and heap relationship is quite clear.  I will set taskParams.stack and taskParams.stackSize to implicitly set the stack, look for stack overflow in ROV and then adjust the stack of corresponding task. Sounds very powerful.

    Let me try that over the weekend.

    Regards

    Jawwad

  • Dear
    ToddMullanix
    All tested and works fine.

    Thank you so much for the precise answer. And thank you TI, a trusted partner in our products.

    Regards
    Jawwad