// 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) // Create our scripting environment object - which is the main entry point into any script and // the factory for creating other Scriptable ervers and Sessions var script = ScriptingEnvironment.instance() // Create a log file in the current directory to log script execution script.traceBegin("TestLog.xml", "DefaultStylesheet.xsl") // Set our TimeOut script.setScriptTimeout(20000) // Log everything script.traceSetConsoleLevel(TraceLevel.ALL) script.traceSetFileLevel(TraceLevel.ALL) // Get the Debug Server and start a Debug Session debugServer = script.getServer("DebugServer.1") debugServer.setConfig(arguments[0]); debugSession = debugServer.openSession(arguments[3], arguments[4]) //debugSession = debugServer.openSession("Texas Instruments XDS110 USB Debug Probe","CortexR5") debugSession.target.connect(); // Load a program // (ScriptingEnvironment has a concept of a working folder and for all of the APIs which take // path names as arguments you can either pass a relative path or an absolute path) debugSession.memory.loadProgram(arguments[1]) var func3 = debugSession.symbol.getAddress("main") // Set Memory Page var Memory_Page = arguments[5]; switch(Memory_Page){ case "Memory.Page.DATA" : Memory_Page = Memory.Page.DATA; break; case "Memory.Page.DATA_BYTE" : Memory_Page = Memory.Page.DATA_BYTE; break; case "Memory.Page.IO" : Memory_Page = Memory.Page.IO; break; case "Memory.Page.IO_BYTE" : Memory_Page = Memory.Page.IO_BYTE; break; case "PROGRAM" : Memory_Page = PROGRAM; break; default : Memory_Page = NONE; } // Restart our Target debugSession.target.restart() debugSession.breakpoint.removeAll() // Set another breakpoint //var func = debugSession.symbol.getAddress("cs_write_log") //var bp1 = debugSession.breakpoint.add(func) //var func = debugSession.symbol.getAddress("cs_io_putbyte") //func = func + 0xE //var bp1 = debugSession.breakpoint.add(func) var bp1 = debugSession.breakpoint.add("cs_io_implementation.c", 32); var func2 = debugSession.symbol.getAddress("main") func2 = func2 + 0x2 var bp2 = debugSession.breakpoint.add(func2) var buf = debugSession.symbol.getAddress("ct_target_log") var index = debugSession.expression.evaluate("ct_index") // Run if already not automatically halted at main. Should halt at first BP debugSession.target.run() // Using an expression - get the current value of the PC nn = debugSession.expression.evaluate("PC") while (nn != func2 ) { debugSession.memory.saveData2(buf, Memory_Page, 5, arguments[2], arguments[6], true); debugSession.target.run() nn = debugSession.expression.evaluate("PC") } debugSession.memory.saveData2(buf, Memory_Page, 5, arguments[2], arguments[6], true); // All done debugSession.target.disconnect(); debugSession.terminate() debugServer.stop() script.traceSetConsoleLevel(TraceLevel.INFO) script.traceWrite("TEST SUCCEEDED!") // Stop logging and exit. script.traceEnd() java.lang.System.exit(0)