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.

Automate connection steps to start debugging (externally built .out file)

Other Parts Discussed in Thread: IWRL6432BOOST

Hi,


I'm trying to make it a bit faster for us to debug in CCS when loading a newly built out file with all the debug symbols in.

CCS Version V12.6.0

Context:

  • We use our own WAF build system with the CLANG compiler and then we debug in CCS.
  • This is currently triggered from VS code, but if WAF is supported in CCS that would be good to know...
  • We are using a IWRL6432BOOST module, but I expect the question related to automation may apply to other TI products as well.

Steps we need to take to debug in CCS:

Currently our specific process to start a debug session looks as follows:

  1. Build in WAF
  2. Launch target configuration
  3. Click show all cores
  4. Connect to XDS110 USB/CS_DAP_0
  5. Run our wakeup gel file from scripts > ... > our script Get message: "M4 reset released"
  6. Connect to XDS110 USB/Cortex_M4_0
  7. Reset it
  8. Load program previously built
  9. Start Debugging

That's a lot of clicks to start a debug session!

Potential Solutions

  • I'd like to create a "debug" script that does as much of this as possible in one step.
  • Can we do this with Debug Server Scripting DSS?
  • Alternative suggestions are welcome
  • If WAF can be incorporated in CCS that would also work, but I suspect this is not option

Any assistance is greatly appreciated!!



Warm Regards
Jaco Swart

  • Okay so I've made some progress, but there are still some steps missing that I may need assistance with.

    UPDATE:

    What can I do so far?

    • I can use DSS scripting commands via the ("View" > "Scripting Console") to run my steps

    What can't I do:

    • Run these commands from a script externally
    • Attach CCS to the running debug session

    Any assistance would be appreciated

    DSS Javascript code to perform my steps:


    // No idea how to get this to work yet
    importPackage(Packages.com.ti.debug.engine.scripting);
    importPackage(Packages.com.ti.ccstudio.scripting.environment);
    importPackage(Packages.java.lang);
    
    // CSS
    var ccsInstallDir = "C:/TI/ccs1260/ccs";
    // Directory where I've put everyting for this script:
    
    var script_folder = "C:/LocalScratch/debug_script";
    // File structure:
    // /debug_script/application.out
    // /debug_script/xwrl6432_xds110.ccxml
    // /debug_script/xwrLx432.gel
    
    // Folder and file setup
    var logFile = script_folder + "log.xml";
    var logFileStylesheet = ccsInstallDir + "/ccs_base/scripting/examples/DebugServerExamples/DefaultStylesheet.xsl";
    var deviceCCXMLFile = script_folder + "/xwrl6432_xds110.ccxml";
    var programToLoad = script_folder + "/application.out";
    var gel_file = script_folder + "/xwrLx432.gel";
    
    // Get a handle to the scripting environment object
    var scriptEnv = ScriptingEnvironment.instance();
    
    // Logging (DOES NOT WORK) QUESTION: Why?
    scriptEnv.traceBegin(logFile, logFileStylesheet);
    scriptEnv.traceSetConsoleLevel(TraceLevel.INFO);
    scriptEnv.traceSetFileLevel(TraceLevel.ALL);
    scriptEnv.traceWrite("Begin scripting session");
    
    // Get a handle to a ScriptServer object to interact with the debugger
    var debugServer = scriptEnv.getServer("DebugServer.1");
    // Set the target configuration
    debugServer.setConfig(deviceCCXMLFile);
    
    // Connect to CS_DAP_0 and Run gel file
    var cs_dap_session = debugServer.openSession("Texas Instruments XDS110 USB Debug Probe_0/CS_DAP_0");
    cs_dap_session.target.connect();
    cs_dap_session.expression.evaluate('GEL_LoadGel("' + gel_file + '")');
    
    // Connect and reset cortexm4
    var cortexm4 = debugServer.openSession("Texas Instruments XDS110 USB Debug Probe_0/Cortex_M4_0");
    cortexm4.target.connect();
    cortexm4.target.reset()
    
    // Load program
    cortexm4.memory.loadProgram(programToLoad);
    
    // Start debugging
    cortexm4.target.run();
    
    // Stop - QUESTION: Should this be here?
    debugServer.stop();
    
    // Stop logging
    scriptEnv.traceWrite("End scripting session");
    scriptEnv.traceEnd();
    

  • Run these commands from a script externally

    What issue do you run into when running the script outside CCS?

    Attach CCS to the running debug session

    If you are inquiring about launching the CCS IDE and connecting it to an already active DSS session, then this is not possible. You can have a DSS script launch the CCS IDE however.

    Thanks

    ki

  • Thanks for the reply Ki. I appreciate the time.

    I'm a bit confused about how to run it exactly. I've tried to launch it using (Let's call my script "script.js")

    Path 1
    dss.bat script.js
    run.bat script.js

    I get errors at the import step in my script "script.js" because the syntax above seems to be java not javascript, but I do not see examples of the same in javascript.

    If I can resolve the issue so that the script recognizes the CSS commands then maybe I can get it to work?
    Perhaps in the above two commands there is an additional step required to launch the IDE?


    Alternative Path 2 (Primary Path at this stage)

    set CCS_INSTALL_DIR="C:\TI\ccs1260\ccs\eclipse\ccstudio.exe"
    
    set WORKSPACE="C:\LocalScratch\debug_script"
    set SCRIPT_PATH="C:\LocalScratch\debug_script\run_debug.js"
    
    %CCS_INSTALL_DIR% -data %WORKSPACE% -application com.ti.ccstudio.apps.runScript -product com.ti.ccstudio.branding.product -import %SCRIPT_PATH%


    This is the closest to a working script that I've gotten, but it opens the IDE without showing anything. I can see it in task manager, but it's not open.
    The result:
    1. I see the IDE splash
    2. See the IDE in "Task Manager"
    3. No errors and no IDE user interface

  • At the end of the day I've decided to simplify this a bit by just copy pasting the DSS code into the Scripting Console inside of Code Compiler Studio.

    I wrote scripts in VS code to copy the correct commands to clipboard when I click "Debug" and then all I have to do is Paste in CCS to start debugging.

    Solution Summary:

    1.Build mmwave project with WAF using "-g3" compiler flag for debug info

    2.Skip automation of steps 1-5 (problem) since these don't need to be repeated for debugging

    2. Generate code to program and start debugging with built out file in CCS from the "Scripting Console"

    // This line is programatically generated
    var workspace = "C:/LocalScratch/mmwave-low-power-radar"; 
    // Copy paste this when you debug
    var scriptEnv = ScriptingEnvironment.instance();
    var debugServer = scriptEnv.getServer("DebugServer.1");
    var scriptEnv = ScriptingEnvironment.instance();
    var debugServer = scriptEnv.getServer("DebugServer.1");
    var deviceCCXMLFile = workspace + "/modules/ti-mmwave-sdk/xwrl6432_xds110.ccxml";
    var programToLoad = workspace + "/out/current/application.out";
    //debugServer.setConfig(deviceCCXMLFile);
    var cortexm4 = debugServer.openSession("Texas Instruments XDS110 USB Debug Probe_0/Cortex_M4_0");
    cortexm4.target.connect();
    cortexm4.target.reset()
    cortexm4.memory.loadProgram(programToLoad);


    3. Paste this in CCS "Scripting Console" and press enter to start debugging session



    Thanks for the help!

    VS Code Setup Details

    Script to copy this code to clipboard from VS code

    Using "Task Buttons" extension the script below can be added as a "Debug" button

    debug.bat (Windows batch file)

    set javescript_to_start_debugging=".\scripts\CCS\debugging\code_to_start_debugging.js"
    
    :: Copy the code to start debugging
    set /p jsContent=<%javescript_to_start_debugging%
    
    set currentDir=%CD:\=/%
    set outputFile=".\scripts\CCS\debugging\temp.txt"
    
    :: Make sure that we use the project workspace for the person using this script
    echo var workspace = "%currentDir%"; > %outputFile%
    type %javescript_to_start_debugging% >> %outputFile%
    type "%outputFile%" | clip
    del %outputFile%
    
    echo Copied debug execution script to clipboard!
    echo.
    echo To Start debugging session:
    echo 1. Paste to Scripting Console inside CCS
    echo 2. Press Enter
    echo.
    echo HINT: Find Scripting Console in "View > Scripting Console"
    echo.


    Further details of VS code setup

    tasks.json
    {
        "label": "Debug",
        "command": "./scripts/CCS/debug_CCS.bat",
        "type": "shell",
    },

    Settings.json

    "VsCodeTaskButtons.tasks": [
        {
            "label": "Debug $(bug)",
            "task": "Debug"
        }
    ]