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.

Project for a TM4C1294NCPDT created in CCS 6.1 using GNU compiler doesn't run to main

Other Parts Discussed in Thread: EK-TM4C1294XL, TM4C1294NCPDT

The attached project TM4C129_GCC_string.zip was created in CCS 6.1.0.00104 for running on an EK-TM4C1294XL, compiled with the GNU v4.8.4 compiler. When a debugging session is started in CCS main isn't reached - and when the debugger is paused it shows that the FaultISR has been entered.

On investigation:

1) After failing to reach main after starting a CCS debug session, if unplug and reconnect the Launchpad the program successfully starts running as indicated by flashing a LED. This indicates the program has been written into flash correctly.

2) If the debug project properties are changed so doesn't attempt to run to main, after starting a debug session the debugger shows the initial program counter as 0x208 which is the start of the __do_global_dtors_aux function. This is not the correct initial program counter, and attempting to single step from this point causes entry to the FaultISR.

After entry to the FaultISR if a "System Reset" is selected then the program counter is set to the 0x354 at the start of the ResetISR function which is the correct initial program counter. Single stepping from this point and main() is entered and the program runs successfully.

Therefore, the problem appears to be that when a debug session is started CCS sets the initial program counter to the wrong value of 0x208. The address 0x208 happens to the start of the .text segment.

3) The debug_server.log file in the attached zip file of the project contains the Debug Server log from starting a debug session which should have run to main.

The following entry from the Debug Server log shows CCS setting the Program Counter to the incorrect value of 0x208, but is not obvious why:

0xC20A7B70 10493 3 CORTEX_M4_0 GTI C: GTI_WRITEREG( 0x0xab899268, 0x0000020F, *0x0xc20a6528 = 0x00000208 )
0xC20A7B70 10494 3 CORTEX_M4_0 STELLARIS C: StellarisDriver::DebugWriteCoreRegister( 15, 0x208 )
0xC20A7B70 10500 3 CORTEX_M4_0 STELLARIS R: StellarisDriver::DebugWriteCoreRegister( 15, 0x208 ) = 0
0xC20A7B70 10500 3 CORTEX_M4_0 GTI R: GTI_WRITEREG( 0x0xab899268, 0x0000020F, *0x0xc20a6528 = 0x00000208 ) = 0x00000000
[Core Register 15 is the Program Counter]

  • The same problem occurs with CCS 6.1.0.00104 in Windows 7 64-bit and CentOS 6.6 64-bit.

  • Chester Gillon said:
    Therefore, the problem appears to be that when a debug session is started CCS sets the initial program counter to the wrong value of 0x208. The address 0x208 happens to the start of the .text segment.

    Chester,

    Your assessment appears to be correct. I did some tests and found that there is a difference between GCC versions 4.8.4 (the one included with CCS 6.1) and GCC 4.7.4 (included with CCS 6.0.1).

    Here are my observations and analysis:

    1) With GCC 4.7.4, your project compiles and debugs fine - stops at main when debug sessions is launched.
    2) With GCC 4.8.4, it does not halt at main, coming up running and when halted is in FaultISR.

    Looking at the linker map files for both builds and dumping the .out files to look at the symbols, I found that the symbol "start" is defined for the GCC 4.7.4 build but not for 4.8.4 build.

    The .map file for 4.7.4 has the symbol start (in addition to _start and _mainCRTStartup) defined at 0x25c. This is what the linker entry point is set to in this version. In the .map file for 4.8.4, the symbol start is not defined (although the other two are) and the linker entry point defaults to the starting address of the .text section, in this case 0x208. I can't explain why that symbol is no longer defined, however, according to the GCC Linker manual (same content as in this page), the entry point then defaulting to the start of .text is expected.

    Using that page as a reference there are a couple of ways to resolve this:

    - Specify the entry point under -e option for the linker (setting this to _start or ResetISR works) or
    - Add the ENTRY(ResetISR) command in the linker script

    Hope this helps!

  • AartiG said:
    - Add the ENTRY(ResetISR) command in the linker script

    Thanks for the investigation and explanation of the problem.

    I confirm that adding "ENTRY(ResetISR)" to the linker script fixes the problem, in that when starting a debug session the program now reaches main.

    However, since the tm4c1294ncpdt.lds which was added when the project was created by CCS 6.1 was missing the entry point can you raise a request to get the default GCC linker scripts used by CCS changed so that they define the entry point in the associated *_startup_ccs_gcc.c source files?