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.

[FAQ] CCS/CC2640R2F: CC26x2: How to connect the debugger to a running target?

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC1312R, CC1352R, CC1352P, CC2642R, CC2652P, CC2652R

Tool/software: Code Composer Studio

This solution works for CC26x0 and CC26x2 devices (it includes CC2640R2, CC2642R, CC2652R, CC2652P, CC1312R, CC1352R, CC1352P).

I have tested it using CCS 9.3.

The possibility to connect the debugger to a running target can help you if you want to see the status of your target after several days, or if you cannot reproduce a crash with the debugger attached. Let's dive in it!

1-      Modify the GEL file

In a very simplistic view, the GEL files describe the way the device’s debugger has to act (more details can be found in the CCS’s help). By default, the GEL files ask the device to reset when the debugger is started up. Hopefully we can modify this:

     a-       Identify the GEL files used

  • Start a debug session as always
  • (If needed), display the debug view
  • Right-click on the program being, “Open GEL files View”.
  • In the GEL files list, open the corresponding GEL file by double-clicking it. Chose cc26x2.gel for CC26x2 devices. Chose cc26x0.gel for CC26x0 devices.

 

     >> Another possibility consists in looking in the <CCS directory>\ccs_base\emulation\gel for the GEL files.

 

     b-      In the StartUp() function, comment out the code executing the reset. If needed, an explicit comment will help you to identify the code to comment out.

Here the content of the StartUp() function after modification:

StartUp(int major, int minor, int patch)
{
    /* Initialize memory map */
    memorymap_init();

    /* Debugger specific handling */
    if(GEL_MatchesConnection(".*TIXDS.*") == 1)
    {
        GEL_LoadGel("$(GEL_file_dir)/cc26xx_connect_util.gel");
        GEL_LoadGel("$(GEL_file_dir)/cc26x2_xds.gel");

        DefineResets(0);

        // Issue Board Reset to ensure device is in a known state
        // Note: If you want to attach to a running target without resetting the
        //       device, you must comment out the following 4 lines:
//        if(!GEL_IsConnected())
//        {
//            GEL_AdvancedReset("Board Reset");
//        }
    }
    else if(GEL_MatchesConnection(".*JLink.*") == 1)
    {
        GEL_LoadGel("$(GEL_file_dir)/cc26xx_jlink.gel");
    }
    else
    {
        GEL_TextOut("Error: Unknown debugger.\n");
        return;
    }
}

     c-       Save you modification and close the file. Stop your debugging session.

2-      Modify the Debug Configuration of your project

Once you have clicked CCS’s debug button (the green bug), CCS is doing a lot of different actions for you. For example CCS loads the program and stops the execution of the code on the target. In our case, we don’t want CCS to load the program (as we already have a running program…). In the same idea, we don’t necessarily want to stop the execution of the code on the target.
Hopefully, the way CCS is running a debug session is highly configurable. So let’s adapt those configurations to our needs.

     a-       On the right of the Debug button, there is an arrow. Click this arrow and select “Debug Configurations...”.

     b-      Select your project.

     c-       Prevent CCS to load the program: in the “Program” tab, chose the proper “Loading option”

 

 

     d-      Prevent CCS to stop the target: in the “Target” tab, deselect the option “Hal the target on a connect”

  

3-      [Optional] Prevent CCS to build the program before load.

As no program will be loaded, it is a bit useless to ask CCS to build an image when you start a debug session. As result, you can disable this option by using the small arrow at the right of the Flash button. Click on “Build Project Before Load” in order to disable the option

 

You are all set now! Let the code running and when needed connect the running target using the Debug button as you usually do.

 

Q: How can I load a new image on the device now?

A: The easiest way is to use the Flash button and select the image to flash. Don’t forget to rebuild your image manually (as we have disabled the option before). Another solution consists in undoing all the configuration changes we did before. A third solution consists in using a different version of CCS.

 

Q: Does these configurations affect all my devices?

A: It depends on the modifications

  • The modifications done at step 1 (GEL file modification) affect all the devices using the same GEL files. In other words, it affects all the CC26X2 and CC13X2 if you modified cc26x2.gel, and all the CC26x0 and CC13x0 if you modified cc26x0.gel.
    Keep in mind that by default, two different CCS versions does *not* use the same GEL files.
  • The modification of the debug configurations only affects one project