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.

Flash program binary file with CCS ver 6

Other Parts Discussed in Thread: CCSTUDIO

I'd like to, in addition to download and program my application coff file, program a small section of flash from a binary file. I can do this with a DSS script (attached) but would like to do is in a single operation from CCS as part of the debug configuration. The idea is to easily download and debug the application, including the extra section programmed from the binary file. I don't see a way to do this directly in the debug configuration but is there some other hook, possibly i

//! @file
//! @brief Debug java script to load and execute App from Flash
//! @cond

// Import the DSS packages into our namespace to save on typing
importPackage(Packages.com.ti.debug.engine.scripting)
importPackage(Packages.com.ti.ccstudio.scripting.environment)
importPackage(Packages.java.lang)

// Configurable Parameters
var deviceCCXMLFile = "../../DevConApp/targetConfigs/TMS320F28075_xds2xx.ccxml";
var programToLoad = "../../DevConApp/Debug - Flash/DevConApp.out";
var fileToLoad = "../../DevConApp/Debug - Flash/Preamble.dat";

// Create our scripting environment object - which is the main entry point into any script and
// the factory for creating other Scriptable ervers and Sessions
print("Creating scripting environment object ...");
var script = ScriptingEnvironment.instance();

// Create a debug server
print("Creating a debug server ...");
var ds = script.getServer( "DebugServer.1" );

// Set the device ccxml 
print("Setting the device ccxml ...");
ds.setConfig( deviceCCXMLFile );

// Open a debug session
print("Opening a debug session ...");
var debugSession = ds.openSession( "Texas Instruments XDS2xx USB Debug Probe_0/C28xx_CPU1" );

debugSession.flash.options.setString("FlashEraseSelection", "Necessary Sectors Only (for Program Load)");
debugSession.flash.options.setNumeric("FlashSPLLIMULT",24);
debugSession.flash.options.setString("FlashSPLLFMULT","0 [0]");
debugSession.flash.options.setString("FlashSYSDIVSEL","1 [/2]");

// Connect to the target
print("Connecting to the target ...");
debugSession.target.connect();

// Start multiload with single erase
debugSession.flash.multiloadStart();

// Load the preamble into flash
print("Loading the preamble ...");
debugSession.memory.loadBinaryProgram(fileToLoad, 0x88004);

// Load the program 
print("Loading the program ...");
debugSession.memory.loadProgram( programToLoad );

// Finish multiload operation
debugSession.flash.multiloadEnd();

// Run the program
print("Running the program, no block ...");
debugSession.target.runAsynch();

print("Ran the program ...");
//! @endcond
n the GEL file, to accomplish this?

  • Can you take a look at this video and see if it helps accomplish what you are looking for?

  • Yes, this video describes what I want to do. However, I have two followup questions.
    1. The video has an absolute path the the application file. Is there some javaScript syntax, when running as an initialization script, that allows you to specify the application file in relative path terms. Say relative to the workspace/project.
    2. I'd like to save my debug configuration to source control so that other developers can use it. It looks like the debug configuration information is placed in the .launches directory. How do you force the creation of the debug confguration file? I see in one of the files in my .launches directory a file with a absolute path for the target configuration. How would I specify the target configuration so that this path is relative to the workspace/project?
    Thanks,John
  • John Szybist said:
    Is there some javaScript syntax, when running as an initialization script, that allows you to specify the application file in relative path terms.

    You can use relative paths with the loadProgram API to specify the location of the executable file.You can also use variables to configure the paths (check this out in some of the example .js files in the \ccsv6\ccs_base\scripting\examples\DebugServerExamples directory).

    John Szybist said:
    I'd like to save my debug configuration to source control so that other developers can use it.

    Please see this wiki section: http://processors.wiki.ti.com/index.php/Debug_Handbook_for_CCS#Portable_Debug_configurations

  • To load my binary file I define a variable in the script:
    var fileToLoad = "Preamble.dat";and use that variable to load the file:
    debugSession.memory.loadBinaryProgram(fileToLoad, 0x88004);but get an error:
    C28xx_CPU1: GEL: Unable to open file: C:\ti\ccsv6\eclipse\Preamble.dat
    org.mozilla.javascript.WrappedException: Wrapped com.ti.ccstudio.scripting.environment.ScriptingException: Error loading "Preamble.dat": Unable to open file: C:\ti\ccsv6\eclipse\Preamble.dat (C:/Users/Public/Documents/Neptune/DeviceControl/DevConApp/targetConfigs/LoadAppPreamble.js#23) (C:/Users/Public/Documents/Neptune/DeviceControl/DevConApp/targetConfigs/LoadAppPreamble.js#23)
    So it looks like the current working directory when loading "Preamble.dat" is "C:\ti\ccsv6\eclipse" not, say, the location of the script or the location of my project's build artifact's directory so I can't specify "Preamble.dat" unless I use an absolute path starting with the root of my file system.
  • John Szybist said:
    So it looks like the current working directory when loading "Preamble.dat" is "C:\ti\ccsv6\eclipse" not, say, the location of the script or the location of my project's build artifact's directory so I can't specify "Preamble.dat" unless I use an absolute path starting with the root of my file system.

    Can you try using ScripingEnvironment.setCurrentDirectory(String) to change the current working directory prior to loading it? 

    This is suggested in the API documentation for loadBinaryProgram (file index.html in /ccsv6/ccs_base/scripting/docs/DS_API ).

  • setCurrentDirectory documentation states: Set the current working directory for this ScriptingEnvironment (The default working directory is the directory in which the script resides). What I see is that the default directory is the directory where the CodeComposerStudio executable resides. I have not yet found a way to find the directory of my workspace or project from within the Initialization Script I specified in my debug configuration.

  • Hi John,
    When a DSS script is run from the command-line (via dss.bat for example), the default directory should be the location of the script. However when a DSS script is launched by CCS from a launch configuration, then the default directory is the 'eclipse' folder as you noticed. Looks like the documentation is only referencing one use case and needs to be updated. Sorry for the confusion.

    Thanks
    ki
  • Is it possible to give the script, launched from a launch configuration, command line parameter that can be parsed in the script? If so how do you parse? I'm looking at C:\ti\ccsv6\ccs_base\scripting\examples\loadti\getArgs.js but this technique doesn't seem to work.

  • The argument passing like you can do with command-line DSS (like with loadti for example) is not support via the initialization script field. That field is quite limited in functionality, unfortunately.
  • Thank you for your help.