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.

Errors in CCSv6 created project for a TM4C129 project using the GNU v4.7.4 compiler

Other Parts Discussed in Thread: TM4C1294NCPDT

Using CCS 6.0.1.00040 when a new project was created for a TM4C1294NCPDT using the GNU v4.7.4 compiler, noticed there were errors in the generated project which caused run time failures. E.g. using a project containing the following code:

/*
 * main.c
 */

#include <string.h>

char test_string[20] = "Hello World\n";

int main(void) {
	volatile size_t len = strlen(test_string);
	return 0;
}

The first problem is that the data segment has not been initialized correctly. E.g. the text in the test_string appears offset by 12 bytes:

The incorrect data segment initialization is caused by the tm4c1294ncpdt_startup_ccs_gcc.c added to the project by CCS. The error is that the ResetISR() function uses __etext as the source of the data segment initialization, whereas it should be using __data_load__. i.e. change the  tm4c1294ncpdt_startup_ccs_gcc.c to contain:

//*****************************************************************************
//
// The following are constructs created by the linker, indicating where the
// the "data" and "bss" segments reside in memory.  The initializers for the
// for the "data" segment resides immediately following the "text" segment.
//
//*****************************************************************************
extern uint32_t __data_load__;
extern uint32_t __data_start__;
extern uint32_t __data_end__;
extern uint32_t __bss_start__;
extern uint32_t __bss_end__;

//*****************************************************************************
//
// This is the code that gets called when the processor first starts execution
// following a reset event.  Only the absolutely necessary set is performed,
// after which the application supplied entry() routine is called.  Any fancy
// actions (such as making decisions based on the reset cause register, and
// resetting the bits in that register) are left solely in the hands of the
// application.
//
//*****************************************************************************
void
ResetISR(void)
{
    uint32_t *pui32Src, *pui32Dest;

    //
    // Copy the data segment initializers from flash to SRAM.
    //
    pui32Src = &__data_load__;
    for(pui32Dest = &__data_start__; pui32Dest < &__data_end__; )
    {
        *pui32Dest++ = *pui32Src++;
    }

The second problem is that the strlen function was crashing the processor - causing the FaultISR() to be entered. This is because the strlen function was being linked from the c:/ti_ccs6_0/ccsv6/tools/compiler/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib\libc.a library. That library has been compiled for ARM mode, whereas the TM4C1294NCPDT device only supports Thumb mode.

The incorrect library being linked is caused by the GNU compiler -march option being left blank when the project was created by CCS. -march should be set to "armv7e-m" for a TM4C1294NCPDT to cause the GNU compiler to select the correct run time library.

With these two changes the above example then worked when compiled with the GNU v4.7.4 compiler

  • Chester Gillon said:
    The incorrect library being linked is caused by the GNU compiler -march option being left blank when the project was created by CCS. -march should be set to "armv7e-m" for a TM4C1294NCPDT to cause the GNU compiler to select the correct run time library.

    I have just seen http://processors.wiki.ti.com/index.php/Using_GCC_with_Tiva_in_CCSv6#Working_with_GCC_libraries, which notes that this is planned to be addressed in future CCS releases. 

  • Chester Gillon said:
    The incorrect data segment initialization is caused by the tm4c1294ncpdt_startup_ccs_gcc.c added to the project by CCS. The error is that the ResetISR() function uses __etext as the source of the data segment initialization, whereas it should be using __data_load__.

    Thank you for reporting this issue. I agree with your assessment and I will pass this along to the folks responsible for the startup files. Hopefully we can get this addressed for the next release of CCS.

  • AartiG said:
    I agree with your assessment and I will pass this along to the folks responsible for the startup files. Hopefully we can get this addressed for the next release of CCS.

    Have just checked with CCS 6.1.0.00104, and confirm that CCS 6.1.0.00104 has fixed both reported problems.