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.

TMS320F28379D: Code hang in ti_sysbios_hal_Hwi_initStack()

Part Number: TMS320F28379D
Other Parts Discussed in Thread: SYSBIOS, C2000WARE

Hi,

As the subject indicate, the code is hanging in the function ti_sysbios_hal_Hwi_initStack specifically in:
while (--curStack > ((UArg)(&curStack) + 1)) {
*((volatile UInt8 *)curStack) = 0xbebe;
}

This is happening because the stkInfo is cero as can be seen in the screenshot. Where the Hwi stack base, peak and size is configured?

  • Do you mind sharing a bit more info? Where the stack located in your cmd file? How large is it supposed to be? Have you configured the BIOS Boot module? With what settings?

    Do note that we aren't supporting SYS/BIOS anymore, so if this is a new project and you're able to consider another RTOS, we recommend using FreeRTOS instead (port can be found in the 'kernel' directory of C2000Ware).

    Whitney

  • Hi Whitney,

    Adding a bit more context, this project is about porting the code from an 28335 to a 28379 uC.

    The stack config is as follow:

    app.cfg

    var ti_catalog_c2800_initF2837x_Boot = xdc.useModule('ti.catalog.c2800.initF2837x.Boot');
    BIOS.heapSize = 0x3700;
    Program.stack = 0x1000;
    Load.hwiEnabled = true;
    Task.defaultStackSize = 768;
    BIOS.heapSection = ".theheap";
    ti_catalog_c2800_initF2837x_Boot.runSegment = "RAMD0 PAGE = 0";
    mem.cmd
    RAMD0             : origin = 0x00B000, length = 0x000800
    RAMGS01234567_DMA    : origin = 0x00C000, length = 0x008000
    sec0.cmd
    .stack:             > RAMGS01234567_DMA      PAGE = 0
    sec1.cmd
    .theheap            : > RAMGS01234567_DMA     PAGE = 0
    .cio                : > RAMGS01234567_DMA     PAGE = 0

    Could you point to which specific configuration I should look for the BIOS Boot module?
  • Thanks for the additional info. One concern I'm seeing right now is that the stack pointer is only 16-bits, but the GS4RAM and above need 5 bits of address. If you want to put the stack in GSxRAM, you need to make sure it's in one of the lower ones. Same thing with the Task stacks.

    Could you point to which specific configuration I should look for the BIOS Boot module?

    I see runSegment in your config above. Is everything else set to the default setting?

    Whitney

  • Hi Whitney,
    Before the configuration I posted above, I was using the lower part, but I had the same issue:


    Program.stack = 1536;
    Task.defaultStackSize = 512;
    mem.cmd
    RAMD0             : origin = 0x00B000, length = 0x000800
    RAMGS0123_DMA    : origin = 0x00C000, length = 0x004000
    sec0.cmd
    .stack:             > RAMGS0123_DMA          PAGE = 0
    sec1.cmd
    .theheap            : > RAMGS0123_DMA         PAGE = 0
    .cio                : > RAMGS0123_DMA         PAGE = 0
    Regarding runSegment, please see the complete code:
    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 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 Swi = xdc.useModule('ti.sysbios.knl.Swi');
    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 Load = xdc.useModule('ti.sysbios.utils.Load');
    var ti_sysbios_hal_Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
    var Event = xdc.useModule('ti.sysbios.knl.Event');
    var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');
    var Timer = xdc.useModule('ti.sysbios.hal.Timer');
    var Timestamp = xdc.useModule('xdc.runtime.Timestamp');
    var Boot = xdc.useModule('ti.catalog.c2800.init.Boot');
    var TimestampProvider = xdc.useModule('ti.sysbios.family.c28.TimestampProvider');
    var ti_sysbios_family_c28_Timer = xdc.useModule('ti.sysbios.family.c28.Timer');
    var Startup = xdc.useModule('xdc.runtime.Startup');
    var ti_catalog_c2800_initF2837x_Boot = xdc.useModule('ti.catalog.c2800.initF2837x.Boot');
    
    
    /*
     * Program.argSize sets the size of the .args section.
     * The examples don't use command line args so argSize is set to 0.
     */
    Program.argSize = 0x0;
    
    /*
     * 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 = 0x3700;
    
    /*
     * Build a custom SYS/BIOS library from sources.
     */
    BIOS.libType = BIOS.LibType_Custom;
    
    /* System stack size (used by ISRs and Swis) */
    Program.stack = 0x1000;
    
    /* Circular buffer size for System_printf() */
    SysMin.bufSize = 0x200;
    
    System.SupportProxy = SysMin;
    
    Load.swiEnabled = true;
    Load.hwiEnabled = true;
    BIOS.cpuFreq.lo = 2500000;
    Boot.disableWatchdog = false;
    Boot.configurePll = false;
    Boot.bootFromFlash = false;
    BIOS.customCCOpts = "-v28 -DLARGE_MODEL=1 -ml --float_support=fpu32 -q -mo  --program_level_compile -o3 -g --optimize_with_debug";
    BIOS.heapTrackEnabled = false;
    var UIAMetaData = xdc.useModule('ti.uia.runtime.UIAMetaData');
    UIAMetaData.timestampFreq.lo = 150000000;
    TimestampProvider.useClockTimer = false;
    
    Load.updateInIdle = true;
    Load.windowInMs = 500;
    
    BIOS.logsEnabled = false;
    
    
    Task.defaultStackSize = 768;
    Clock.tickPeriod = 1000;
    Clock.timerId = -1;
    Clock.swiPriority = 2;
    Semaphore.supportsEvents = true;
    
    BIOS.runtimeCreatesEnabled = true;
    BIOS.swiEnabled = true;
    BIOS.assertsEnabled = false;
    BIOS.heapSection = ".theheap";
    //Startup.resetFxn = "&PreBootInitExternalSram";
    ti_catalog_c2800_initF2837x_Boot.runSegment = "RAMD0 PAGE = 0";
    
  • Hey  do you think the runSegment config is correct?. I am running out of ideas, so any hint will be appreciated Slight smile

  • Unfortunately, there are no obvious issues jumping out at me. Are you able to put a breakpoint at the call to Hwi_getStackInfo() and see what's going wrong with the initialization of stkInfo?

    Whitney

  • Hi , I can set the breakpoint but it does not stop there.

  • Are you able to try turning off optimization in the SYSBIOS build to make debugging a little easier? Unfortunately I don't really have any ideas of what a likely cause is here, so I think it's going to need to be debugged to find out what's going wrong--are variables being initailized incorrectly, are they being linked to the wrong location, etc...

    Whitney

  • After adding the following line, the hwistacksize is initialized correctly. Does it make sense ?

    .data               : > M01SARAM     PAGE = 0
  • Good to know you found a solution. Off the top of my head I'm not sure why that worked. Maybe the linker was placing .data at some inaccessible location. You could try comparing .map files before and after the change to try to figure out what was going wrong before.

    Whitney