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.

How to build a DSP server using C-callable linear assembly?



We are evaluating DM6446 for a video processing application.  We use Monta Vista Linux on the target and RHEL 5.1 on the host. We have installed all the TI tools and we can build all the demo codes. We have example codes from TI (DaVinci workshop) which demonstrate how to build a codec server.  We are trying to build on these examples and modify them as necessary to implement our algorithm.

Specifically;

We have application code for ARM that handles all the I/O, etc. We did not modify this.

We have codec codes that run on the dsp. This is supposed to be an encode/decode application. However, the codecs are simply placeholders that  just copy the incoming frame from the capture device to the display buffer. We modified one of these codecs to implement a simple frame differencing routine.

We use TI's makefile to build everything. This file calls xdc to generate a dsp server and an ARM executable. All is fine when we implement the frame differencing routine in C. Our code compiles and links and we get our executables. However, when we implement the routine in linear assembly and call it from our C file, the code compiles but we get a linking error and the dsp server is not built. It complains that our assembly code is an unresolved symbol.

below is the assembly code:

.def    _diff1_sa
   
    .sect   "mycode"

_diff1_sa     .cproc  in1_ptr,in2_ptr
   
    .reg    in1,in2, y,count
   
   
    MVK        1,count

loop    LDB     *in1_ptr++,in1
   

    LDB     *in2_ptr++,in2
   
    SUB     in1, in2, y
    ABS        y,y
    SUB        count,1,count
[count]    B loop


    .return y
    .endproc 


below is the C code that calls it:

static XDAS_Int32 MYVIDENC_TTO_process(IVIDENC_Handle h, XDM_BufDesc *inBufs,
    XDM_BufDesc *outBufs, IVIDENC_InArgs *inArgs, IVIDENC_OutArgs *outArgs)
{
    XDAS_Int32 curBuf;
    XDAS_UInt32 minSamples;
   int lineWidth = 72 * 2;
    int y;

    MYVIDENC_TTO_Obj *hTmp = (void *)h;
    XDAS_Int8 *prev = hTmp->prevFrame;
    XDAS_Int8 *src = inBufs->bufs[0];
    XDAS_Int8 *dst = outBufs->bufs[0];
   
    /* validate arguments - this codec only supports "base" xDM. */
    if ((inArgs->size != sizeof(*inArgs)) ||
        (outArgs->size != sizeof(*outArgs))) {

        return (IVIDENC_EFAIL);
    }

    /* outArgs->bytesGenerated reports the total number of bytes generated */
    outArgs->bytesGenerated = 0;

        /* there's an available in and out buffer, how many samples? */
        minSamples = inBufs->bufSizes[0] < outBufs->bufSizes[0] ?
            inBufs->bufSizes[0] : outBufs->bufSizes[0];

   
    for (y=0; y < 4800; y++) {
       
    for (curBuf=0;curBuf<lineWidth;curBuf++) {
        if (curBuf%2==0)
            dst[curBuf] = src[curBuf];
        else
            /*dst[curBuf] = abs(src[curBuf] - prev[curBuf]);*/
            dst[curBuf] = diff1_sa(src+curBuf,prev+curBuf);
        }

    memcpy(prev, src, lineWidth);
        prev += lineWidth;
        src += lineWidth;
        dst += lineWidth;

    }
   
   
        outArgs->bytesGenerated += minSamples;


    /* Fill out the rest of the outArgs struct */
    outArgs->extendedError = 0;
    outArgs->encodedFrameType = 0;
    outArgs->inputFrameSkip = IVIDEO_FRAME_ENCODED;
    outArgs->reconBufs.numBufs = 0;   /* important: indicate no reconBufs */

    return (IVIDENC_EOK);
}


below is the error we get when we try to build this code:

======== .executables [/home/algoritma/TI/workshop/solutions/soln14a_build_codec_frame_diff_asm/server] ========
configuring server_debug.x64P from package/cfg/server_debug_x64P.cfg ...
ti.sdo.ce.bioslog.init() ...
ti.sdo.ce.bioslog.close() ...
ti.sdo.ce.osal.close() ...
ti.sdo.ce.bioslog.validate() ...
ti.sdo.ce.osal.validate() ...
    will link with codecs.auddec_copy:lib/auddec_copy.a64P
    will link with codecs.audenc_copy:lib/audenc_copy.a64P
    will link with ti.sdo.ce.audio:lib/audio_debug.a64P
    will link with ti.sdo.ce.bioslog:lib/bioslog.a64P
    will link with myvidenc:myvidenc_debug.a64P
    will link with myviddec:myviddec_debug.a64P
    will link with ti.sdo.ce.video:lib/video_debug.a64P
    will link with ti.sdo.ce:lib/ce_debug.a64P
    will link with ti.sdo.fc.acpy3:acpy3.a64P
    will link with ti.sdo.fc.dman3:dman3d.a64P
    will link with ti.sdo.fc.dskt2:dskt2d.a64P
    will link with ti.sdo.ce.osal:lib/osal_dsplink_bios.a64P
    will link with ti.bios.utils:lib/utils.a64P
    will link with dsplink.dsp:export/BIN/DspBios/Davinci/RELEASE/dsplink.lib;export/BIN/DspBios/Davinci/RELEASE/dsplinkmsg.lib
    will link with ti.sdo.ce.osal.alg:lib/alg.a64P
    will link with ti.sdo.ce.trace:lib/gt.a64P
    will link with ti.sdo.ce.node:lib/node_debug.a64P
asm64P package/cfg/server_debug_x64Pcfg.s62 ...
cl64P main.c ...
cl64P package/cfg/server_debug_x64P.c ...
cl64P package/cfg/server_debug_x64Pcfg_c.c ...
lnk64P server_debug.x64P ...
warning: conservatively using trampoline for call destination
   "_BCACHE_bootInit"; generation and use of this trampoline can potentially be
   avoided if the --symbol_map option is used to re-direct symbol references
   instead of using symbol assignments

 undefined first referenced                                                                                                   
  symbol       in file                                                                                                        
 --------- ----------------                                                                                                   
 _diff1_sa /home/algoritma/TI/workshop/solutions/soln14a_build_codec_frame_diff_asm/myvidenc/myvidenc_debug.a64P<myvidenc.o64P>

error: unresolved symbols remain
error: errors encountered during linking; "server_debug.x64P" not built
gmake[1]: *** [server_debug.x64P] Error 1
gmake: *** [/home/algoritma/TI/workshop/solutions/soln14a_build_codec_frame_diff_asm/server,.executables] Error 2