Hi,
i'm using CCS 4.2.4.0033 and want to run tests with loadti.bat on TMS570 chip.
The target address from is 0x0 is the external flash device.
I won't use this flash for interrupt vector tables and have moved it to RAM on 0x68000000.
See map file:
******************************************************************************
TMS470 Linker PC v4.6.1
******************************************************************************
>> Linked Sat Nov 24 19:30:53 2012
OUTPUT FILE NAME: <UUT_INST.out>
ENTRY POINT SYMBOL: "_c_int00" address: 680204ec
MEMORY CONFIGURATION
name origin length used unused attr fill
---------------------- -------- --------- -------- -------- ---- --------
VECTORS 68000000 00000020 00000020 00000000 X
STACKS 68000020 00008000 00000000 00008000 RW
EMIF_RAM 68008020 00ff7fe0 00032d8e 00fc5252 RW
SEGMENT ALLOCATION MAP
run origin load origin length init length attrs members
---------- ----------- ---------- ----------- ----- -------
68000000 68000000 00000020 00000020 r-x
68000000 68000000 00000020 00000020 r-x .intvecs
68008020 68008020 0001a620 0001a620 r-x
68008020 68008020 0001a620 0001a620 r-x .text
68022640 68022640 00017d39 00000000 rw-
68022640 68022640 00016000 00000000 rw- .sysmem
68038640 68038640 00001d39 00000000 rw- .bss
6803a380 6803a380 00000514 00000514 rw-
6803a380 6803a380 00000514 00000514 rw- .data
6803a894 6803a894 00000524 00000524 r--
6803a894 6803a894 00000409 00000409 r-- .const
6803aca0 6803aca0 00000118 00000118 r-- .cinit
SECTION ALLOCATION MAP
output attributes/
section page origin length input sections
-------- ---- ---------- ---------- ----------------
.intvecs 0 68000000 00000020
68000000 00000020 sys_intvecs.obj (.intvecs)
.text 0 68008020 0001a620
68008020 00005610 B0000002.obj (.text)
6800d630 00004014 I0000012.obj (.text)
68011644 00003714 I0000009.obj (.text)
68014d58 00002734 B0000001.obj (.text)
6801748c 00002108 I0000011.obj (.text)
68019594 000018e0 I0000013.obj (.text)
6801ae74 00001584 I0000015.obj (.text)
6801c3f8 000011fc B0000007.obj (.text)
6801d5f4 00000dea rtsv7R4_T_be_v3D16_eabi.lib : _printfi.obj (.text)
6801e3de 00000002 --HOLE-- [fill = 0]
6801e3e0 00000dc4 B0000008.obj (.text)
6801f1a4 00000748 I0000014.obj (.text)
6801f8ec 000004a8 S0000003.obj (.text)
6801fd94 000003ec rtsv7R4_T_be_v3D16_eabi.lib : memory.obj (.text)
68020180 0000036c : lowlev.obj (.text)
680204ec 0000032c sys_startup.obj (.text)
68020818 000002f4 rtsv7R4_T_be_v3D16_eabi.lib : trgdrv.obj (.text)
68020b0c 000002d4 sys_core.obj (.text)
68020de0 000002b8 rtsv7R4_T_be_v3D16_eabi.lib : ull_div32.obj (.text)
68021098 00000278 B1_switch.obj (.text)
68021310 000001e4 rtsv7R4_T_be_v3D16_eabi.lib : fopen.obj (.text)
680214f4 00000184 system.obj (.text)
68021678 00000128 B4_switch.obj (.text)
680217a0 00000118 S3_switch.obj (.text)
680218b8 00000110 rtsv7R4_T_be_v3D16_eabi.lib : strtoul.obj (.text)
680219c8 00000104 : fputs.obj (.text)
68021acc 000000dc B0000004.obj (.text)
68021ba8 000000d8 sys_memory.obj (.text)
68021c80 000000b0 rtsv7R4_T_be_v3D16_eabi.lib : _io_perm.obj (.text)
68021d30 000000a4 : fflush.obj (.text)
68021dd4 000000a4 : setvbuf.obj (.text)
68021e78 0000009c : memcpy_t2.obj (.text)
68021f14 0000007c : fputc.obj (.text)
68021f90 00000078 : memset_t2.obj (.text)
68022008 00000066 : ltoa.obj (.text)
6802206e 00000002 --HOLE-- [fill = 0]
68022070 00000064 : trgmsg.obj (.text)
680220d4 00000060 : fclose.obj (.text)
68022134 00000060 : sprintf.obj (.text)
68022194 00000058 : i_div32.obj (.text)
680221ec 00000054 : printf.obj (.text)
68022240 00000054 : u_div32.obj (.text)
68022294 00000050 : atoi.obj (.text)
680222e4 00000050 : atol.obj (.text)
68022334 00000050 : cpy_tbl.obj (.text)
68022384 0000004e : fseek.obj (.text)
680223d2 00000048 : copy_decompress_rle.obj (.text:decompress:rle)
6802241a 00000002 --HOLE-- [fill = 0]
6802241c 00000044 : exit.obj (.text)
68022460 00000040 : signal.obj (.text)
680224a0 0000003e : setjmp_t2.obj (.text)
680224de 00000030 : strncpy.obj (.text)
6802250e 00000028 : strncmp.obj (.text)
68022536 00000024 : memccpy.obj (.text)
6802255a 0000001e : memchr.obj (.text)
68022578 0000001a : strcat.obj (.text)
68022592 0000001a : strcmp.obj (.text)
680225ac 00000018 : _lock.obj (.text)
680225c4 00000018 : ll_mul_t2.obj (.text)
680225dc 00000016 : strchr.obj (.text)
680225f2 00000014 : strlen.obj (.text)
68022606 00000012 : copy_decompress_none.obj (.text:decompress:none)
68022618 00000010 : copy_zero_init.obj (.text:decompress:ZI)
68022628 00000010 : strcpy.obj (.text)
68022638 00000004 : remove.obj (.text)
6802263c 00000004 sys_phantom.obj (.text)
In Code-Composer Studio I can do the following steps
1) Target -> "Launch TI Debugger"
2) Target -> "Connect Target"
3) Target -> "Load Program"
=> The program is loaded and the Target (haltet somewhere)
4) Target -> "Restart"
=> The target is restarted and halts on "int main (int argc, char **argv) {" on address 0x6801F8E4.
(=> BUT sometimes i have to halt and press restart again.)
When i press go, the programm is executed well.
Now i want to do the same in loadti.bat.
Therefore I added after the loading of the program a "debugSession.target.restart();"
/* ===========================================================================
* This .js file is a VectorCAST version that was created from the default
* file that was delivered with CCS version 4.x. This new file was needed
* because in some cases VectorCAST requires a customized main.js Java File
*
* All of the diffs are been commented with "//VCAST:"
* =========================================================================== */
/**
* @main.js - This script mimics Texas Instruments' load6x stand-alone
* simulator base functionality but will work with any TI target (HW or
* Simulator) that is supported by Debug Server Scripting.
*/
// Run loadti.
testEnv = {};
run();
/**
* Send message to the console and log (if logging is enabled)
* @param {String} The string to output to the console/log.
*/
function printTrace(string)
{
if (!testEnv.quietMode)
{
dssScriptEnv.traceWrite(string);
}
}
/**
* Get error code from the given exception.
* @param {exception} The exception from which to get the error code.
*/
function getErrorCode(exception)
{
var ex2 = exception.javaException;
if (ex2 instanceof Packages.com.ti.ccstudio.scripting.environment.ScriptingException) {
return ex2.getErrorID();
}
return 0;
}
/**
* This function is called to perform some clean up before exiting (or
* aborting) the script. It assumes that the the scripting environment and
* debug and profile servers have been created.
*/
function quit(retVal)
{
printTrace("\nEntered the quit function...");
if (isDebugSession)
{
//by MSK:
if(debugSession.target.isHalted()) {
printTrace("\nTarget already halted.");
} else {
printTrace("\nHalt target...");
try {
debugSession.target.halt();
}
catch (ex)
{
//ex.javaException.printStackTrace();
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", failed to halt target!");
}
}
//by MSK:
if(debugSession.target.isConnected())
{
printTrace("\nDisconnect Target...");
try {
debugSession.target.disconnect();
}
catch (ex)
{
//ex.javaException.printStackTrace();
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", failed to disconnect target!");
}
}
else
{
printTrace("\nTarget not connected!");
}
// Close debug session.
printTrace("\nTerminate Debug Session. @"+debugSession);
try{
debugSession.terminate();
}
catch (ex)
{
//ex.javaException.printStackTrace();
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", failed to terminate debugSession!");
}
}
else
{
printTrace("\nError: DebugSession not found.");
}
if (isDebugServer)
{
printTrace("\nStop Debug Server. @"+debugServer);
try{
debugServer.stop();
}
catch (ex)
{
//ex.javaException.printStackTrace();
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", failed to stop debugServer!");
}
}
else
{
printTrace("\nError: DebugServer not found.");
}
date = new Date();
printTrace("\nEND: " + date.toTimeString());
if (testEnv.logFile != null)
{
// Close log.
dssScriptEnv.traceEnd();
}
if (testEnv != null)
{
printTrace("\Delete Test Environment @"+testEnv);
delete testEnv;
}
else
{
printTrace("\nError: No Test Environment to delete.");
}
// Terminate JVM and return main return value.
java.lang.System.exit(retVal);
}
/*
* Main function.
*/
function run()
{
var inst;
var errCode = 0;
var retVal = 0;
var date = 0;
var defaultTimeout = -1;
isDebugServer = false;
isDebugSession = false;
load(java.lang.System.getenv("LOADTI_PATH") + "/getArgs.js");
getArgs();
// Create base scripting environment.
dssScriptEnv = Packages.com.ti.ccstudio.scripting.environment.ScriptingEnvironment.instance();
// Set overall script timeout value.
dssScriptEnv.setScriptTimeout(defaultTimeout);
// Enable logging to a file if specified.
if (testEnv.logFile != null)
{
// NOTE: Log output folder must already exist.
try
{
dssScriptEnv.traceBegin(testEnv.logFile, java.lang.System.getenv("LOADTI_PATH").replace("\\", "/") +
"/DefaultStylesheet.xsl");
dssScriptEnv.traceSetFileLevel(Packages.com.ti.ccstudio.scripting.environment.TraceLevel.ALL);
}
catch (ex)
{
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", failed to enable logging for " + testEnv.logFile +
"\nLogging disabled!");
testEnv.logFile = null;
}
}
// Set console verbosity.
if (testEnv.verboseMode)
{
dssScriptEnv.traceSetConsoleLevel(Packages.com.ti.ccstudio.scripting.environment.TraceLevel.ALL);
}
printTrace("\nRunning main.js EMBEX-Version");
printTrace("\n***** DSS Generic Loader *****\n");
date = new Date();
printTrace("START: " + date.toTimeString() + "\n");
// Configure the Debug Server.
if (testEnv.setupCfgFile != null)
{
printTrace("Configuring Debug Server for specified target...");
load(java.lang.System.getenv("LOADTI_PATH") + "/dsSetup.js");
errCode = configureDebugServer(testEnv.setupCfgFile, dssScriptEnv);
if (errCode != 0)
{
quit(errCode);
}
printTrace("Done");
// There's no more to do if no outfiles have been provided.
if (testEnv.outFiles == null)
{
// VCAST: Rob Added this, no harm
printTrace("No OutFile Provided, Aborting");
quit(0);
}
}
else
{
if (java.lang.System.getProperty("os.name").contains("Linux"))
{
dssScriptEnv.traceWrite("No target setup configuration file specified. Aborting!");
quit(1);
}
printTrace("No target setup configuration file specified. Using existing setup");
}
// Open Debug Server session.
if (!isDebugServer)
{
debugServer = dssScriptEnv.getServer("DebugServer.1");
isDebugServer = true;
}
//VCAST: By default the script did not handle multicore.
// The syntax for open session using ("*", "*") will
// open a session for the first target, and the first CPU
// In some cases, we need to provide an explicit core name
// For the second parameter
if (testEnv.coreName!="")
{
printTrace("The value for --coreName provided on the command line is: '" + testEnv.coreName + "'");
printTrace("Opening Session for Core: " + testEnv.coreName);
// We catch the exception here, in case they provided the wrong coreName
try
{
debugSession = debugServer.openSession("*", testEnv.coreName);
}
catch (ex)
{
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", could not OpenSession, Aborting!");
// Version 4 of the CCS scripting does not support getListOfCPUs
if (typeof debugServer.getListOfCPUs == 'function') {
var cpuList = debugServer.getListOfCPUs();
var i = 0;
printTrace("The attached device has the following cores: ");
while (cpuList[i])
{
printTrace(" " + String(cpuList[i]));
i++
}
}
quit(errCode != 0 ? errCode : 1);
}
}
else
{
// If no coreName was specified on the command line,
// let's get the list and echo it to the Trace Report to help
// with debugging the configuration
if (typeof debugServer.getListOfCPUs == 'function') {
var cpuList = debugServer.getListOfCPUs();
var i = 0;
printTrace("The attached device has the following cores: ");
while (cpuList[i])
{
printTrace(" " + String(cpuList[i]));
i++
}
}
printTrace("To choose between multiple cores, add the '--coreName <name>' to the command line");
printTrace("Opening Session for first Core (*)");
debugSession = debugServer.openSession("*", "*");
}
//VCAST: End Block
isDebugSession = true;
printTrace("TARGET: " + debugSession.getBoardName());
//VCAST: Added some additional debug trace statements
platform = debugSession.getPlatform();
printTrace("PLATFORM: " + platform );
printTrace("CPU: " + debugSession.getCPUName());
printTrace("Connecting to target...");
// Connect to target. If target is simulator or already connected, a warning will be reported.
try
{
debugSession.target.connect();
}
catch (ex)
{
//ex.javaException.printStackTrace();
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", could not connect to target!\nAborting!");
quit(errCode != 0 ? errCode : 1);
}
//by MSK:
if(debugSession.target.isConnected())
{
printTrace("Target is connected.");
}
//by MSK:
printTrace("\nHalt target...");
try {
debugSession.target.halt();
}
catch (ex)
{
//ex.javaException.printStackTrace();
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", failed to halt target!");
}
if (testEnv.resetTarget)
{
printTrace("Resetting target...");
// Reset target.
try
{
debugSession.target.reset();
}
catch (ex)
{
//ex.javaException.printStackTrace();
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", could reset target!\nAborting!");
quit(errCode != 0 ? errCode : 1);
}
}
//VCAST: Added this special case code to get the ezDSP 28335 board working which needs the
// watchdog to be disabled and external memory to be enabled
if (debugSession.getBoardName().contains("Spectrum Digital DSK-EVM-eZdsp"))
{
printTrace("Disabling Watchdog...");
debugSession.expression.evaluate("Disable_WD()");
printTrace("Enabling External memory...");
debugSession.expression.evaluate("XINTF_Enable()");
}
//by MSK:
//debugSession.options.printOptions("FlashEraseSelection");
printTrace("Set debugSession -> FlashEraseSelection -> Necessary Sectors Only (for Program Load)");
debugSession.options.setString("FlashEraseSelection", "Necessary Sectors Only (for Program Load)");
// Load and run each program provided.
java.lang.System.out.println("testEnv.outFiles: " + testEnv.outFiles);
var st = new java.util.StringTokenizer(testEnv.outFiles, "+");
while (st.hasMoreTokens())
{
var outFile = st.nextToken();
var filePath = new java.io.File(outFile);
var outFileName = filePath.getName();
testEnv.argvArgs[0] = outFileName;
printTrace("Loading " + outFile);
// Load program and pass arguments to main (if applicable).
try
{
if (testEnv.initBss)
{
printTrace("set debugSession.memory.setBssInitValue(" + testEnv.initBssValue+ ")");
debugSession.memory.setBssInitValue(testEnv.initBssValue);
}
printTrace("check testEnv.argvArgs.length : " + testEnv.argvArgs.length + " < 2");
if (testEnv.argvArgs.length < 2)
{
debugSession.memory.loadProgram(outFile);
}
else
{
debugSession.memory.loadProgram(outFile, testEnv.argvArgs);
}
}
catch (ex)
{
//ex.javaException.printStackTrace();
errCode = getErrorCode(ex);
printTrace("Error code #" + errCode + ", " + outFile + " load failed!\nAborting!");
quit(errCode != 0 ? errCode : 1);
}
printTrace("Done");
load(java.lang.System.getenv("LOADTI_PATH") + "/memXfer.js");
// Load data from the host to target memory (if applicable).
if ((testEnv.loadRaw.length > 0) || (testEnv.loadDat.length > 0))
{
printTrace("Loading data to target memory...");
errCode = memLoad(dssScriptEnv, debugSession, testEnv.loadRaw, testEnv.loadDat);
if (errCode != 0)
{
printTrace("Memory load failed with errCode: " + errCode);
quit(errCode != 0 ? errCode : 1);
}
else
{
printTrace("Done");
}
}
//by MSK:
printTrace("\nHalt target...");
try {
debugSession.target.halt();
}
catch (ex)
{
//ex.javaException.printStackTrace();
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", failed to halt target!");
}
if (testEnv.restartTarget)
{
printTrace("Restarting target...");
// Restart target.
try
{
debugSession.target.restart();
}
catch (ex)
{
//ex.javaException.printStackTrace();
errCode = getErrorCode(ex);
dssScriptEnv.traceWrite("Error code #" + errCode + ", could restart target!\nAborting!");
quit(errCode != 0 ? errCode : 1);
}
}
if (!testEnv.onlyLoad)
{
printTrace("Target running...");
// Set script timeout value for run API.
dssScriptEnv.setScriptTimeout(testEnv.timeoutValue);
if (testEnv.cioFile != null)
{
// Begin CIO logging.
debugSession.beginCIOLogging(testEnv.cioFile);
}
// Run to end of program (or timeout) and return total cycles unless asynch run.
try
{
// Is the target already at the end of the program? If so, do not try to run again.
// Note: we need to check the existance of the symbol first, since the evaluate function does not, and will return errors if the symbol does not exist, causing the script to exit
// Note: This check is to fix the following use case: if the debugger is configured to Auto Run to a label after program load but that label is not hit then the loadti script may cause the program to enter an infinite loop.
if ( ( debugSession.symbol.exists("C$$EXIT") && debugSession.expression.evaluate( "PC == C$$EXIT" ) ) ||
( debugSession.symbol.exists("C$$EXITE") && debugSession.expression.evaluate( "PC == C$$EXITE") ) ||
( debugSession.symbol.exists("abort") && debugSession.expression.evaluate( "PC == abort") ) )
{
printTrace( "Target failed to run to desired user label after program load, and is at end of program. Script execution aborted." );
} else {
// continue with running the program
if (!testEnv.asyncRun)
{
printTrace("Interrupt to abort . . .");
if (!testEnv.noProfile)
{
var cycles = debugSession.clock.runBenchmark();
}
else
{
printTrace("Call: debugSession.target.run()");
debugSession.target.run();
}
}
else
{
printTrace("Call: debugSession.target.runAsynch();");
debugSession.target.runAsynch();
}
}
}
catch (ex)
{
//ex.javaException.printStackTrace();
printTrace("\nERROR: Ex called!");
errCode = getErrorCode(ex);
if (errCode == 1001)
{
printTrace(">> OVERALL TIMED OUT");
debugSession.target.halt();
}
else
{
dssScriptEnv.traceWrite("Error code #" + errCode +
", error encountered during program execution!\nAborting!");
quit(errCode != 0 ? errCode : 1);
}
}
if (testEnv.cioFile != null && !testEnv.asyncRun)
{
// Stop CIO logging.
debugSession.endCIOLogging();
}
// Set script timeout value to default.
dssScriptEnv.setScriptTimeout(defaultTimeout);
if (!testEnv.asyncRun && !testEnv.noProfile)
{
// Print cycle counts unless script timout occured on program execution.
if (errCode != 1001)
{
printTrace("NORMAL COMPLETION: " + cycles + " cycles");
}
}
}
// Save data from target memory to a file on the host (if applicable).
if ((testEnv.saveRaw.length > 0) || (testEnv.saveDat.length > 0))
{
// Only dump data if it is not a asynchronous run.
if (!testEnv.asyncRun)
{
printTrace("Saving data to file...");
errCode = memSave(dssScriptEnv, debugSession, testEnv.saveRaw, testEnv.saveDat);
if (errCode != 0)
{
printTrace("Memory save failed with errCode: " + errCode);
retVal = errCode;
}
else
{
printTrace("Done");
}
}
else
{
printTrace("Memory save options are not supported with an asynchronous run!");
}
}
}
// End automation.
quit(retVal);
}
Now it seems like that the restart() does not work correct.
* Is there a possiblity to check after restart() where the program counter of target is?
* Is there a possiblity to check if the breakpoint is on main()?
* Is there a possiblity to modify the program counter?
Thanks in advance
Matthias Krüßelin