CCSTUDIO: Debug Server Automation in CCS

Part Number: CCSTUDIO


Hi, 

I have a self-managed makefile project for a C28x MCU and I'm trying to simplify the debugging process in CCS 20.3.1.

Currently, in order to run a debug session I perform the following steps:

  1. Build and load the application via makefile on CLI (or through a task defined in tasks.json)
  2. Open the Debug Panel
  3. Import the target configuration file for the project (one-time).
  4. Start a project less debug session (this gets loaded in tasks.json).
  5. Connect the debugger to the target.
  6. Load symbols from my *.out file
  7. Set a breakpoint to `main()`
  8. Run the target.

I'd like to automate steps 4 through 8 so that debugging is less painful for myself and my team. Additionally, we'd really like to make it so this can be a portable solution that is either managed in the repo or easily reproducible via a config file (pasted in our Wiki or similar).

 

A couple things I've tried so far, and the questions I have regarding each:

Defining a session in `launch.json` file.

Based on the information in this page: https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html

I've created a launch configuration that looks like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug myProject",
            "type": "ccs-debug",
            "request": "launch",
            "targetConfig": "/path/to/project/target_configs/bh560v2.ccxml",
            "connections": [
              {
                "name": "Blackhawk XDS560v2-USB System Trace Emulator IcePick_C_0",
                "cores": [
                  {
                    "name": "C28xx_CPU1",
                    "program": "/path/to/project/build/out/myProject.out",
                    "autoConnect": true,
                    "loadSymbolsOnly": true
                  }
                ]
              }
            ]
        }
    ]
}

However, running this launch only seems to accomplish Step 4 above, rather than accomplishing Steps 4-6. When running, I still have to connect the target, load the symbol file before I can set my breakpoints and start running the application.

 

Is there something I'm missing here or should this technically work?

Scripting Console

This seemed promising and is close to being a full solution with a couple of issues:

  1. Using the Scripting Console directly in CCS means that you still need to execute commands in ordeer to get the debug session started. This quickly becomes cumbersome to do.
  2. Using the file load option is better, but still requires you to manually select the .js file you want to run, and then also ensure that you include commands for navigating to the root directory of your project since the CWD is wherever `consoleMain.js` is located.

With this method, is there a way to automatically invoke the Scripting Console with an initialization script, similar to how a .gdbinit or .bashrc file might? Or maybe invoke this as an action in tasks.json or launch.json?

Scripting Commands via CLI

Similar to the above, it looks like we can run custom scripts with the supplied run.bat/sh. Then, it looks like we can open a graphical debug session with `ds.launchCCS()`. This seems to work really well, and it is possible to wrap the whole thing into a script or as a target in the makefile. The biggest issue though, is that it fails if CCS is already open. Specifically, the error is due to two instances of CCS having the same "workspace" or folder opened. Since we'd likely already have CCS open to view the source code before opening a debug session, we would need to close the window before executing this .... not ideal.

Seems to me that a missing option for the `launchCCS()` function is to attach to an already existing CCS proceess. Is this something that exists or it is possible to get this sort of behavior in some other way? Or is there some insight you might be able to give related to how to control what folder CCS opens when launched this way?

 

Thanks!