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.

Using memory.readData() from scripting console

I am using CCS 5.0.3 scripting console in order to asynchronously (from the debugger point of view) read/write a c66xx's memory.  A javascript program is loaded via LoadJSfile and then invoked by calling its "main" when needed on the scripting console.  It simply opens a TCP socket over which a PC-based program issues read/write requests (which is what makes it "asynchronous" to the debug session).

The following is the function that is used to read the memory:

function MemRead(addr, wordSize, wordCnt)
{
    var result;
    var successful = 0;

    if (!activeDS.target.isHalted()){
        // This command halts the target in order to allow memory reads
        activeDS.target.halt();
    }
    
    while (! successful) {
       try {
         result = activeDS.memory.readData(0, addr, wordSize * 8, wordCnt);
         successful = 1;
       }
       catch(err)
       {
         print ("Memory read failed.  sleep and retry");
         java.lang.Thread.sleep(1000);
       }
    }
    return result;
}

Everything works well if the debug session is idle.  However, if the C66xx is single stepped, eventually the activeDS.memory.readData() will fail catastrophically while logging the following error to the scripting console.

Error reading memory: Errors during memory.readData(): Address: 0x######## :Error: 0x2000000

Note that I have both "Halt the target before any debugger access (will impact servicing of interrupts" enabled in the generic debugger options, and have the programmatic halt activeDS.target.halt() in MemRead to no avail.

This causes the tcp server running in the  scripting console to terminate, which seriously breaks the program connected via tcp.  Obviously, the try/catch doesn't work.

  1. What does error 0x2000000 mean? (I blanked out the address, it is a valid, readable address that varies among the addresses the tcp application might read)
  2. Is there anything other than try/catch that could prevent catastrophic termination?  Retrying the read is fine, the tcp application won't care.

  • Hi John

    John Dowdal said:
    It simply opens a TCP socket over which a PC-based program issues read/write requests (which is what makes it "asynchronous" to the debug session).

    Is this functionality based off the DSS Test Server example?

    John Dowdal said:
    Everything works well if the debug session is idle.  However, if the C66xx is single stepped, eventually the activeDS.memory.readData() will fail catastrophically while logging the following error to the scripting console.

    I cannot reproduce the issue which a simple script that does a memory.readData(). There must be something else specific to your script/environment that is causing the issue. Can you try simplifying your test case so that your script simply does the memory.readData() call?

    Thanks

    ki

  • I tried using the simple example below which uses a delay between reads.  When single stepping, the try/catch "works" and retries the read when using either 0x800000 or the actual addresses used by the script that is failing.

    What does the Error: 0x2000000  mean? 

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

    function MemRead(addr, wordSize, wordCnt)
    {
        var result;
        var successful = 0;

        if (!activeDS.target.isHalted()){
            // This command halts the target in order to allow memory reads
            activeDS.target.halt();
        }
        
        while (! successful) {
           try {
             result = activeDS.memory.readData(0, addr, wordSize * 8, wordCnt);
             successful = 1;
           }
           catch(err)
           {
             print ("Memory read failed.  sleep and retry");
             java.lang.Thread.sleep(1000);
           }
        }
        return result;
    }

    function test_case ()
    {
       var i = 0;
       for (i=0; i < 100; i++)
       {
           print ("Iteration " + i );
           MemRead (0x800000, 4, 2048);
           java.lang.Thread.sleep(250);
       }
    }