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.

CCSTUDIO3: Reset is not happening when triggered using Jython script

Part Number: CCSTUDIO3
Other Parts Discussed in Thread: CCSTUDIO

Tool/software:

Hello Team,

I am trying to execute 'hello_world.out' using Jython script . I need to do reset using the script but its not getting set.

When done manually from GUI , Terminate -> Launch configuration -> reset -> run jython script -> output is seen.

Trying to do same process using Jython script , but i don't observe the logs shown below and output is not seen.

SCRIPT snippet details ->

debugServer = script.getServer("DebugServer.1")
debugServer.setConfig("AM62PX_XDS110.ccxml");
debugSession = debugServer.openSession("Texas Instruments XDS110 USB Debug Probe_0/A53SS0_CORE0_0")
script.traceWrite("CONNECTING TARGET")

debugSession.target.connect()
debugSession.target.reset()
debugSession.terminate()
debugSession = debugServer.openSession("Texas Instruments XDS110 USB Debug Probe_0/A53SS0_CORE0_0")
debugSession.target.connect()

script.traceWrite("LOADING PROGRAM")

Logs details - Logs seen when reset is done from CCS GUI window. And then executed the script it works.

Starting NULL Bootloader ...

SYSFW Firmware Version 10.0.8--v10.00.08 (Fiery Fox)
SYSFW Firmware revision 0xa
SYSFW ABI revision 4.0

INFO: Bootloader_runCpu:176: CPU mcu-r5f is initialized to 800000000 Hz !!!
INFO: Bootloader_runCpu:176: CPU a530-0 is initialized to 1400000000 Hz !!!
INFO: Bootloader_runCpu:176: CPU a530-1 is initialized to 1400000000 Hz !!!
INFO: Bootloader_runCpu:176: CPU a531-0 is initialized to 1400000000 Hz !!!
INFO: Bootloader_runCpu:176: CPU a531-1 is initialized to 1400000000 Hz !!!
INFO: Bootloader_loadSelfCpu:229: CPU wkup-r5f is initialized to 800000000 Hz !!!
INFO: Bootloader_JumpSelfCpu:248: All done, jumping self ...

  • Hi Shriya,

    Can you clarify if you are not getting any output when running the script, or just no output associated with the reset that was issued?

    Thanks,

    Ricky

  • Hi Ricky,

    Note - I have figured out about "System reset" using DSS script, reset is working in my script but facing other challenges.

    Issue - 

    I am working on script to automate the process of -> Terminate -> Launch configuration -> System reset -> then load .out file -> get output -> Terminate -> stop session.

    When I configured my script to support this, its not working as I am not seeing output.

    So I manually did Terminate -> Launch configuration -> system reset from CCS GUI then executed my existing script, it worked and output could be seen.

    Using script I am facing issues, could you please help me in correcting my script - as shown below. Unable to figure out the exact error here.

    Script -

    from java.lang import *
    from java.util import *
    from com.ti.debug.engine.scripting import *
    from com.ti.ccstudio.scripting.environment import *
    import time
    import subprocess
    
    # Create our scripting environment object - which is the main entry point into any script and
    # the factory for creating other Scriptable Servers and Sessions
    script = ScriptingEnvironment.instance()
    
    # Create a log file in the current directory to log script execution
    script.traceBegin("BreakpointsTestLog_python.xml", "DefaultStylesheet.xsl")
    
    # Set our TimeOut
    script.setScriptTimeout(25000)
    
    # 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("AM62P.ccxml");
    debugSession = debugServer.openSession("Texas Instruments XDS110 USB Debug Probe/A53SS0_CORE0_0")
    script.traceWrite("CONNECTING TARGET")
    debugSession.target.connect()
    
    
    resetType = debugSession.target.getResetType(3)
    script.traceWrite("Going to issue reset: '" + resetType.getName() + "' (" + resetType.getDescription() + ")... ")
    resetType.issueReset();
    script.traceWrite("Done\n");
    
    
    script.traceWrite("LOADING PROGRAM")
    # 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("hello_world.debug.out")
    
    # Set a breakpoint
    address = debugSession.symbol.getAddress("main")
    bp = debugSession.breakpoint.add(address)
    script.traceWrite("Address of MAIN -".format(hex(address)))
    # Using an expression - get the current value of the PC
    
    nPC = debugSession.expression.evaluate("PC")
    script.traceWrite("Current halted at {}. This should be at the start of main().".format(hex(nPC)))
    
    # Run the target. Should halt at our breakpoint.
    debugSession.target.run()
    debugSession.target.waitForHalt();
    script.traceWrite("HALTING")
    
    nPC = debugSession.expression.evaluate("PC")
    
    #Verify we halted at the correct address.
    if (nPC == address):
        script.traceWrite("SUCCESS: Halted at correct location")
    else:
        script.traceWrite("FAIL: Expected halt at " + hex(address) + ", actually halted at " + hex(nPC))
        script.traceSetConsoleLevel(TraceLevel.INFO)
        script.traceWrite("TEST FAILED!")
        script.traceEnd()
        System.exit(1);
    
    
    #Get reset working
    resetType = debugSession.target.getResetType(3)
    script.traceWrite("Going to issue reset: '" + resetType.getName() + "' (" + resetType.getDescription() + ")... ")
    resetType.issueReset();
    script.traceWrite("Done\n");
    
    # All done
    debugSession.terminate()
    debugServer.stop()
    

    Error logs -

    LOADING PROGRAM
    loadProgram: ENTRY sFileName: hello_world.debug.out
    load: Requesting program load
    waitUntil: ENTRY timeout: 25000 (ms)
    SEVERE: A53SS0_CORE0_0: Trouble Halting Target CPU: (Error -2062 - (0:23:2)) Unable to halt device. Reset the device, and retry the operation. If error persists, confirm configuration, power-cycle the board, and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 20.0.0.3178)

    SEVERE: A53SS0_CORE0_0: Trouble Halting Target CPU: (Error -2062 - (0:23:2)) Unable to halt device. Reset the device, and retry the operation. If error persists, confirm configuration, power-cycle the board, and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 20.0.0.3178)

    SEVERE: A53SS0_CORE0_0: File Loader: Verification failed: Could not write 0x0000000080000000: execution state prevented access

    SEVERE: A53SS0_CORE0_0: GEL: File: /home/dinakar/ti/ccs1281/ccs/ccs_base/scripting/hello_world.debug.out: Load failed.

    waitUntil: RETURN
    SEVERE: File: /home/dinakar/ti/ccs1281/ccs/ccs_base/scripting/hello_world.debug.out: Load failed.
    SEVERE: Error loading "hello_world.debug.out": File: /home/dinakar/ti/ccs1281/ccs/ccs_base/scripting/hello_world.debug.out: Load failed.
    Traceback (most recent call last):
    File "trial.py", line 40, in <module>
    debugSession.memory.loadProgram("hello_world.debug.out")
    at com.ti.debug.engine.scripting.Memory.loadProgram(Memory.java:932)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    com.ti.ccstudio.scripting.environment.ScriptingException: com.ti.ccstudio.scripting.environment.ScriptingException: Error loading "hello_world.debug.out": File: /home/dinakar/ti/ccs1281/ccs/ccs_base/scripting/hello_world.debug.out: Load failed.

  • Hi Ricky,

    Could you help me with your comment on this post along with previous one. Let me know the corrections.

    Second observation -

    Modified script from previous one by commenting out the lines 30-33 

    from java.lang import *
    from java.util import *
    from com.ti.debug.engine.scripting import *
    from com.ti.ccstudio.scripting.environment import *
    import time
    import subprocess
    
    # Create our scripting environment object - which is the main entry point into any script and
    # the factory for creating other Scriptable Servers and Sessions
    script = ScriptingEnvironment.instance()
    
    # Create a log file in the current directory to log script execution
    script.traceBegin("BreakpointsTestLog_python.xml", "DefaultStylesheet.xsl")
    
    # Set our TimeOut
    script.setScriptTimeout(25000)
    
    # 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("AM62P.ccxml");
    debugSession = debugServer.openSession("Texas Instruments XDS110 USB Debug Probe/A53SS0_CORE0_0")
    script.traceWrite("CONNECTING TARGET")
    debugSession.target.connect()
    
    
    #resetType = debugSession.target.getResetType(3)
    #script.traceWrite("Going to issue reset: '" + resetType.getName() + "' (" + resetType.getDescription() + ")... ")
    #resetType.issueReset();
    #script.traceWrite("Done\n");
    
    
    script.traceWrite("LOADING PROGRAM")
    # 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("hello_world.debug.out")
    
    # Set a breakpoint
    address = debugSession.symbol.getAddress("main")
    bp = debugSession.breakpoint.add(address)
    script.traceWrite("Address of MAIN -".format(hex(address)))
    # Using an expression - get the current value of the PC
    
    nPC = debugSession.expression.evaluate("PC")
    script.traceWrite("Current halted at {}. This should be at the start of main().".format(hex(nPC)))
    
    # Run the target. Should halt at our breakpoint.
    debugSession.target.run()
    #debugSession.target.waitForHalt();
    script.traceWrite("HALTING")
    
    nPC = debugSession.expression.evaluate("PC")
    
    #Verify we halted at the correct address.
    if (nPC == address):
        script.traceWrite("SUCCESS: Halted at correct location")
    else:
        script.traceWrite("FAIL: Expected halt at " + hex(address) + ", actually halted at " + hex(nPC))
        script.traceSetConsoleLevel(TraceLevel.INFO)
        script.traceWrite("TEST FAILED!")
        script.traceEnd()
        System.exit(1);
    
    
    #Get reset working
    resetType = debugSession.target.getResetType(3)
    script.traceWrite("Going to issue reset: '" + resetType.getName() + "' (" + resetType.getDescription() + ")... ")
    resetType.issueReset();
    script.traceWrite("Done\n");
    
    # All done
    debugSession.terminate()
    debugServer.stop()
    
    

    Manually from CCS GUI window -> Terminate + Launch + System reset -> Trigger the above script.

    Output - seen on serial port terminal

    Logs -

    getAddress: RETURN 0x80000bd8
    add: ENTRY nAddress: 2147486680
    add: Getting breakpoint manager
    add: Assigning address location
    createAtLocation: Creating new breakpoint
    addAndEnable: Adding breakpoint
    addAndEnable: Enabling breakpoint
    add: RETURN 52
    Address of MAIN -
    evaluate: ENTRY sExpression: PC
    eval: Requesting evaluation of expression: "PC"
    isConnected: ENTRY
    isConnected: Target is connected
    isConnected: RETURN true
    isHalted: ENTRY
    isHalted: Target is halted
    isHalted: RETURN true
    waitUntil: ENTRY com.ti.ccstudio.scripting.environment.ScriptingEnvironment@11b5f4e2 timeout: 25000 (ms)
    waitUntil: RETURN com.ti.ccstudio.scripting.environment.ScriptingEnvironment@11b5f4e2
    waitUntil: ENTRY timeout: 25000 (ms)
    onEvent: Evaluated expression: PC
    waitUntil: RETURN
    evaluate: RETURN 0x80000bd8
    Current halted at 0x80000bd8L. This should be at the start of main().
    run: ENTRY
    go: Requesting target execution
    waitUntil: ENTRY timeout: 25000 (ms)
    SEVERE: Timed out after 25000ms
    SEVERE: com.ti.debug.engine.scripting.Target.run(): Timed out after 25000ms
    Traceback (most recent call last):
    File "trial.py", line 53, in <module>
    debugSession.target.run()
    at com.ti.debug.engine.scripting.ExecutionOperation.go(ExecutionOperation.java:68)
    at com.ti.debug.engine.scripting.Target.run(Target.java:818)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    com.ti.ccstudio.scripting.environment.ScriptingException: com.ti.ccstudio.scripting.environment.ScriptingException: com.ti.debug.engine.scripting.Target.run(): Timed out after 25000ms

    Thanks,

    Shriya

  • waitUntil: ENTRY timeout: 25000 (ms)
    SEVERE: Timed out after 25000ms
    SEVERE: com.ti.debug.engine.scripting.Target.run(): Timed out after 25000ms

    You have the script timeout set to 25 seconds.

    target.run() is a blocking call. It will block until the target halts or if the script timeout is triggered. The latter is happening here - After 25 seconds the timeout is triggered and an exception is thrown. It looks like the breakpoint set an main (0x80000bd8) is not being reached, hence the timeout occurs. Assuming your program has a valid main that is not being reached, then it looks like the program is not executing correctly. Perhaps the system reset is needed to put the target in a good state.

    If you power cycle the target and then run your script as-is, does it work (reach main)?

  • Thanks Ki. 

    Yes exactly, I changed .out file , added system reset at the beginning of the script and script has halted at the exact breakpoint .