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.

Cannot debug imported Energia sketch

Other Parts Discussed in Thread: EK-TM4C1294XL, ENERGIA, TM4C1294NCPDT

I cannot for the life of me debug an Energia (0101E0012) sketch in CCS (6.0.1.00040), targeted for TM4C1294NCPDT (the EK-TM4C1294XL launchpad). The sketch appears to run fine from Energia, and when imported into CCS, it compiles and (appears to) flash just fine with no errors, but it doesn't run. A breakpoint set at the first line of setup() is never hit, and clicking “pause” while debugging prints the message “CORTEX_M4_0: Error: Debug Port error occurred.”, and the stack frame (I think? I'm kind of new to this) is at “_free_r() [C:\path\to\file.out] at 0xFFFFFFFE”. The memory map also shows such helpful information as

fffffffe:  ???? Memory map prevented reading 0xFFFFFFFE [code=0x20000]

100000000:   ???? Invalid target memory access

100000002:   ???? Invalid target memory access

100000004:   ???? Invalid target memory access

100000006:   ???? Invalid target memory access

100000008:   ???? Invalid target memory access

10000000a:   ???? Invalid target memory access

10000000c:   ???? Invalid target memory access

10000000e:   ???? Invalid target memory access

100000010:   ???? Invalid target memory access

 

Clicking “View Disassembly” makes the page in CCS sort of “flash” but otherwise does nothing.

I would greatly appreciate any help with this issue.

P.S. I’m running everything on Windows 7 Pro SP1 x64. The Stellaris ICDI drivers are installed and working, as evidenced by the code running straight from Energia. TivaWare example projects from CCS also run fine. But  I would much prefer to use the Energia API, as the base C code looks fairly impenetrable to me (as I said, I’m no expert). 

  • Hi,

    I hit almost all the issues you are having.

    Every time I click on the "green bug button", the Debug view shows the core running free: Stellaris In-Circuit Debug Interface_0/CORTEX_M4_0 (Running)

    When I halt the processor the Console view shows the Debug Port error you mentioned: CORTEX_M4_0: Error: Debug Port error occurred.

    At this point, however, when I issued a System Reset (see picture below) and put the core to run again, the code runs fine and I am able to properly debug it.

    Therefore this indicates the Energia code requires a complete reset to properly run. The reason I mentioned Energia is because I also tested several Tivaware projects but they did not show the same behavior - i.e., they worked fine.

    I could not yet find a way to automate the reset operation, but can you try this and see if it helps you move forward?

    Hope this helps,

    Rafael

  • Thank you for your reply. This does indeed correct the issue, and I can now debug my problems. 

    I didn't reply sooner because I had other issues that I was investigating. However I'm now pretty sure I had a bad board. Another works fine. 

  • I got this exact error and the above correct answer works.
    I also was wondering if this is because the code with the project name, for example blink, is considered the code with the 'main' routine in it. The main.cpp file that calls setup() and loop() in Energia code is in the Energia include directory ending with, hardware/lm4f/cores/lm4f. After I start debug, pause the debug to be able to reset, I can start the green arrow and the program will stop at a break point set in main.cpp.
    Normal Code Composer projects start at the first executable line in main().
  • I got this exact error and the above correct answer works.

    I also was wondering if this is because the code with the project name, for example blink, is considered the code with the 'main' routine in it. The main.cpp file that calls setup() and loop() in Energia code is in the Energia include directory ending with, hardware/lm4f/cores/lm4f. After I start debug, pause the debug to be able to reset, I can start the green arrow and the program will stop at a break point set in main.cpp.

    Normal Code Composer projects start at the first executable line in main().

  • Texas Instruments Engineers: This is happening for me with a fresh install of both CCSv7 and Energia 18. The above mentioned workaround by desouza works, but *only* if I disable "On a program load or restart" in 'Debug > Auto Run and Launch Options' first.

    Relevant thread here: e2e.ti.com/.../586137

    Note: Using a fresh install of CCSv7 and fresh install of Energia 18.

    Does anyone know what changed from CCSv6 that causes this?? Why would CCSv6 perform a proper System Reset upon starting to debug, but CCSv7 requires manually (and annoyingly) selecting 'System Reset' AFTER disabling the debugger's auto-run options??
  • You can fix this problem by modifying the .gel file to force a system reset.

    $ pwd
    /home/kimballr/ti/ccsv7/ccs_base/emulation/gel
    $ diff tm4c1294ncpdt.gel rk1294ncpdt.gel
    127a128,132
    > OnRestart()
    > {
    > GEL_AdvancedReset("System Reset", 1);
    > }
    >

    Shouldn't enabling the checkboxes in the Debug Configuration/Target dialog/Program/Memory Load Options have the same affect? There are three options there that seem like they should accomplish this.

    "Reset the target on a connect"

    "Reset the target on a program load or restart"

    "Restart the target on a symbol load as well as a program load"
  • Phil LaFayette10 said:
    Does anyone know what changed from CCSv6 that causes this??

    I don't use Energia so can't investigate directly. However, for other CCS projects using the GNU ARM compiler found similar symptoms of a program crashing when first started a debug session, but manually generating a System Reset then allowed the program to run. The Wiki entry Known issue when using CCS 6.1/Linaro GCC 4.8.4 explains the reason, and describes a fix of adding ENTRY(ResetISR) to the linker script.

    From https://github.com/energia/Energia/blob/master/hardware/lm4f/cores/lm4f/lm4fcpp_snowflake.ld which I think is the Energia linker script for TM4C129 devices there is no ENTRY(ResetISR). Maybe adding ENTRY(ResetISR) to that Energia linker script would fix the problem.

  • The CCS Linker configuration already uses ResetISR. I tried adding the ENTRY(ResetISR) to the .ld script and it made no difference.

    I should have mentioned that the other 2 board variants, the Stellaris Board and the Tiva C board both work fine. It is only the TM4C1294 that seems to have issues.

    I should have also have mentioned that if I use an external program (lm4flash) to load the code and then start a Debug session without loading the program from the CCS IDE, the debug session also works successfully.

    I can use the IDE to flash the code using the default debug configuration and then terminate the stuck debug session. To get it to work properly, I need to pull the usb plug on the board and plug it back in, then use a modified Debug configuration that doesn't try to load the program, it just loads the symbols and it also works successfully.

    The problem only seems to occur when using the TM4C1294 variant of these boards in combination with uploading new code to the board. It has been reported to me that running CCS 6.1 works fine with this board. The problem appeared in CCS 7.

    -rick
  • Rick Kimball said:
    The problem only seems to occur when using the TM4C1294 variant of these boards in combination with uploading new code to the board. It has been reported to me that running CCS 6.1 works fine with this board. The problem appeared in CCS 7.

    Can you post an example problematic executable generated by Energia?

    I could set up a project-less debug session in CCS 7 to investigate the problem after starting a debug session.

  • Do you mean run energia and save the the .out file? Or do you mean generate the code from the CCS ide?
    I'm just using the sample Blink code that is provided.
  • Rick Kimball said:
    Do you mean run energia and save the the .out file?

    Yes.

    Also post the linker map file if a linker map file is created by the Energia build.

  • As per this related thread, this issue is being tracked in CCBT-2079.