// Import the DSS packages into our namespace 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 Servers and Sessions var script = ScriptingEnvironment.instance(); // Create a log file script.traceBegin(LOG_FILE, LOG_FILE_STYLESHEET); // Specifies the max time to wait for underlying calls to the DebugServer to return. script.setScriptTimeout(60000); // Log everything to console script.traceSetConsoleLevel(TraceLevel.ALL); // Log INFO level and above up to SEVERE to log file which includes traceWrite outputs script.traceSetFileLevel(TraceLevel.INFO); // Get the Debug Server and start a Debug Session var debugServer = script.getServer("DebugServer.1"); // Launch selected configuration debugServer.setConfig(TARGET_CONFIGURATION_FILE); // Open a debug session script.traceWrite("Open debug session ... "); var debugSession = debugServer.openSession(EMULATOR); // Connect to target CPU script.traceWrite("Connecting to " + EMULATOR + " ..."); debugSession.target.connect(); var bp_startup; var properties_startup; var bp_boot; var properties_boot; var bp_ofp; var properties_ofp; var nPC; var nResult; // The Start Of Memory Addresses for each of the CSCIs var STARTUP_SOMA = 0x08000000; var BOOT_SOMA = 0x40300000; var OFP_SOMA = 0x80000000; // Set a hardware breakpoint at the start of STARTUP memory script.traceWrite("Set hardware breakpoint at start of STARTUP memory ..."); properties_startup = debugSession.breakpoint.createProperties(1); properties_startup.setString("Hardware Configuration.Type", "Breakpoint"); properties_startup.setString("Hardware Configuration.Type.Location", "0x08000000"); properties_startup.setString("Hardware Configuration.Type.Access Mode", "Any"); bp_startup = debugSession.breakpoint.add(properties_startup); // Set a hardware breakpoint at the start of BOOT memory script.traceWrite("Set hardware breakpoint at start of BOOT memory ..."); properties_boot = debugSession.breakpoint.createProperties(1); properties_boot.setString("Hardware Configuration.Type", "Breakpoint"); properties_boot.setString("Hardware Configuration.Type.Location", "0x40300000"); properties_boot.setString("Hardware Configuration.Type.Access Mode", "Any"); bp_boot = debugSession.breakpoint.add(properties_boot); // Set a hardware breakpoint at the start of OFP memory script.traceWrite("Set hardware breakpoint at start of OFP memory ..."); properties_ofp = debugSession.breakpoint.createProperties(1); properties_ofp.setString("Hardware Configuration.Type", "Breakpoint"); properties_ofp.setString("Hardware Configuration.Type.Location", "0x80000000"); properties_ofp.setString("Hardware Configuration.Type.Access Mode", "Any"); bp_ofp = debugSession.breakpoint.add(properties_ofp); // Reset the target //debugSession.target.reset(); script.traceWrite("System Reset ..."); nResult = debugSession.expression.evaluate("GEL_AdvancedReset(\"System Reset\")"); nPC = debugSession.expression.evaluate("PC"); if (nPC != STARTUP_SOMA) { // Not at the start of STARTUP when we would expect it to be. outcome = "FAIL"; script.traceWrite("FAIL: Expected halt at start of STARTUP 0x" + Long.toHexString(STARTUP_SOMA) + ", actually halted at 0x" + Long.toHexString(nPC)); } else { // Halted at start of STARTUP if (CSCI_UNDER_TEST == "STARTUP") { script.traceWrite("Halted at 0x" + Long.toHexString(nPC)); script.traceWrite("Loading symbols for STARTUP ..."); debugSession.symbol.load(STARTUP_OUT_FILE); symbols_loaded = true; } else { // Run on to BOOT debugSession.target.run(); nPC = debugSession.expression.evaluate("PC"); if (nPC != BOOT_SOMA) { // Not at the start of BOOT when we would expect it to be. outcome = "FAIL"; script.traceWrite("FAIL: Expected halt at start of BOOT 0x" + Long.toHexString(BOOT_SOMA) + ", actually halted at 0x" + Long.toHexString(nPC)); } else { // Halted at start of BOOT if (CSCI_UNDER_TEST == "BOOT") { script.traceWrite("Halted at 0x" + Long.toHexString(nPC)); script.traceWrite("Loading symbols for BOOT ..."); debugSession.symbol.load(BOOT_OUT_FILE); symbols_loaded = true; } else { // Run on to OFP debugSession.target.run(); nPC = debugSession.expression.evaluate("PC"); if (nPC != OFP_SOMA) { // Not at the start of OFP when we would expect it to be. outcome = "FAIL"; script.traceWrite("FAIL: Expected halt at start of OFP 0x" + Long.toHexString(OFP_SOMA) + ", actually halted at 0x" + Long.toHexString(nPC)); } else { // Halted at start of OFP if (CSCI_UNDER_TEST == "OFP") { script.traceWrite("Halted at 0x" + Long.toHexString(nPC)); script.traceWrite("Loading symbols for OFP ..."); debugSession.symbol.load(OFP_OUT_FILE); symbols_loaded = true; } else { outcome = "FAIL"; script.traceWrite("FAIL: Script did not halt at chosen CSCI's start of memory"); } } } } } } debugSession.breakpoint.removeAll();