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.

Problem in running DSS scripts

Hi,

I am using CCS v5 and am trying to use DSS to load my program onto my DSP. For some reason, with the same DSS script (no changes at all between attempts), I am able to load and run my program every other time. Let's say I run the script the first time and I am able to load the program, run it and exit with success. If I do it a second time, the script executes the loadProgram command but never returns. I then kill the process and run the script again, and this time I am able to run the script without a problem. Of course, the next time I try to run it again, it won't work and I will have to kill the process and retry.

The loadProgram command is as follows

debugSessionDSP.memory.loadProgram(programName);

I actually tried changing the loadProgram command to the following :

debugSessionDSP.expression.evaluate('GEL_Load("C:/Work/myProgram.out")');

and while I manage to load the program, I did not manage to execute the next command after this, that is running the program

debugSessionDSP.target.restart();

Is there something that I have to do to make sure my DSS script can load and run the program every time I run the script?

Thanks,

s

  • Hello Steph,

    Are you running on actual hardware and not simulation? Also, are you terminating the debug server at the end of your script?

    Thanks

    ki

  • Hi Ki,

    I am running on actual hardware. 

    I am terminating the debug server at the end of my script with the following commands

    debugServer.stop();
    debugSessionDSP.terminate();
    
    
    I also tried the other sequence of 
    debugSessionDSP.terminate();
    debugServer.stop();

    I did realize though, if I wait long enough before I run the script again, I am able load the program without a problem. I am not sure what is the shortest time I have to wait before I can run the script successfully twice, it's longer than 5 min. Last time I was successful, I probably waited 15 min.
    
    
    Thanks,
    s
  • Hi Steph,

    Your second sequence is the correct one. But it shouldn't impact your debug session. I'm not sure why you are running into this issue. The target must be getting into a strange state or your script is doing something else unexpected. Are you able to run back to back instances of loadti?

    http://processors.wiki.ti.com/index.php/Loadti

    Could you also provide more snippets of your script? Just want to know what actions are being done after the program load.

    thanks

    ki

  • Hi Ki,

    Here's my script. 

    I'll try loadit.

    Thanks,

    steph

    /*******************************************************************
     * This sample script loads and runs a specified program on a 
     * specified target. 
     *
     * Usage:
     *   dss runDSP.js myTargetConfig.ccxml myProgramFile.out
     *
    
     *******************************************************************/
    
    // Import the DSS packages into the namespace;
    importPackage(Packages.com.ti.debug.engine.scripting);
    importPackage(Packages.com.ti.ccstudio.scripting.environment);
    importPackage(Packages.java.lang);
    
    // Define parameters ----------------------------
    
    var targetConfig;           // (user input) target configuration file
    var programName;            // (user input) program to load
    
    var waitForHalt = 1;        // wait for program to halt before exiting
    
    var enableLogging = 0;              // enable logging
    var logFile = "RunProgramLog.xml";  // file where trace info is stored
    
    // Get the input parameters ---------------------
    var input = getArgs();
    programName  = input.programName;
    targetConfig = input.targetConfig;
    
    print("Target Config is" + targetConfig);
    // Create/configure scripting object -------------
    
    // Create the scripting environment object
    var script = ScriptingEnvironment.instance();
    
    // Set up the debug session ----------------------
    
    print("*** Starting debug session...");
    
    // Get the Debug Server
    debugServer = script.getServer("DebugServer.1");
    debugServer.setConfig(targetConfig);
    
    // Start a Debug Session
    
    debugSessionDSP = debugServer.openSession("Blackhawk XDS560v2-LAN System Trace Emulator_0/C674X_0");
    print("*** Debug Session Name: " + debugSessionDSP.getName());
    print("*** Board Name: " + debugSessionDSP.getBoardName());
    print("*** CPU Name: " + debugSessionDSP.getCPUName());
    
    // Connect to the target -------------------------
    try {
        print("*** Connecting to DSP...")
        debugSessionDSP.target.connect();
    } 
    catch (ex) {
        print(" Fail to connect to DSP...");
        exitFailScript();   
    }
    
    
    // Load the program -------------------------------
    print("*** Loading the program to the target...")
    try{
    debugSessionDSP.memory.loadProgram(programName);
    
    print("*** LoadED the program to the target...")
    }
    catch (ex){
    print("** cannot load program ***");
    exitFailScript();   
    }
    // Restart the program ----------------------------
    debugSessionDSP.target.restart();
    
    // Run the program --------------------------------
    print("*** Run Program...")
    
    debugSessionDSP.beginCIOLogging("cio.txt"); 
    
    
    try{
    debugSessionDSP.target.runAsynch();
    // Run program for 5s
    java.lang.Thread.sleep(5000);
    //halt program
    debugSessionDSP.target.halt();
    }
    catch (ex){
    print("** cannot run program **");
    exitFailScript();   
    }
    
    
    // Read timing data and save to a file
    var timing_address = debugSessionDSP.symbol.getAddress("TimestampArray");
    debugSessionDSP.memory.saveData(Memory.Page.PROGRAM, timing_address, "timing_data.dat",3000,Memory.IOFormat.HEX,false);
    
    
    print("*** Stop Logging.");
    // Disconnect from target --------------------------
    
    try {
        print("*** Disconnecting from DSP...");
       // debugSessionDSP.target.disconnect();
    	print("*** DSP disconnected...");
    } 
    catch (ex) {
        // ignore if disconnect() fails - it may not be supported   
    	print("*** FAILED Disconnecting from DSP..."); 
        exitFailScript();   
    }
    
    debugSessionDSP.endCIOLogging(); 
    // All done -----------------------------
    
    print("*** Terminating debug session...");
    debugSessionDSP.terminate();
    debugServer.stop();
    
    
    
    print("*** LOAD & RUN DONE.");
    exitScript();
    
    /**************************************
     * Get arguments from the command-line. 
     **************************************/
    function getArgs()
    {
        var args = {};
        var arguments = this.arguments;
    
        if (!(arguments.length == 2))
        {
    		print(
                "ERROR: You did not specify the required arguments.\n" + 
                "Usage: dss runProgram.js <targetConfigurationFile> <programFile>\n");        
            delete args;
            java.lang.System.exit(0);
    	}
        args.targetConfig = arguments[0];
        args.programName  = arguments[1];
        return args;
    }
    
    /**************************************
     * Exit the script
     **************************************/
    function exitScript()
    {
        //if (enableLogging)
       // {
       //     script.traceSetConsoleLevel(TraceLevel.INFO); 
       //     script.traceEnd(); // stop logging
       // }
    //quit();
    print("runProgram Success : Exit 0\n");    
    java.lang.System.exit(0);
    }
    
    function exitFailScript()
    {
        print("runProgram Failed : Exit -1\n");
        java.lang.System.exit(-1);
    
    }
    
    

  • The script looks ok. You are doing an async run. You can try running loadti asynchronously (use -h option to get the help) to see if that makes a difference.