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.

First calling UNIVERSAL_control() fails

 


Hello,

I would like to develop a codec using IUNIVERSAL interface (DM6446) and I have a problem.
I made an empty project using ti.xdais.wizards.genalg wizard.
The codec and the codec server built successfully (I think but I am not sure: I am new in Codec Engine/XDAIS/xDM development): codec server is compiled without errors and my codec is on codec list of Codec Engine's codec server (Engine_getNumAlgs and Engine_getAlgInfo functions).
In application the new codec created successfully using UNIVERSAL_create().
Firstly the first calling of UNIVERSAL_control() hangs.
I dug into sources and I found an issue in universal_skel.c files.
If I use UNIVERSAL_Status.data.numBufs=0 the universal_stub.c not clear (initialize) the fields of buffer descriptors.
The issue is in later on DSP side, in _UNIVERSAL_CCONTROL case of universal_skel.c call() function in the for loops.
    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
        if (outBufs.descs[i].buf != NULL) {
            Memory_cacheInv(outBufs.descs[i].buf, outBufs.descs[i].bufSize); // fails if UNIVERSAL_Status.data.numBufs==0 but the ptr!=NULL

It could be corrected in next release of Codec Engine using the followings for sentence:
    for (i = 0, numBufs = 0; (numBufs < outBufs.numBufs) && (i < XDM_MAX_IO_BUFFERS); i++) {
Remarks:
- I use previous release of Codec Engine (v2.26.01.09)
- The solution above is same as the vidanalytics_skel.c in Codec Engine v2.26.02.11: http://e2e.ti.com/support/embedded/f/354/p/64877/258060.aspx?PageIndex=1
- May be a bit more efficient solution could be the following:
    numBufs = (pStatus->data.numBufs > XDM_MAX_IO_BUFFERS) ? XDM_MAX_IO_BUFFERS:pStatus->data.numBufs;
    for (i=0; i<numBufs; ++i) {
        if (pStatus->data.descs[i].buf != NULL) {
            Memory_cacheInv(pStatus->data.descs[i].buf, pStatus->data.descs[i].bufSize);
        }
    }

There is a workaround In application side too: the whole UNIVERSAL_Status.data structure must be cleared (numBufs=XDM_MAX_IO_BUFFERS, and set all ptr=NULL, it is checked in universal_skel.c).
After that, the Codec Engine didn't hang (great!), but UNIVERSAL_control() still failed (returns -1).
(I tried to allocate a buffer in application and it is given to the UNIVERSAL_Status.data, but the result is the same.)
For test, I tried to return success return code immediately (IUNIVERSAL_EOK) in my codec's control function (so, the control function now does nothing), but the result is the same.

The softwares are running under WinCE6.
I wrote some GT trace messages into my codec to see it starts or not but I cannot found my GT lines in log (other GT messages are displayed):

  36204 PID:1260066 TID:522000a [DSP] @1,934,878tk: [+5 T:0x8fc06ae4 S:0x8fc08eac] CN - NODE> 0x8fc065f0(rotor#0) call(algHandle=0x8fc066b8, msg=0x8fe06c80); messageId=0x00020001
  36205 PID:1260066 TID:522000a [DSP] @1,934,966tk: [+0 T:0x8fc06ae4 S:0x8fc08bfc] OM - Memory_cacheInv> Enter(addr=0x887c0000, sizeInBytes=16384)
  36206 PID:1260066 TID:522000a [DSP] @1,935,045tk: [+0 T:0x8fc06ae4 S:0x8fc08bfc] OM - Memory_cacheInv> return
  36207 PID:1260066 TID:522000a [DSP] @1,935,087tk: [+0 T:0x8fc06ae4 S:0x8fc08bbc] ti.sdo.ce.universal.UNIVERSAL - UNIVERSAL_control> Enter (handle=0x8fc066b8, id=1, dynParams=0x8fe06cb4 (size=0x4), status=0x8fe06cb8 (size=0xcc)
  36208 PID:1260066 TID:522000a [DSP] @1,935,197tk: [+5 T:0x8fc06ae4 S:0x8fc08b9c] CV - VISA_enter(visa=0x8fc066b8): algHandle = 0x8fc066f0
  36209 PID:1260066 TID:522000a [DSP] @1,935,257tk: [+0 T:0x8fc06ae4 S:0x8fc08b7c] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Enter(alg=0x8fc066f0)
  36210 PID:1260066 TID:522000a [DSP] @1,935,323tk: [+0 T:0x8fc06ae4 S:0x8fc08b7c] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Exit
  36211 PID:1260066 TID:522000a [DSP] @1,935,379tk: [+5 T:0x8fc06ae4 S:0x8fc08b9c] CV - VISA_exit(visa=0x8fc066b8): algHandle = 0x8fc066f0
  36212 PID:1260066 TID:522000a [DSP] @1,935,438tk: [+0 T:0x8fc06ae4 S:0x8fc08b7c] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Enter(alg=0x8fc066f0)
  36213 PID:1260066 TID:522000a [DSP] @1,935,502tk: [+0 T:0x8fc06ae4 S:0x8fc08b7c] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Exit
  36214 PID:1260066 TID:522000a [DSP] @1,935,555tk: [+0 T:0x8fc06ae4 S:0x8fc08bbc] ti.sdo.ce.universal.UNIVERSAL - UNIVERSAL_control> Exit (handle=0x8fc066b8, retVal=0xffffffff)
  36237 PID:1260066 TID:522000a [DSP] @1,935,629tk: [+5 T:0x8fc06ae4 S:0x8fc08eac] CN - NODE> returned from call(algHandle=0x8fc066b8, msg=0x8fe06c80); messageId=0x00020001
  36237 PID:1260066 TID:522000a [DSP] @1,935,629tk: [+5 T:0x8fc06ae4 S:0x8fc08eac] CN - NODE> returned from call(algHandle=0x8fc066b8, msg=0x8fe06c80); messageId=0x00020001
  36238 PID:1260066 TID:522000a [DSP] @2,006,560tk: [+0 T:0x8fc01b2c S:0x8fc05aec] CR - processRmsCmd(0x8fe05ca8, 4056): cmd = 5
  36239 PID:1260066 TID:522000a [DSP] @2,006,616tk: [+0 T:0x8fc01b2c S:0x8fc05aec] CR - remote time = 0x0, trace buffer size = 4032
  36240 PID:1260066 TID:522000a @54,391,000us: [+0 T:0x0522000a S:0x1c01f460] CE - Engine_fwriteTrace> returning count [1684]
  36241 PID:1260066 TID:522000a @54,393,000us: [+0 T:0x0522000a S:0x1c01f52c] CV - VISA_call Completed: messageId=0x00020001, command=0x1, return(status=-1)
  36242 PID:1260066 TID:522000a @54,395,000us: [+5 T:0x0522000a S:0x1c01f548] CV - VISA_freeMsg(0x1c022560, 0x1c0b1c80): Freeing message with messageId=0x00020001
  36244 PID:1260066 TID:522000a @54,397,000us: [+0 T:0x0522000a S:0x1c01f628] ti.sdo.ce.universal.UNIVERSAL - UNIVERSAL_control> Exit (handle=0x1c022560, retVal=0xffffffff)
  36245 PID:1260066 TID:522000a @54,399,000us: [+0 T:0x0522000a S:0x1c01f6c8] ti.sdo.ce.universal.UNIVERSAL - UNIVERSAL_delete> Enter (handle=0x1c022560)

GT specific codes in my codec:

#define GTNAME "hexium.rotor.ROTOR"
GT_Mask gt_HEXIUM_ROTOR_curTrace = {NULL, NULL};
#define CURTRACE gt_HEXIUM_ROTOR_curTrace

Int ROTOR_HEXIUM_alloc(const IALG_Params *algParams, IALG_Fxns **pf, IALG_MemRec memTab[])
{
    Int nUsedBufs;
    static Bool fGTInit = FALSE;

    if (fGTInit != TRUE)
    {
        fGTInit = TRUE;
        GT_init();
        GT_create(&CURTRACE, GTNAME);
        GT_set(GTNAME "=01234567");
    }
    GT_4trace(CURTRACE, GT_ENTER, "ROTOR_HEXIUM_alloc> Enter: algParams=0x%08X, pf=0x%08X, *pf=0x%08X, memTab=0x%08X\n",
                                         algParams, pf, (pf == NULL)?0x00000000:*pf, memTab);
    /* Request memory for my object */
    nUsedBufs = 1;
    memTab[0].size = sizeof(ROTOR_HEXIUM_Obj);
    memTab[0].alignment = 0;
    memTab[0].space = IALG_EXTERNAL;
    memTab[0].attrs = IALG_PERSIST;
    GT_1trace(CURTRACE, GT_ENTER, "ROTOR_HEXIUM_alloc> Exit: retVal=0x%08X\n", nUsedBufs);

    return (nUsedBufs);
}
     
My questions is: How can I verify that my codec is
    -Built and packaged successfully?
    -Allocated, initialized and run properly on DSP?
    -Can log GT messages?

Thanks.
Peter

 

  • Peter,

    1. Sounds like the codec did get built and packaged successfully going by this:-  codec server is compiled without errors and my codec is on codec list of Codec Engine's codec       server (Engine_getNumAlgs and Engine_getAlgInfo functions).

    2. The issue you have raised, is indeed an issue, and we will be fixing it in the next release of Codec Engine (same fix as you have noted for VIDANALYTICS_skel). Your code           snippet where you suggest a more efficient solution is unlikely to work as the inBufs array can be "sparse". 

    3. Regarding your question about GT, it looks like all your code mods for enabling GT is all there (assuming you are including gt.h header file somewhere above). You have to           also make sure that following macros are defined when you build your codec:-

        -DGT_ASSERT=1 -DGT_TRACE=1

        These defines should be set to "1" to see trace .

    Regarding the issue you are seeing, instead of using the first workaround you suggest (clearing the data structure), let's just allocate 1 buffer (so that numBufs != 0) and in your codec's control function, comment out everything except the return statement.(IUNIVERSAL_EOK). Please share the trace that you get when you run this.

    Per the trace, it seems like we get to the UNIVERSAL_control on the DSP side and that function doesn't do much (that might fail) besides returning the output from the call to codec's control function. It would be good to double check that the codec isn't returning a bad status.

    Also could you let me know if you are running with checked set to "TRUE" ?

    Gunjan



  • Dear
    Gunjan,


    Thank you for your response.

    1.
    According to your suggestion, I give some compiler options to GT trace logs.
    Meanwhile, I realized that the codec's config.bld was missing.

    Altough, I can compile and package my codec successfully without config.bld, the codec won't work.
    Building with config.bld (with enabled GT options) my codec started (I really did not any modification in my other sources).

    Finally, I get GT messages and my codec's functions are working well too!
    Thank you for help!


    2.
    > Also could you let me know if you are running with 'checked' set to "TRUE" ?
    How can I set this "checked" flag?
    It is the VISA_checked flag which is generated by Settings.xdt based 'checked'?
    If yes: How can I set this flag in my project, because I found Settings.xdt in my Codec engine folder only.
    I wouldn't rebuild whole Codec Engine if it is not important...

     

    3.
    Your code snippet where you suggest a more efficient solution is unlikely to work as the inBufs array can be "sparse".

    Of course, in this case.

    I did not know
    that this way you can u
    se these buffers.

     

    4.
    > Regarding the issue you are seeing, instead of using the first workaround you suggest
    > (clearing the data structure), let's just allocate 1 buffer (so that numBufs != 0) and in your
    > codec's control function, comment out everything except the return statement.(IUNIVERSAL_EOK).
    > Please share the trace that you get when you run this.
    OK, you can found log messages at the end of my message.
    (I though: cache-management could be inefficient, but an empty cycle is really nothing...)


    Peter



    PS:
    Thanks for the Codec Engine's next release fixation.
    In my opinion, updating any software components in installed development platform (e.g. DVDSK) is a hard thing.
    As you now, there are many software components, which are validated by given other ones, which are validated by others, etc...
    So, I will this only after a full backup!!!




    1448695 PID:459000a TID:45a000a @1465,967,000us: [+0 T:0x045a000a S:0x1c01f628] ti.sdo.ce.universal.UNIVERSAL - UNIVERSAL_control> Enter (handle=0x1c0225c0, id=1, dynParams=0x1c02221c (size=0x20), status=0x1c02223c (size=0xd4)
    1448698 PID:459000a TID:45a000a @1465,971,000us: [+4 T:0x045a000a S:0x1c01f558] CV - VISA_getMaxMsgSize(0x1c0225c0): returning 0x1000
    1448699 PID:459000a TID:45a000a @1465,975,000us: [+5 T:0x045a000a S:0x1c01f550] CV - VISA_allocMsg> Allocating message for messageId=0x00021041
    1448700 PID:459000a TID:45a000a @1465,977,000us: [+0 T:0x045a000a S:0x1c01f514] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x1c130000, size=16384)
    1448701 PID:459000a TID:45a000a @1465,979,000us: [+1 T:0x045a000a S:0x1c01f4ac] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x1c130000, size=16384)
    1448702 PID:459000a TID:45a000a @1465,981,000us: [+1 T:0x045a000a S:0x1c01f4ac] OM - Memory__getPhysicalAddress> found in cb(Sc=0x1c130000, Ec=0x1c134000, Ss=0x1c130000, Es=0x1c134000, PSc=0x887c0000)
    1448703 PID:459000a TID:45a000a @1465,983,000us: [+1 T:0x045a000a S:0x1c01f4ac] OM - Memory__getPhysicalAddress> returning physAddr=0x887c0000
    1448705 PID:459000a TID:45a000a @1465,985,000us: [+0 T:0x045a000a S:0x1c01f514] OM - Memory_getBufferPhysicalAddress> return (0x887c0000)
    1448706 PID:459000a TID:45a000a @1465,989,000us: [+0 T:0x045a000a S:0x1c01f52c] CV - VISA_call(visa=0x1c0225c0, msg=0x1c0b1c80): messageId=0x00021041, command=0x1
    1448707 PID:459000a TID:45a000a @1465,991,000us: [+0 T:0x045a000a S:0x1c01f4c8] OC - Comm_put> Enter(queue=0x2, msg=0x1c0b1c80)
    1448708 PID:459000a TID:45a000a @1465,993,000us: [+0 T:0x045a000a S:0x1c01f4c8] OC - Comm_put> return (0)
    1448710 PID:459000a TID:45a000a @1465,997,000us: [+0 T:0x045a000a S:0x1c01f49c] OC - Comm_get> Enter(queue=0x10001, msg=0x1c01f59c, timeout=-1)
    1448711 PID:459000a TID:45a000a @1465,999,000us: [+0 T:0x045a000a S:0x1c01f49c] OC - Comm_get> MSGQ_get() status=0x8000, return (0)
    1448712 PID:459000a TID:45a000a @1466,001,000us: [+0 T:0x045a000a S:0x1c01f400] OC - Comm_put> Enter(queue=0x0, msg=0x1c0b0c80)
    1448714 PID:459000a TID:45a000a @1466,005,000us: [+0 T:0x045a000a S:0x1c01f400] OC - Comm_put> return (0)
    1448735 PID:459000a TID:45a000a @1466,047,000us: [+0 T:0x045a000a S:0x1c01f3d4] OC - Comm_get> Enter(queue=0x10000, msg=0x1c01f48c, timeout=-1)
    1448737 PID:459000a TID:45a000a @1466,051,000us: [+0 T:0x045a000a S:0x1c01f3d4] OC - Comm_get> MSGQ_get() status=0x8000, return (0)
    1448738 PID:459000a TID:45a000a [DSP] @1,211,036tk: [+5 T:0x8fc06b0c S:0x8fc08ed4] CN - NODE> 0x8fc065f0(rotor#0) call(algHandle=0x8fc066b8, msg=0x8fe06c80); messageId=0x00021041
    1448739 PID:459000a TID:45a000a [DSP] @1,211,125tk: [+0 T:0x8fc06b0c S:0x8fc08c24] OM - Memory_cacheInv> Enter(addr=0x887c0000, sizeInBytes=16384)
    1448740 PID:459000a TID:45a000a [DSP] @1,211,205tk: [+0 T:0x8fc06b0c S:0x8fc08c24] OM - Memory_cacheInv> return
    1448741 PID:459000a TID:45a000a [DSP] @1,211,252tk: [+0 T:0x8fc06b0c S:0x8fc08be4] ti.sdo.ce.universal.UNIVERSAL - UNIVERSAL_control> Enter (handle=0x8fc066b8, id=1, dynParams=0x8fe06cb4 (size=0x20), status=0x8fe06cd4 (size=0xd4)
    1448742 PID:459000a TID:45a000a [DSP] @1,211,365tk: [+5 T:0x8fc06b0c S:0x8fc08bc4] CV - VISA_enter(visa=0x8fc066b8): algHandle = 0x8fc066f0
    1448742 PID:459000a TID:45a000a [DSP] @1,211,427tk: [+0 T:0x8fc06b0c S:0x8fc08ba4] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Enter(alg=0x8fc066f0)
    1448743 PID:459000a TID:45a000a [DSP] @1,211,496tk: [+0 T:0x8fc06b0c S:0x8fc08ba4] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Exit
    1448744 PID:459000a TID:45a000a [DSP] @1,211,553tk: [+0 T:0x8fc06b0c S:0x8fc08bac] hexium.rotor.ROTOR - ROTOR_HEXIUM_control> Enter handle=0x888007c0, id=1, universalDynParams=0x8fe06cb4, universalStatus=0x8fe06cd4
    1448745 PID:459000a TID:45a000a [DSP] @1,211,653tk: [+0 T:0x8fc06b0c S:0x8fc08bac] hexium.rotor.ROTOR - ROTOR_HEXIUM_control> Exit: retVal=0x00000000
    1448746 PID:459000a TID:45a000a [DSP] @1,211,714tk: [+5 T:0x8fc06b0c S:0x8fc08bc4] CV - VISA_exit(visa=0x8fc066b8): algHandle = 0x8fc066f0
    1448747 PID:459000a TID:45a000a [DSP] @1,211,777tk: [+0 T:0x8fc06b0c S:0x8fc08ba4] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Enter(alg=0x8fc066f0)
    1448748 PID:459000a TID:45a000a [DSP] @1,211,843tk: [+0 T:0x8fc06b0c S:0x8fc08ba4] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Exit
    1448750 PID:459000a TID:45a000a [DSP] @1,211,898tk: [+0 T:0x8fc06b0c S:0x8fc08be4] ti.sdo.ce.universal.UNIVERSAL - UNIVERSAL_control> Exit (handle=0x8fc066b8, retVal=0x0)
    1448751 PID:459000a TID:45a000a [DSP] @1,211,969tk: [+5 T:0x8fc06b0c S:0x8fc08ed4] CN - NODE> returned from call(algHandle=0x8fc066b8, msg=0x8fe06c80); messageId=0x00021041
    1448906 PID:459000a TID:45a000a [DSP] @1,221,248tk: [+0 T:0x8fc01b2c S:0x8fc05aec] CR - processRmsCmd(0x8fe05ca8, 4056): cmd = 5
    1448907 PID:459000a TID:45a000a [DSP] @1,221,309tk: [+0 T:0x8fc01b2c S:0x8fc05aec] CR - remote time = 0x0, trace buffer size = 4032
    1448908 PID:459000a TID:45a000a @1466,393,000us: [+0 T:0x045a000a S:0x1c01f460] CE - Engine_fwriteTrace> returning count [1979]
    1448909 PID:459000a TID:45a000a @1466,395,000us: [+0 T:0x045a000a S:0x1c01f52c] CV - VISA_call Completed: messageId=0x00021041, command=0x1, return(status=0)
    1448910 PID:459000a TID:45a000a @1466,397,000us: [+5 T:0x045a000a S:0x1c01f548] CV - VISA_freeMsg(0x1c0225c0, 0x1c0b1c80): Freeing message with messageId=0x00021041
    1448911 PID:459000a TID:45a000a @1466,399,000us: [+0 T:0x045a000a S:0x1c01f628] ti.sdo.ce.universal.UNIVERSAL - UNIVERSAL_control> Exit (handle=0x1c0225c0, retVal=0x0)

  • Peter Ladanyi said:
    2.
    > Also could you let me know if you are running with 'checked' set to "TRUE" ?
    How can I set this "checked" flag?

    http://e2e.ti.com/blogs_/b/codec_engine/archive/2010/06/13/tools-and-tips-ce-check.aspx

    Chris

  •  

    Dear Chris,

    Thank you for your help.

    Peter