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/TMS570LS3137: sys_startup.c resets in _c_int00 in /* initalise the C global variables */ section

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

We have a custom board based on the TMS570LS3 HDK. We are using the code based on TMS570LS31x_HDK_Connectivity_Test.zip.

The code compiled out of the box and we started making changes before we received the actual board to get ahead.

We now have the board and started debugging the code with an XDS200 from spectrum digital. It programs and runs but gets stuck in the reset vector in sys_startup.c.

When execution gets to the  /* initalise the C global variables */ section it loops through twice and on the second pass at the (*handler)((const unsigned char *)loadAdr, runAdr) line it resets and enters the same vector and gets stuck in a loop.

    /* initalise the C global variables */
    if (&__TI_Handler_Table_Base < &__TI_Handler_Table_Limit)
    {
        unsigned char **tablePtr   = (unsigned char **)&__TI_CINIT_Base;
        unsigned char **tableLimit = (unsigned char **)&__TI_CINIT_Limit;

        while (tablePtr < tableLimit)
        {
            unsigned char *loadAdr = *tablePtr++;
            unsigned char *runAdr  = *tablePtr++;
            unsigned char  idx     = *loadAdr++;
            handler_fptr   handler = (handler_fptr)(&__TI_Handler_Table_Base)[idx];

            (*handler)((const unsigned char *)loadAdr, runAdr);
        }
    }

    /* initalise contructors */
    if (__TI_PINIT_Base < __TI_PINIT_Limit)
    {
        void (**p0)() = (void *)__TI_PINIT_Base;

        while ((unsigned)p0 < __TI_PINIT_Limit)
        {
            void (*p)() = *p0++;
            p();
        }
    }

We can get around the issue by not intiializing the C variables or constructors by putting #if 0 and #endif around the code above, but it is problematic where there is initialized data.

For example we are also using the lwIP port HALCoGen EMAC Driver with lwIP Demonstration and it has initialized string variables that do not come out. We changed them to const to force them into flash, but there must be other issues where we do not have initialized data.

Any ideas why this example code out of the box fails to initialize the C variables?

  • Hello Mark,

    What changes did you make to the example code? It looks like this is an issue related to compiler.
  • We got the example code for the development kit and just added some IO setup for starters. The initialization code caused a reset before we even reached the main function. We had to skip the initialization code in order test the code, but any initialized data could not be used. Ultimately, we started over by generating a new project using HALCoGen and tailored it to our board. We generated code and it worked fine. Very nice tool.