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.

about DVT scripting

Other Parts Discussed in Thread: CCSTUDIO

Hi:

We created a javescript to simulator "PC trace" on our tracepod , but didn't get the right result now. Anyone can help me ? thanks !

CCS version is 5.5.0,OS is window XP.

What we do in manually trigger was : Tools->Hardware Trace Analyzer-> PC Trace(set startaddress,buffer size in this view) , make code go into function of “startaddress” , then we can see the data in "trace viewer" and the exported csv was start from this address.

But we didn't get the same behavior when using scripts , the “trace viewer”was not waiting for buffer full and the exported csv was not started with right address .

 

Function:string

Disassembly:string

Program Address:uinteger:hex

Delta Cycles:ulong:decimal

Cycle:long:decimal

 

 

 

 

0

IdleMeterCalc(unsigned int, unsigned int *, unsigned int *)

8C6E         NOP           5

0xC15D260

5

0

IdleMeterCalc(unsigned int, unsigned int *, unsigned int *)

8C6E         NOP           5

0xC15D262

5

5

IdleMeterCalc(unsigned int, unsigned int *, unsigned int *)

8C6E         NOP           5

0xC15D264

5

10

IdleMeterCalc(unsigned int, unsigned int *, unsigned int *)

0C6E         NOP           1

0xC15D266

1

15

IdleMeterCalc(unsigned int, unsigned int *, unsigned int *)

00A40274         STW.D1T1      A1,*+A9[0]

0xC15D268

1

16

 

Below is cmd outputs:

getCurrentDirectory: ENTRY

getCurrentDirectory: RETURN C:\ti\ccsv5\ccs_base\scripting\examples\DVTExamples\

HardwareTraceAnalyzer\liveExamples

RETURN (com.ti.dvt.engine.scripting.DVTServer.start Wed May 20 10:06:02 CST 2015

)

getServer: RETURN com.ti.dvt.engine.scripting.DVTServer@78d4e6

########### Begin to open analysession!!!

########### Begin to set analysis!!!

########### Begin to run analysis!!!

JTRACE: GetConnectedCPUNames: channelServer = 31C67C18

######  set R&D parameter!!!

######  set R&D parameter over!!!

########### Begin to export data to csv!!!

********************************stop*******************************************

 

 

Below is our javescript:

importPackage(Packages.com.ti.debug.engine.scripting)

importPackage(Packages.com.ti.ccstudio.scripting.environment)
importPackage(Packages.com.ti.dvt.engine.scripting)
importPackage(Packages.com.ti.dvt.analysis.traceviewer.activity)

importPackage(Packages.java.lang)
importPackage(Packages.java.io)
importPackage(Packages.java.util)

var data = {"configurationFile":"Nyquist.ccxml","logFile":"script_log.xml","portNumber":5000,"cpuName":"Spectrum Digital XDS560V2 STM USB Emulator_0/C66xx_2","outFile":"cpu3.out","receiverName":"Pro Trace","channelSetupFile":"TraceCntrl_DefaultSettings_ETB.xml","tracepodReadyFile":"trace.csv"};

// -------------------- local utilities --------------------

function Sleep(numberMillis) 
{
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) 
{
now = new Date();
if (now.getTime() > exitTime)
return;
}
}

function PC_Trace() {

// ---------- Start up ----------
script = ScriptingEnvironment.instance();
script.setScriptTimeout(240000);

// Create a log file in the current directory to log script execution
script.traceBegin("scriptLog.xml", "DefaultStylesheet.xsl");
script.traceSetConsoleLevel(TraceLevel.ALL);
script.traceSetFileLevel(TraceLevel.ALL);



cwd = script.getCurrentDirectory();

// ---------- Set up debugger ----------


debugServer = script.getServer("DebugServer.1");

debugServer.setConfig(data.configurationFile);

dsC66_0 = debugServer.openSession(data.cpuName); 
Sleep(5000);

dsC66_0.options.setBoolean("AllowInterruptsWhenHalted", true);
dsC66_0.options.setBoolean("PoliteRealtimeMode", true);

script.traceWrite("Connecting CPU");
dsC66_0.target.connect();
script.traceWrite("Loading out-File: " + data.outFile);
dsC66_0.symbol.load(data.outFile);

analysisSession = dvtServer.openAnalysisSession();

analysis = analysisSession.loadAnalysis("PC Trace");

script.traceWrite("########### Begin to set analysis!!!");

analysisSession.setAnalysisProperty(analysis, "transportType", "Pro Trace");

analysisSession.setAnalysisProperty(analysis, "startAddress", "0x0c12b300");
analysisSession.setAnalysisProperty(analysis, "bufferSize", "1 MB");
analysisSession.setAnalysisProperty(analysis, "numberOfPins", "10 pin");
analysisSession.setAnalysisProperty(analysis, "bufferType", "Stop-on-full");
analysisSession.setAnalysisProperty(analysis, "synchronizeWithTarget", true);

script.traceWrite("########### Begin to run analysis!!!");
//analysisSession.runAnalysis(analysis);
analysisSession.run(); 

// trigger function of address 0x0c12b300 here.

Sleep(20000); 


analysisSession.waitForEndOfData("TraceViewer#0/Trace Viewer");

script.traceWrite("########### Begin to export data to csv!!!");
analysisSession.exportDataToCSV("TraceViewer#0/Trace Viewer", cwd+"/"+"C66_0_PCTrace.csv", "Function,Disassembly,Program Address,Delta Cycles,Cycle,Trace Status");

analysisSession.endAnalysis(analysis);
debugServer.stop();
dvtServer.stop();
script.traceEnd();
}

// -------------------- Main --------------------

System.out.println("Start scripts.");

PC_Trace();

System.out.println("End scripts.");

 

 

  • Hello,

    yin alex said:
    var data = {"configurationFile":"Nyquist.ccxml","logFile":"script_log.xml","portNumber":5000,"cpuName":"Spectrum Digital XDS560V2 STM USB Emulator_0/C66xx_2","outFile":"cpu3.out","receiverName":"Pro Trace","channelSetupFile":"TraceCntrl_DefaultSettings_ETB.xml","tracepodReadyFile":"trace.csv"};

    You specified that you are using a xds560v2 STM emulator but also specified that you are using a Pro Trace receiver. Which exact emulator/receiver are you using?


    Thanks

    ki

  • Sorry for misunderstanging , We are using "Spectrum Digital XDS560V2 STM USB Emulator_0" .
  • Then I assume you are using the ETB?
  • Do you mean "transport type" ? We set is as ""transportType", "Pro Trace"" now, both in manual and scripting .
  • Unless I'm mistaken, you should be using "ETB" for transport type unless you are using the XDS560v2 PRO TRACE emulator/receiver (with proper pins on the target). I'll confirm this when I am in the office tomorrow

    ki

  • When you manually enable PC Trace via the GUI, is this the setting you are using?


    To use this setting, you need an XDS PRO TRACE receiver. Otherwise you get an error when trying to Start the trace session. Does this setting work for you?


    ki

  • Yes , both "Spectrum Digital XDS560V2 STM USB Emulator_0" and "Spectrum Digital XDSPRO USB Emulator_0" can work in manually enable "transport type".

    But I modify it to XDSPRO in scripts now maybe it's more reasonable . But we still can't get the expected csv .

    could you help check following script , I modify it form CCS DVT examples. thanks !

    importPackage(Packages.com.ti.debug.engine.scripting)
    importPackage(Packages.com.ti.ccstudio.scripting.environment)
    importPackage(Packages.com.ti.dvt.engine.scripting)
    importPackage(Packages.java.lang)
    importPackage(Packages.java.io)
    importPackage(Packages.java.util)


    // ---------- Start up ----------
    script = ScriptingEnvironment.instance();
    //script.setScriptTimeout(240000);

    // Create a log file in the current directory to log script execution
    script.traceBegin("scriptLog.xml", "../../DefaultStylesheet.xsl");
    script.traceSetConsoleLevel(TraceLevel.INFO);
    script.traceSetFileLevel(TraceLevel.INFO);

    script.traceWrite("PC Trace C660 Example");

    // ---------- Set up debugger ----------
    script.traceWrite("Launching debugger");
    debugServer = script.getServer("DebugServer.1");
    debugServer.setConfig("pro.ccxml");
    dsC66_0 = debugServer.openSession("Spectrum Digital XDSPRO USB Emulator_0/C66xx_2");


    dsC66_0.options.setBoolean("AllowInterruptsWhenHalted", true);
    dsC66_0.options.setBoolean("PoliteRealtimeMode", true);

    script.traceWrite("Connecting CPU");
    dsC66_0.target.connect();

    script.traceWrite("Loading program");
    dsC66_0.symbol.load("cpu3.out");

    // ---------- Create a DVT server ----------
    dvtServer = script.getServer("DVTServer.1");

    // ---------- Set up the analysis for PC Trace using ----------
    script.traceWrite("Setting up PC Trace");
    analysisSession = dvtServer.openAnalysisSession();

    analysisConfig = analysisSession.loadAnalysis("PC Trace");


    analysisConfig.setProperty("cpu", "Spectrum Digital XDSPRO USB Emulator_0/C66xx_2");
    //analysisConfig.setProperty("receiver", "Pro_Trace");
    analysisConfig.setProperty("transportType", "Pro Trace");
    analysisConfig.setProperty("startAddress", "0xc12b300");
    analysisConfig.setProperty("bufferSize", "1 MB");
    analysisConfig.setProperty("numberOfPins", "10 pin");
    analysisConfig.setProperty("bufferType", "Stop-on-full");
    analysisConfig.setProperty("synchronizeWithTarget", true);
    analysisConfig.setProperty("merge", true);
    analysisConfig.run();

    //---------- Run target for 2 secs ----------
    script.traceWrite("Running target");
    dsC66_0.target.runAsynch();
    Thread.sleep(2000);
    //dsC66_0.target.halt();

    // ---------- Wait until processing is done ----------
    script.traceWrite("Processing");
    dataProvider = analysisConfig.findDataProviderByName("Trace Viewer");
    dataProvider.waitForEndOfData();


    // ---------- Post analysis - export the data to a CSV file ----------
    cwd = script.getCurrentDirectory();
    script.traceWrite("Exporting results to " + cwd);
    dataProvider.exportDataToCSV("Trace Viewer", cwd+"/"+"TraceLogs.csv", "Function,Disassembly,Program Address,Delta Cycles,Cycle,Trace Status");

    // ---------- shut down ----------
    script.traceWrite("Shutting down");
    analysisSession.endAnalysis(analysisConfig);
    debugServer.stop();
    dvtServer.stop();
    script.traceEnd();

  • Hi,Ki

    Our scripts can run now and csc data is right , the reason why we couldn't get expected data was some parameters set error in analysis.

    Anyway, thanks for your warm supports .  

    Brs

  • Good to hear that you solved the problem. Thank you for the update.