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 loadti with OMAPL138 (ARM9 core)

Other Parts Discussed in Thread: OMAP-L137, OMAP-L138, OMAPL138, CCSTUDIO

Hi,

Hoping I got the correct forum. Please let me know if there is a better place to post the following question.

I will split this into three questions.

Q1:
I am trying to run code to program flash device on our hardware with u-boot. I want to do this without using CCS GUI. First step, I have tried is using the "Scripting Console". This is the command I use

 args=["program_name"];ccxmlFile="C:/OMAPL138_XDS510.ccxml";app="C:/ti/DaVinci-PSP-SDK-03.22.00.02/host-tools/OMAP-L138_FlashAndBootUtils_2_40/OMAP-L138/CCS/SPIWriter/ARM/SPIWriter_OMAP-L137.out";core="Spectrum Digital XDS510USB Emulator_0/ARM9_0";ds.setConfig(ccxmlFile);mySession=ds.openSession(core);mySession.target.connect();mySession.memory.loadProgram(app, args);

A couple of issues I am seeking help for here

1. After the program loads, if I try to run it (using F8), it just hits exit without actually giving me the prompt to specify the u-boot file to flash. But, if I single step it, the program works properly. Any ideas?

2. If I use the CCS GUI to connect to the target and load code, the loader stops at main.c. But, if I use the scripting method above, the loader stops at boot.asm. Why the difference? From CCS GUI, I can hit F8 after loading and it works properly every time.

An additional question here

I need to run the SPI1 Pinmux script for flash programming. How can I run that from Debug Server Scripting?

Q2:

Eventually I want to modify the flashing program so that it can take command line arguments and I can use loadti to be able to run from command line without user interaction. When I tried loadti, it seems like the program was trying to load the .out to C6748 and it failed complaining that the image format is wrong. How can I specify in loadti that the code needs to be loaded to the ARM9 core? Do I have to modify main.js?

Q3:

Can I use the XDS100v2 emulator with OMAPL138 and run the above scripts (using loadti)? I have only tried with SD XDS 510 till now, but would like to use XDS100v2. Do you have any data on how long it would take to program an SPI flash (about 256 KB of code - 4 sectors) using loadti and XDS100v2?

Thanks,

-raja.

  • Hi raja,

    I will do my best to answer the questions that I have answer for:

    Raja Subramanian said:
    1. After the program loads, if I try to run it (using F8), it just hits exit without actually giving me the prompt to specify the u-boot file to flash. But, if I single step it, the program works properly. Any ideas?

    That is odd. I don't have an answer for that.

    Raja Subramanian said:
    2. If I use the CCS GUI to connect to the target and load code, the loader stops at main.c. But, if I use the scripting method above, the loader stops at boot.asm. Why the difference? From CCS GUI, I can hit F8 after loading and it works properly every time.

    Normally, when loading a program, it will set the PC at the entry point of the program. However, if you are using the "Debug As" (bug) button to launch the debugger, the default is to load the program and auto-run to main. There is also a debugger option that you can set to auto-run to main every time. It is likely that the environment when scripting does not auto-run to main while via GUI, it is.

    Raja Subramanian said:
    I need to run the SPI1 Pinmux script for flash programming. How can I run that from Debug Server Scripting?

    Is this script a DSS javascript? Or a GEL file?

    Raja Subramanian said:
    Eventually I want to modify the flashing program so that it can take command line arguments and I can use loadti to be able to run from command line without user interaction. When I tried loadti, it seems like the program was trying to load the .out to C6748 and it failed complaining that the image format is wrong. How can I specify in loadti that the code needs to be loaded to the ARM9 core? Do I have to modify main.js?

    loadti does not handle multi-core environments by default. It will simply try to connect and load to the first core on the JTAG scan chain (which I think is the C674x on a L138). As you mentioned, you'll have to modify the loadti script to correctly handle multi-core environments

    Raja Subramanian said:
    Can I use the XDS100v2 emulator with OMAPL138 and run the above scripts (using loadti)? I have only tried with SD XDS 510 till now, but would like to use XDS100v2.

    Sure. loadti supports any emulator that CCS does. loadti interfaces to the same debug engine as CCS.

    Raja Subramanian said:
    Do you have any data on how long it would take to program an SPI flash (about 256 KB of code - 4 sectors) using loadti and XDS100v2?

    It will take the same time as doing it in CCS. As for how long in CCS, I do not know.

    Thanks

    ki

  • Thank you very much. I have interspersed more notes below.

    Ki-Soo Lee said:

    Hi raja,

    I will do my best to answer the questions that I have answer for:

    1. After the program loads, if I try to run it (using F8), it just hits exit without actually giving me the prompt to specify the u-boot file to flash. But, if I single step it, the program works properly. Any ideas?

    That is odd. I don't have an answer for that.

    Raja Subramanian said:
    2. If I use the CCS GUI to connect to the target and load code, the loader stops at main.c. But, if I use the scripting method above, the loader stops at boot.asm. Why the difference? From CCS GUI, I can hit F8 after loading and it works properly every time.

    Normally, when loading a program, it will set the PC at the entry point of the program. However, if you are using the "Debug As" (bug) button to launch the debugger, the default is to load the program and auto-run to main. There is also a debugger option that you can set to auto-run to main every time. It is likely that the environment when scripting does not auto-run to main while via GUI, it is.

    I am not using "Debug As". I do Ctrl+Alt+L to load the program. That is what gets the program to main(). Maybe, that is equivalent to "Debug As"?

    Raja Subramanian said:
    I need to run the SPI1 Pinmux script for flash programming. How can I run that from Debug Server Scripting?

    Is this script a DSS javascript? Or a GEL file?

    This is in the GEL file. It shows up in the  Scripts drop down in CCS GUI. Maybe, I just have to add this to the connect function in the GEL file?

    Raja Subramanian said:
    Eventually I want to modify the flashing program so that it can take command line arguments and I can use loadti to be able to run from command line without user interaction. When I tried loadti, it seems like the program was trying to load the .out to C6748 and it failed complaining that the image format is wrong. How can I specify in loadti that the code needs to be loaded to the ARM9 core? Do I have to modify main.js?

    loadti does not handle multi-core environments by default. It will simply try to connect and load to the first core on the JTAG scan chain (which I think is the C674x on a L138). As you mentioned, you'll have to modify the loadti script to correctly handle multi-core environments

    So, I tried modifying main.js to open a session with the proper core. It seemed to be happy to load the code just one time. Even that time, the whole process failed as loadti complained about not being able to set breakpoint . Output below

    Loading C:/ti/DaVinci-PSP-SDK-03.22.00.02/host-tools/OMAP-L138_FlashAndBootUtils_2_40/OMAP-L138/CCS/SPIWriter/ARM/SPIWriter_OMAP-L137.out
    WARNING: ARM9_0: Breakpoint Manager: Retrying with a AET breakpoint

    SEVERE: ARM9_0: Trouble Setting Breakpoint with the Action "Process CIO" at 0x80007054: Error 0x00000008/-1066 Error during: Break Point, Cannot set/verify breakpoint at 0x80007054

    WARNING: ARM9_0: Breakpoint Manager: Retrying with a AET breakpoint

    SEVERE: ARM9_0: Trouble Setting Breakpoint with the Action "Finish Auto Run" at 0x800032cc: Error 0x00000008/-1066 Error during: Break Point, Cannot set/verify breakpoint at 0x800032CC

    SEVERE: ARM9_0: Trouble Setting Breakpoint with the Action "Terminate Program Execution" at 0x80007250: Error 0x00000008/-1066 Error during: Break Point, Cannot set/verify breakpoint at 0x80007250

    After this attempt, I could not get past initializing the emulator at all. Gets a Java exception. Here is the output. I have tried everything from power cycling the board and power cycling the emulator, power cycling both, but  every time I get the following exception.

    ***** DSS Generic Loader *****

    START: 13:54:14 GMT-0700 (PDT)

    Configuring Debug Server for specified target...
    Done
    SEVERE: ICEPICK_C: Error initializing emulator

    SEVERE: Could not start server: DebugServer.1: ICEPICK_C: Error initializing emulator

    org.mozilla.javascript.WrappedException: Wrapped com.ti.ccstudio.scripting.environment.ScriptingException: Could not start server: DebugServer.1: ICEPICK_C: Error initializing emulator
    (C:\ti\ccsv5.3\ccsv5\ccs_base\scripting\examples\loadti\main.js#165)
    at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1705)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:157)
    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:201)
    at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:64)
    at org.mozilla.javascript.gen.c1._c4(C:\ti\ccsv5.3\ccsv5\ccs_base\scripting\examples\loadti\main.js:165)
    at org.mozilla.javascript.gen.c1.call(C:\ti\ccsv5.3\ccsv5\ccs_base\scripting\examples\loadti\main.js)
    at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:106)
    at org.mozilla.javascript.gen.c1._c0(C:\ti\ccsv5.3\ccsv5\ccs_base\scripting\examples\loadti\main.js:9)
    at org.mozilla.javascript.gen.c1.call(C:\ti\ccsv5.3\ccsv5\ccs_base\scripting\examples\loadti\main.js)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
    at org.mozilla.javascript.gen.c1.call(C:\ti\ccsv5.3\ccsv5\ccs_base\scripting\examples\loadti\main.js)
    at org.mozilla.javascript.gen.c1.exec(C:\ti\ccsv5.3\ccsv5\ccs_base\scripting\examples\loadti\main.js)
    at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:500)
    at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:422)
    at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:388)
    at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:379)
    at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:176)
    at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:97)
    at org.mozilla.javascript.Context.call(Context.java:540)
    at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:447)
    at org.mozilla.javascript.tools.shell.Main.exec(Main.java:159)
    at org.mozilla.javascript.tools.shell.Main.main(Main.java:137)
    Caused by: com.ti.ccstudio.scripting.environment.ScriptingException: Could not start server: DebugServer.1: ICEPICK_C: Error initializing emulator

    at com.ti.debug.engine.scripting.DebugServer$SessionFactory.<init>(DebugServer.java:161)
    at com.ti.debug.engine.scripting.DebugServer.openSession(DebugServer.java:1128)
    at com.ti.debug.engine.scripting.DebugServer.openSession(DebugServer.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:142)
    ... 21 more

    Any ideas?

    Raja Subramanian said:
    Can I use the XDS100v2 emulator with OMAPL138 and run the above scripts (using loadti)? I have only tried with SD XDS 510 till now, but would like to use XDS100v2.

    Sure. loadti supports any emulator that CCS does. loadti interfaces to the same debug engine as CCS.

    Raja Subramanian said:
    Do you have any data on how long it would take to program an SPI flash (about 256 KB of code - 4 sectors) using loadti and XDS100v2?

    It will take the same time as doing it in CCS. As for how long in CCS, I do not know.

    Oh ok, I was hoping it would be at least a bit faster. But, there is still gain of doing it from command line in a production environment. But, I need to get the loadti variant working reliably.

    Thanks

    ki

    [/quote]

  • Raja Subramanian said:
    I am not using "Debug As". I do Ctrl+Alt+L to load the program. That is what gets the program to main(). Maybe, that is equivalent to "Debug As"?

    No, they are different. CTRL+ALT+L is simply the load program command. Go to Tools -> Debugger Options -> Auto Run and Launch Options and check the Auto Options to see if you have the run to 'main' symbol enabled on program load.

    Raja Subramanian said:
    This is in the GEL file. It shows up in the  Scripts drop down in CCS GUI. Maybe, I just have to add this to the connect function in the GEL file?

    You can use the DSS API expression.evaluate() API. That API can evaluate any GEL call, including 'GEL_LoadGel()' to load/run a GEL script and call any GEL function from a loaded GEL script.

    Raja Subramanian said:
    So, I tried modifying main.js to open a session with the proper core. It seemed to be happy to load the code just one time. Even that time, the whole process failed as loadti complained about not being able to set breakpoint . Output below

    You use case is a bit more complex than what most people use loadti for. You mention uboot, serial connections, etc. What exactly are you loading? uboot? and then have uboot run to handle the rest? Most people use loadti to load and run simple programs.

    Raja Subramanian said:
    Oh ok, I was hoping it would be at least a bit faster. But, there is still gain of doing it from command line in a production environment. But, I need to get the loadti variant working reliably.

    The only speed gain with loadti you would see is when you compare running loadti vs launching CCS from scratch. That would be much faster since there is no GUI overhead. But in terms of sheer emulation speed and flash programming speed, both loadti and CCS uses the same connections and flash algos.

    ki

  • Thank you Ki.

    Thank you for the confirmation about Ctrl+Alt+L. I do have it set to run to main in CCS in Auto Run and Launch options.

    To be clear, my application is very simple as well. I just want to run loadti to burn some code into SPI flash. That is all. I am using the SPIWriter application to do that. One of the bits of instruction for that is to run the SPI1 Pinmux script, but the code has worked even without that script running. But, I wanted to find out how to run the script. Is there some place I can find the complete DSS Javascript API I can use?

    Also, any ideas on the exception? It is extremely repeatable.

    Cheers,

    -raja.

  • Hi Ki,

    Found documentation of DS API under scripting docs. I will read through that.

    If you can help with the exception and any suggestions on how I can get past it, I will really appreciate it.

    Cheers,

    -raja.

  • You must have some C I/O in your program, which requires breakpoints set on the target. And CCS is having problems setting these breakpoints. loadti's functionality is very simple. Basically load and run. Do you see the same issues when you do everything via GUI?

  • Thank you Ki.

    I do have some file I/O in the program, but the exception seems to happening at connect time.

    SEVERE: ICEPICK_C: Error initializing emulator

    SEVERE: Could not start server: DebugServer.1: ICEPICK_C: Error initializing emulator

    Any ideas?

    Cheers,

    -raja.

  • Raja Subramanian said:
    I do have some file I/O in the program, but the exception seems to happening at connect time.

    Your error appears to be occurring after program load. Do you get the same error when doing manual steps via CCS GUI?

  • Thank you Ki.

    No I do not see the problem when using CCS GUI.

    Can you please elaborate how you determined that the error is happening after program load?

    According to backtrace shown below, the error is happening at line 166 of main.js

    SEVERE: ICEPICK_C: Error initializing emulator

    SEVERE: Could not start server: DebugServer.1: ICEPICK_C: Error initializing emulator

    org.mozilla.javascript.WrappedException: Wrapped com.ti.ccstudio.scripting.environment.ScriptingException: Could not start server: DebugServer.1: ICEPICK_C: Error initializing emulator
    (C:\ti\ccsv5.3\ccsv5\ccs_base\scripting\examples\loadti\main.js#166)

    My main.js looks like the one below. Line #166 is the first line I am cutting and pasting and the loadProgram happens after that

    debugSession = debugServer.openSession("*", "*");
    isDebugSession = true;

    //Set the default File IO folder
    debugSession.options.setString("FileIODefaultDirectory", testEnv.fileIOFolder);

    printTrace("TARGET: " + debugSession.getBoardName());

    printTrace("Connecting to target...");

    // Connect to target. If target is simulator or already connected, a warning will be reported.
    try
    {
    debugSession.target.connect();
    }
    catch (ex)
    {
    errCode = getErrorCode(ex);
    dssScriptEnv.traceWrite("Error code #" + errCode + ", could not connect to target!\nAborting!");
    quit(errCode != 0 ? errCode : 1);
    }

    if (testEnv.resetTarget)
    {
    printTrace("Resetting target...");

    // Reset target.
    try
    {
    debugSession.target.reset();
    }
    catch (ex)
    {
    errCode = getErrorCode(ex);
    dssScriptEnv.traceWrite("Error code #" + errCode + ", could reset target!\nAborting!");
    quit(errCode != 0 ? errCode : 1);
    }
    }

    // Load and run each program provided.
    java.lang.System.out.println("testEnv.outFiles: " + testEnv.outFiles);
    var st = new java.util.StringTokenizer(testEnv.outFiles, "+");
    while (st.hasMoreTokens())
    {
    var outFile = st.nextToken();

    var filePath = new java.io.File(outFile);
    var outFileName = filePath.getName();
    testEnv.argvArgs[0] = outFileName;

    printTrace("Loading " + outFile);

    // Load program and pass arguments to main (if applicable).
    try
    {
    if (testEnv.initBss)
    {
    debugSession.memory.setBssInitValue(testEnv.initBssValue);
    }

    if (testEnv.argvArgs.length < 2)
    {
    debugSession.memory.loadProgram(outFile);
    }
    else
    {
    debugSession.memory.loadProgram(outFile, testEnv.argvArgs);
    }
    }
    catch (ex)
    {
    errCode = getErrorCode(ex);
    printTrace("Error code #" + errCode + ", " + outFile + " load failed!\nAborting!");
    quit(errCode != 0 ? errCode : 1);
    }