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.

CCS/TMS320F28335: startup hangs when Hwi_getStackInfo returns stkInfo->hwiStackBase = NULL

Part Number: TMS320F28335
Other Parts Discussed in Thread: SYSBIOS

Tool/software: Code Composer Studio

I have a project that traditionally compiled in working order, where Hwi_getStackInfo returns stkInfo->hwiStackBase = 0x400 (_stack). 

Now, it usually compiles where Hwi_getStackInfo returns stkInfo->hwiStackBase = 0x00 and hangs in startup under xdc_runtime_Startup_exec__F. I haven't been able to figure out why it only sometimes compiles correctly now. I've tried cleaning out the output directory before compiling. Do you have some clues of what to try? _stack shows up where it should in the .map file. One thing that might be relevant is that .ebss points to external memory.

  • Hello,

    I will bring this thread to the attention of the TI-RTOS experts. Note that due to the local holiday, responses may be delayed.

    Thanks

    ki

  • Hi David,

    Can you attach your .cfg file? Please attach and not copy/paste to keep the thread readable.

    Todd

    [12/2 Update: Marking as TI Thinks Resolved due to no activity.]

  • 3443.app.cfg Sorry about the delay in response, I just returned from the holiday.

  • stkInfo->hwiStackBase is set as follows:

        stkInfo->hwiStackBase = (Ptr)(Hwi_module->isrStackBase);

    This is how Hwi_module->isrStackBase gets set in ti/sysbios/family/c28/Hwi.xs:

    /*
    * ROM
    * These members of the module state are added for ROM. They are tied to
    * their respective symbol name because the symbols will not be defined
    * at the time the ROM assembly is made.
    */
    if (Build.buildROM == false) {
        if (Program.build.target.$name.match(/elf/)) {
            mod.isrStackSize = $externPtr('__TI_STACK_SIZE');
            mod.isrStackBase = $externPtr("__stack");
        }
       else {
            mod.isrStackSize = $externPtr("_STACK_SIZE");
            mod.isrStackBase = $externPtr("_stack");
        }
    }
    else {
        /* If building ROM, then __stack and __STACK_SIZE is undefined */
        mod.isrStackBase = null;
        mod.isrStackSize = 0;
    }

    I can see from your .cfg file that you're not setting Build.buildROM to 'true', so I wouldn't expect the last "else" clause to be taking effect.

    Are you building for ELF or COFF?

    You say that it sometimes works but you don't know why.  Given the same input files (source code and linker command files) it will build the same way every time, so identifying why it's different sometimes would be key.

    Regards,

    - Rob

  • The problem appears to be that a bunch of initialized xcd variables are ending up in an uninitialized external memory segment.

    The third function in the list called by xdc_runtime_starup_exec__F is:

    ti_sysbios_hal_Hwi_initStack() which is calling Hwi_getStackInfo(), which is accessing ti_sysbios_family_c28_Hwi_Module__state__V.

    ti_sysbios_family_c28_Hwi_Module__state__V is initialized in the source file app_p28FP.c, but the map file shows it is located in external .ebss (uninitialized) memory, and at this stage has not been initialized. 

    As a semi-cargo-cult experiment, I tried setting the linker file with the following entry for the relevant external section (containing ti_sysbios_family_c28_Hwi_Module__state__V ) :

    ZONE7DATA : LOAD = FLASHF PAGE = 0,
    RUN = ZONE7B PAGE = 1,
    LOAD_START(extLoadStart),
    //LOAD_SIZE(extLoadSize),
    LOAD_END(extLoadEnd),
    RUN_START(extRunStart)

    and adding the line :

    memcpy(&extRunStart, &extLoadStart, &extLoadEnd - &extLoadStart); 

    in knl_to_ram() (the first function in the list called by xdc_runtime_starup_exec__F).

    But CCS studio ended up complaining this was an UNINITIALIZED segment and the extLoadStart... variables weren't defined.

    How do I initialize the app_p28FP.o28FP external .ebss variables? 

  • David Taylor8 said:
    ti_sysbios_family_c28_Hwi_Module__state__V is initialized in the source file app_p28FP.c, but the map file shows it is located in external .ebss (uninitialized) memory, and at this stage has not been initialized.

    Variables in .ebss get initialized by .cinit records at runtime.  This happens before xdc_runtime_Startup_exec__E is run.

    I just tried a COFF C28 example which worked, and it has this code at the entry point:

    c_int00():
    081766: 3B30 SETC INTM|DBGM
    081767: 2BA9 MOV @AL, #0
    081768: 23A9 MOV IER, @AL
    081769: 28AD0122 MOV @SP, #0x0122
    08176b: FF69 SPM #0
    08176c: 561F SETC OBJMODE
    08176d: 5616 CLRC AMODE
    08176e: 561A SETC M0M1MAP
    08176f: E6100200 SETFLG RNDF32=1
    081771: 2940 CLRC PAGE0
    081772: 761F0000 MOVW DP, #0x0
    081774: 2902 CLRC OVM
    081775: 761B ASP
    081776: 7648294C LCR _system_pre_init
    081778: 5200 CMPB AL, #0x0
    081779: 6152 SB DONE_INIT, EQ
    08177a: 7622 EALLOW
    08177b: 28A90001 MOV @AL, #0x0001
    08177d: 28A80000 MOV @AH, #0x0000
    08177f: 0900 ADDB ACC, #0
    081780: 6103 SB noreset, EQ
    081781: 764827A6 LCR ti_catalog_c2800_initF2837x_Boot_init
    noreset:
    081783: 28A946BF MOV @AL, #0x46bf
    081785: 28A80008 MOV @AH, #0x0008
    081787: 0901 ADDB ACC, #1
    081788: 611B SB DO_BINIT, EQ
    081789: 76C846BF MOVL XAR7, #0x0846bf
    08178b: 2904 CLRC TC
    08178c: 6F0F SB START, UNC
    LOOP:

    .cinit record processing starts at the "noreset" label.  Then, after that runs, there's this code that calls xdc_runtime_Startup_exec__E:

    DO_PINIT:
    0817ad: 761A EDIS
    0817ae: 28A91EBF MOV @AL, #0x1ebf
    0817b0: 28A80008 MOV @AH, #0x0008
    0817b2: 0900 ADDB ACC, #0
    0817b3: 6103 SB noexec, EQ
    0817b4: 76481EBF LCR xdc_runtime_Startup_exec__E

    Do you have similar code at your app's entry point?

    My test has Hwi_Module__state__V in .ebss as well, and I see it's not initialized when I load the program and is then initialized by the time I get to xdc_runtime_Startup_exec__E (which calls Hwi_initStack).

    Regards,

    - Rob

  • That actually helped a lot. I've solved the issue by initializing the external RAM in the "user reset function", which appears to be called before the variables are initialized.