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.

CCS 5.1: argument passing with DSS/LOADTI doesn't appear to work properly



I'm trying to use LOADTI to load and run a .out file for a C28x build
and pass it options on the command line. This is of course a C
project, and I've placed a 512-byte .args section into my linker
command file:

    --args=512
   .args            : > SHARED,     PAGE = 1

I modified main.js to emit the passed arguments (testEnv.argvArgs)
just before the call to loadProgram():

          print("****listing arguments for debugging...");
    n = 0;
          while (n < testEnv.argvArgs.length)
          {
              print("testEnv.argvArgs[" + n + "] = " + testEnv.argvArgs[n]);
              n++;
          }

   if (testEnv.argvArgs.length < 2)
   {
    debugSession.memory.loadProgram(outFile);
   }
   else
   {
    debugSession.memory.loadProgram(outFile, testEnv.argvArgs);
   }

and have verified they are correct:

  ****listing arguments for debugging...
  testEnv.argvArgs[0] = tst_PHY_cnvEncK4.out
  testEnv.argvArgs[1] = -i
  testEnv.argvArgs[2] = /cygdrive/y/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_PHY_cnvEncK4/inp/Ramp.u16
  testEnv.argvArgs[3] = -o
  testEnv.argvArgs[4] = /cygdrive/y/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_PHY_cnvEncK4/out/Ramp.u16
  Done
  Target running...

Then I had my .out program iterate through the command-line options
and print them out and they are out-of-order:

  argc = 5
  0: 1: tst_PHY_cnvEncK4.out
  2: 3: -i
  4:

So it appears there is something wrong in the loadProgram() method or one of its children.

Any help would be appreciated!


--Randy

 

 

  • randy.yates said:

      ****listing arguments for debugging...
      testEnv.argvArgs[0] = tst_PHY_cnvEncK4.out
      testEnv.argvArgs[1] = -i
      testEnv.argvArgs[2] = /cygdrive/y/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_PHY_cnvEncK4/inp/Ramp.u16
      testEnv.argvArgs[3] = -o
      testEnv.argvArgs[4] = /cygdrive/y/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_PHY_cnvEncK4/out/Ramp.u16
      Done
      Target running...

    Then I had my .out program iterate through the command-line options
    and print them out and they are out-of-order:

      argc = 5
      0: 1: tst_PHY_cnvEncK4.out
      2: 3: -i
      4:

    Not sure if they are out of order. It looks like the formatting is off.

    argc =5 would be correct. I am assuming you are printing the value of "argc" first

    argv[0] is the program name so "tst_PHY_cnvEncK4.out" is right

    argv[1] would be "-i" so that would be the next option displayed.

    The rest of the options just are not printed. What does your C code that does the printf in your outfile look like? And what is the command you are passing to loadti?

    In my loadti environment, everything looks fine (loadProgram correctly writing the argc and argv values)

    ki

     

  • Hi Ki-Soo,

    The .out file code which emitted this:

      argc = 5
        0: 1: tst_PHY_cnvEncK4.out
        2: 3: -i
        4:

    was this:

      printf("argc = %d\n", argc);
      for (n = 0; n < argc; n++)
      {
        printf("%d: %s\n", n, argv[n]);
      }

    The loadti command I was issuing was this:

    C:\ti\ccsv5\ccs_base\scripting\examples\loadti>loadti -c "C:\Documents and Settings\x0170761\user\CCSTargetConfigurations\F28M35x_c28_xds100v2.ccxml" -x test.xml "Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_PHY_cnvEncK4\driver\tst_PHY_cnvEncK4.out" -i /cygdrive/y/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_PHY_cnvEncK4/inp/Ramp.u16 -o /cygdrive/y/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_PHY_cnvEncK4/out/Ramp.u16

    > argv[0] is the program name so "tst_PHY_cnvEncK4.out" is right

    argv[0] is not the program name (i.e., the out_file, using my original
    post's nomenclature). The out_file name is placed into argv[1]. My
    code is seeing out_file as the first parameter and reporting it as an
    invalid parameter. the argv[0] looks like a null pointer or a pointer
    to the empty string. Similarly for argv[2] and argv[4].

    By the way, this exact same code runs perfectly when compiled using
    gcc to either a linux or cygwin executable.


    --Randy

  • Ki,

    I created a new .out file that was extremely simple:

        #include <stdlib.h>
        #include <stdint.h>
        #include <stdbool.h>
        #include <stdio.h>
        #include <string.h>
       
        int main(int argc, char* argv[])
        {
          uint16_t n;
       
          for (n = 0; n < argc; n++)
          {
            printf("argv[%d] = %s\n", n, argv[n]);
          }
          return 0;
        }

    I compiled it to the file named tst_loadti.out. I then ran it using
    the following command and got the following output:

        C:\ti\ccsv5\ccs_base\scripting\examples\loadti>loadti -c "C:\Documents and Settings\x0170761\user\CCSTargetConfigurations\F28M35x_c28_xds100v2.ccxml" -x test.xml Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_loadti\driver\tst_loadti.out -i Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_PHY_cnvEncK4\inp\Ram
        p.u16 -o Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_PHY_cnvEncK4\out\Ramp.u16
        length = 9
        arguments[0] = -c
        arguments[1] = C:\Documents and Settings\x0170761\user\CCSTargetConfigurations\F28M35x_c28_xds100v2.ccxml
        arguments[2] = -x
        arguments[3] = test.xml
        arguments[4] = Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_loadti\driver\tst_loadti.out
        arguments[5] = -i
        arguments[6] = Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_PHY_cnvEncK4\inp\Ramp.u16
        arguments[7] = -o
        arguments[8] = Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_PHY_cnvEncK4\out\Ramp.u16
       
        ***** DSS Generic Loader *****
       
        START: 14:25:19 GMT-0600 (CST)
       
        Configuring Debug Server for specified target...
        Done
        TARGET: Texas Instruments XDS100v2 USB Emulator_0
        Connecting to target...
        C28xx_0: GEL Output:
        Memory Map Initialization Complete
       
        C28xx_0: GEL Output:
        RAM Initialization Complete
       
        testEnv.outFiles: Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_loadti\driver\tst_loadti.out
        Loading Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_loadti\driver\tst_loadti.out
        ****listing arguments for debugging...
        testEnv.argvArgs[0] = tst_loadti.out
        testEnv.argvArgs[1] = -i
        testEnv.argvArgs[2] = Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_PHY_cnvEncK4\inp\Ramp.u16
        testEnv.argvArgs[3] = -o
        testEnv.argvArgs[4] = Y:\dspsrdc_csa\emeter\dsp_c28x\sun\tst\tst_PHY_cnvEncK4\out\Ramp.u16
        Done
        Target running...
        Interrupt to abort . . .
        argv[0] = argv[1] = tst_loadti.out
        argv[2] = argv[3] = -i
        argv[4] =

    As you can see, the problem with the arguments persist.

    Here is the linker command file I used:

        /* -*- c -*-  */
        -c
        --args=1024
        /*
        // TI File $Revision: /main/2 $
        // Checkin $Date: April 27, 2011   14:17:10 $
        //###########################################################################
        //
        // FILE:    28M35H52C1_RAM_lnk.cmd
        //
        // TITLE:   Linker Command File for F28M35H52C1 examples that run out of RAM
        //
        //          This ONLY includes all SARAM blocks on the F28M35H52C1 device.
        //          This does not include flash or OTP.
        //
        //          Keep in mind that L0 and L1 are protected by the code
        //          security module.
        //
        //          What this means is in most cases you will want to move to
        //          another memory map file which has more memory defined.
        //
        //###########################################################################
        // $TI Release:  $
        // $Release Date:  $
        //###########################################################################
        */
       
        /* ======================================================
        // In addition to this memory linker command file,
        // add the header linker command file directly to the project.
        // The header linker command file is required to link the
        // peripheral structures to the proper locations within
        // the memory map.
        //
        // The header linker files are found in <base>\F28M35x_headers\cmd
        //
        // For BIOS applications add:      F28M35x_Headers_BIOS.cmd
        // For nonBIOS applications add:   F28M35x_Headers_nonBIOS.cmd
        ========================================================= */
       
        /* Define the memory block start/length for the F28M35x
           PAGE 0 will be used to organize program sections
           PAGE 1 will be used to organize data sections
       
           Notes:
                 Memory blocks on F28M35x are uniform (ie same
                 physical memory) in both PAGE 0 and PAGE 1.
                 That is the same memory region should not be
                 defined for both PAGE 0 and PAGE 1.
                 Doing so will result in corruption of program
                 and/or data.
       
                 Contiguous SARAM memory blocks can be combined
                 if required to create a larger memory block.
        */
       
        MEMORY
        {
        PAGE 0 :
           /* BEGIN is used for the "boot to SARAM" bootloader mode   */
       
           BEGIN       : origin = 0x000000, length = 0x000002
           RAMM0       : origin = 0x000050, length = 0x0003B0     /* on-chip RAM block M0 */
           RAML0L1     : origin = 0x008000, length = 0x002000     /* on-chip RAM block L0, L1 */  
           
           RESET       : origin = 0x3FFFC0, length = 0x000002     /* Part of Boot ROM */
           FPUTABLES   : origin = 0x3FD258, length = 0x0006A0      /* FPU Tables in Boot ROM */
           IQTABLES    : origin = 0x3FD8F8, length = 0x000B50     /* IQ Math Tables in Boot ROM */
           IQTABLES2   : origin = 0x3FE448, length = 0x00008C     /* IQ Math Tables in Boot ROM */
           IQTABLES3   : origin = 0x3FE4D4, length = 0x0000AA      /* IQ Math Tables in Boot ROM */
       
           BOOTROM     : origin = 0x3FEDA8, length = 0x001200     /* Boot ROM */
       
       
        PAGE 1 :
       
           BOOT_RSVD   : origin = 0x000002, length = 0x00004E     /* Part of M0, BOOT rom will use this for stack */
           RAMM1       : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */
           RAML2       : origin = 0x00A000, length = 0x001000      /* on-chip RAM block L2 */
           RAML3       : origin = 0x00B000, length = 0x001000     /* on-chip RAM block L3 */
           SHARED      : origin = 0x00C000, length = 0x010000     /* on-chip Shared RAM block S0 */
           CTOMRAM     : origin = 0x03F800, length = 0x000380     /* C28 to M3 Message RAM */
           MTOCRAM     : origin = 0x03FC00, length = 0x000380     /* M3 to C28 Message RAM */
        }
       
       
        SECTIONS
        {
           /* Setup for "boot to SARAM" mode:
              The codestart section (found in DSP28_CodeStartBranch.asm)
              re-directs execution to the start of user code.  */
           codestart        : > BEGIN,      PAGE = 0
           ramfuncs         : > RAMM0       PAGE = 0
           .text            : > SHARED,     PAGE = 1
           .args            : > SHARED,     PAGE = 1
           .cinit           : > RAMM0,      PAGE = 0
           .pinit           : > RAMM0,      PAGE = 0
           .switch          : > RAMM0,      PAGE = 0
           .reset           : > RESET,      PAGE = 0, TYPE = DSECT /* not used, */
       
           .stack           : > RAML2,      PAGE = 1
           .ebss            : > RAML2,      PAGE = 1
           .econst          : > RAML2,      PAGE = 1
           .esysmem         : > RAML2,      PAGE = 1
       
           IQmath           : > RAML0L1,    PAGE = 0
           IQmathTables     : > IQTABLES,   PAGE = 0, TYPE = NOLOAD
          
           /* The following section definitions are required when using the IPC API Drivers */
           GROUP : > CTOMRAM, PAGE = 1
           {
               PUTBUFFER
               PUTWRITEIDX
               GETREADIDX
           }
       
           GROUP : > MTOCRAM, PAGE = 1
           {
               GETBUFFER :    TYPE = DSECT
               GETWRITEIDX :  TYPE = DSECT
               PUTREADIDX :   TYPE = DSECT
           }  
          
           /* Allocate FPU math areas: */
           FPUmathTables    : > FPUTABLES,  PAGE = 0, TYPE = NOLOAD
       
          /* Uncomment the section below if calling the IQNexp() or IQexp()
              functions from the IQMath.lib library in order to utilize the
              relevant IQ Math table in Boot ROM (This saves space and Boot ROM
              is 1 wait-state). If this section is not uncommented, IQmathTables2
              will be loaded into other memory (SARAM, Flash, etc.) and will take
              up space, but 0 wait-state is possible.
           */
           /*
           IQmathTables2    : > IQTABLES2,  PAGE = 0, TYPE = NOLOAD
           {
       
                      IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)
       
           }
           */
           /* Uncomment the section below if calling the IQNasin() or IQasin()
              functions from the IQMath.lib library in order to utilize the
              relevant IQ Math table in Boot ROM (This saves space and Boot ROM
              is 1 wait-state). If this section is not uncommented, IQmathTables2
              will be loaded into other memory (SARAM, Flash, etc.) and will take
              up space, but 0 wait-state is possible.
           */
           /*
           IQmathTables3    : > IQTABLES3,  PAGE = 0, TYPE = NOLOAD
           {
       
                      IQmath.lib<IQNasinTable.obj> (IQmathTablesRam)
       
           }
           */
       
        }
       
        /*
        //===========================================================================
        // End of file.
        //===========================================================================
        */
       


    It was built using the following commands:

        cl2000 -c /vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_loadti/driver/tst_loadti.c -g -v28 -dTARGET_DSP_28M35 -dPLATFORM_ -i/vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/dspbios/packages/ti/bios/include/ -i/vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/csl/include/ -i/vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/xdais/include/ -i/vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/xdais/src/api/ -i/vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/linux/c2000/cgtools/include/ -i/vobs/dspsrdc_csa/emeter/dsp_c28x/sun/inc/  -fr/tmp/x0170761/vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_loadti/driver/dsp-28m35linux -fs/tmp/x0170761/vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_loadti/driver/dsp-28m35linux -ft/tmp/x0170761/vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_loadti/driver/dsp-28m35linux 
        lnk2000 -I /vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/linux/c2000/cgtools/lib/  -I /vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/dspbios/packages/ti/bios/lib/  -I /vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/dspbios/packages/ti/rtdx/lib/c6000/  -I /vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/csl/lib_3x/  -I /vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/ddk/lib/  -I /vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tool/xdais/lib/ /tmp/x0170761/vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_loadti/driver/dsp-28m35linux/tst_loadti.obj /vobs/dspsrdc_csa/emeter/dsp_c28x/sun/etc/lnk-ram.cmd -o /vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_loadti/driver/tst_loadti.out -m /vobs/dspsrdc_csa/emeter/dsp_c28x/sun/tst/tst_loadti/driver/tst_loadti.map --library libc.a

    If you can try this on your system and see if you get the same results, I would appreciate it.

    --Randy

  • Or... if anyone else could try this and verify it's a problem, please let me know.

    -Randy Yates

    TI/Dallas/South Campus