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.

Problems with compilation / execution of code using DSPLink

For the past three weeks I have been trying to compile and run my code on DaVinci platform. Platform itself works properly ( loop example works ). So I think problem is on my side. However DSPLink examples are so overcomplicated that I can't decrypt them.

 

In short:

- When I don't specify application entry point of DSP side my code compiles ( Giving warning about lack of suitable entry point. ) but it fails to execute PROC_start().

- When I specify entry point ( using -e=_main ) linker fails giving following errors:

 

%% err.txt %%

 undefined         first referenced                                                                                                                                                
  symbol               in file                                                                                                                                                     
 ---------         ----------------                                                                                                                                                
 _BCACHE_inv       C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<dsplink.obj>     
 _BCACHE_invL1pAll C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<hal.obj>         
 _BCACHE_wbInv     C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<dsplink.obj>     
 _BCACHE_wbInvAll  C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<hal_interrupt.obj>
 _C64_disableIER   C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<hal_interrupt.obj>
 _C64_enableIER    C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<hal_interrupt.obj>
 _CLK_reconfig     C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<dsplink.obj>     
 _DDR2             linkEx01Server.obj                                                                                                                                              
 _DSPLINKMQT_init  C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<dsplink.obj>     
 _GBL_freq         C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<dsplink.obj>     
 _GBL_procId       C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<dsplink.obj>     
 _HWI_disable      C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<ips.obj>         
 _HWI_dispatchPlug C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<hal_interrupt.obj>
 _HWI_eventMap     C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<hal_interrupt.obj>
 _HWI_restore      C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<ips.obj>         
 _MEM_free         C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<ips.obj>         
 _MEM_valloc       C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<ips.obj>         
 _MPCS_init        C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<dsplink.obj>     
 _MPLIST_init      C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<dsplink.obj>     
 _NOTIFY_init      C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<dsplink.obj>     
 _POOL             linkEx01Server.obj                                                                                                                                              
 _RingIO_init      C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib<dsplink.obj>     
 _SIO_ATTRS        linkEx01Server.obj                                                                                                                                              
 _SIO_create       linkEx01Server.obj                                                                                                                                              
 _SIO_delete       linkEx01Server.obj                                                                                                                                              
 _SIO_issue        linkEx01Server.obj                                                                                                                                              
 _SIO_reclaim      linkEx01Server.obj                                                                                                                                              
 _TSK_create       linkEx01Server.obj                                                                                                                                              

error: unresolved symbols remain
error: errors encountered during linking; "linkEx01Server.x64P" not built
gmake: *** [linkEx01Server.x64P] Error 1

 

%%%%

 

XDC Makes me sick so I use such makefile:

 

%% makefile %%

 

# Makefile for DaVinci platform.
# Because I don't like XDC.

xdcRoot   = C:/Programs/DaVinci/dsp_build_system/xdctools_3_15_00_50
x64Tools  = C:/Programs/DaVinci/dsp_build_system/CGT_6.1.10
confiGuro = xs xdc.tools.configuro
loader    = xs xdc.tools.loader
CC        = $(x64Tools)/bin/cl6x

CONFIG    = conf
TARGET    = ti.targets.C64P
PLATFORM  = ti.platforms.sim64Pxx
linkerCMD = $(CONFIG)/linker.cmd
compilerOPT = $(CONFIG)/compiler.opt

sourceServer    = linkEx01Server.cpp
objectServer    = linkEx01Server.obj
outputServer    = linkEx01Server.x64P


sourceClient    = linkEx01Client.cpp
objectClient    = linkEx01Client.obj
outputClient    = linkEx01Client

InclClient      = -I C:\Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/gpp/export/INCLUDE/Linux/DAVINCI/usr \
            -I C:\Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/gpp/export/INCLUDE/Linux/DAVINCI \
            -I C:\Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/gpp/inc/usr \
            -I C:\Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/gpp/inc/sys/Linux

IncServer      = -I C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/INCLUDE/DspBios/DAVINCI \
            -I C:/Programs/DaVinci/dsp_build_system/bios_5_33_05/packages/ti/bios/include \
            -I C:\Programs\DaVinci\dsp_build_system\codec_engine_2_24\cetools\packages\dsplink\dsp\inc\DspBios\5.XX\DM6446GEM \
            -I C:\Programs\DaVinci\dsp_build_system\codec_engine_2_24\cetools\packages\dsplink\dsp\inc\C64XX

LibServer      = -l C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplink.lib \
            -l C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplinkpool.lib \
            -l C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/dsp/export/BIN/DspBios/DAVINCI/DM6446GEM_0/RELEASE/dsplinkdata.lib \
            -l $(x64Tools)/lib/rts64plus_eh.lib \
            -l $(x64Tools)/lib/libc.a

GCC       = C:/Programs/DaVinci/arm_build_system/bin/arm-none-linux-gnueabi-gcc.exe

all : $(outputClient) $(outputServer)

$(objectClient) : $(sourceClient)
    $(GCC) -c $(sourceClient) -o $(objectClient) $(InclClient)
   
$(outputClient) : $(objectClient)
    $(GCC) $(objectClient) C:/Programs/DaVinci/dsp_build_system/codec_engine_2_24/cetools/packages/dsplink/gpp/export/BIN/Linux/DAVINCI/DEBUG/dsplink.lib -lpthread -o $(outputClient)

$(outputServer) : $(objectServer) $(linkerCMD)
    $(CC) -z $(linkerCMD) -e _main $(objectServer) $(LibServer) -o $(outputServer)

$(objectServer) : $(sourceServer) $(compilerOPT)
    $(CC) -@ $(compilerOPT) -c $(sourceServer) $(IncServer)
       
$(linkerCMD) $(compilerOPT) :
    $(confiGuro) -c $(x64Tools) -p $(PLATFORM) -t $(TARGET) -o $(CONFIG) linkEx01Server.cfg
   
clear:
    $(xdcRoot)/bin/rm -rf $(CONFIG) $(outputClient) $(objectClient) $(outputServer) $(objectServer)

 

%%%%

( linkEx01Server.cfg is an empty file. )

 

Source of GPP side:

 

%% linkEx01Client.cpp %%

 

#define MAX_DSPS 1
#define DLLEXPORT

#include <dsplink.h>
#include <proc.h>
#include <chnl.h>
#include <pool.h>

#include <cstdio>
#include <cstring>

enum CommSym
{
    Alloc = 0,
    Free = 1,
    Cpy = 2,
    Stop= 3,
    Nop = 0xffffffff
};

struct DSP_Command
{
    CommSym opCode;
    void* pParam1;
    void* pParam2;
    Uint32 numParam;
};

char  dataBuffer[13] = "Ala ma kota!";
char  returnBuffer[13] ;

Char8 exeName[] = "linkEx01Server.x64P";
Uint32 buffersSize[1] = { DSPLINK_ALIGN(sizeof(DSP_Command), DSPLINK_BUF_ALIGN) };
Uint32 numOfBuffers[1] = { 4 };

const Uint32 PoolID = 0;
const Uint32 OutChnlID = 0;
const Uint32 InChnlID = 1;
const Uint32 ProcID = 0;

static Char8* ChnlBuffer[1];

Char8* inBuffer = NULL;
Char8* outBuffer = NULL;

DSP_STATUS Init()
{
    printf( "Begin Init.\n" );

    DSP_STATUS status;
    BUFPOOL_Attrs poolAttrs;
    ChannelAttrs inChannel;
    ChannelAttrs outChannel;
   
    status = PROC_setup( NULL );
   
    printf( "PROC_setup.\n" );
   
    if( DSP_FAILED (status) )
    {
        return status;
    }
   
    status = PROC_attach( ProcID, NULL );
   
    printf( "PROC_attach.\n" );
   
    if( DSP_FAILED (status) )
    {
        return status;
    }
   
    poolAttrs.bufSizes = ( Uint32 * ) &buffersSize;
    poolAttrs.numBuffers = ( Uint32 * ) &numOfBuffers;
    poolAttrs.numBufPools = 1;
   
    status = POOL_open( POOL_makePoolId(ProcID, PoolID), &poolAttrs );
   
    printf( "POOL_open.\n" );
   
    if( DSP_FAILED (status) )
    {
        return status;
    }
   
    status = PROC_load(ProcID, exeName, 0, NULL );
   
    printf( "PROC_load.\n" );

    if( DSP_FAILED (status) )
    {
        return status;
    }
   
    inChannel.mode = ChannelMode_Input;
    inChannel.endianism = Endianism_Default;
    inChannel.size = ChannelDataSize_16bits;

    status = CHNL_create( ProcID, InChnlID, &inChannel );
   
    printf( "CHNL_create.\n" );
   
    if( DSP_FAILED (status) )
    {
        return status;
    }
   
   
    outChannel.mode = ChannelMode_Output;
    outChannel.endianism = Endianism_Default;
    outChannel.size = ChannelDataSize_16bits;

    status = CHNL_create( ProcID, OutChnlID, &outChannel );
   
    printf( "CHNL_create.\n" );
   
    if( DSP_FAILED (status) )
    {
        return status;
    }
   
    status = CHNL_allocateBuffer( ProcID, OutChnlID, ChnlBuffer, buffersSize[0], 1 );
   
    printf( "CHNL_allocateBuffer.\n" );
   
    if( DSP_FAILED (status) )
    {
        return status;
    }
   
    status = PROC_start( ProcID );
   
    printf( "PROC_start.\n" );
   
    return status;
}

DSP_STATUS Close()
{
    printf( "Begin Close.\n" );

    DSP_STATUS status;

    status = CHNL_freeBuffer( ProcID, OutChnlID, ChnlBuffer, 1);
   
    status = CHNL_delete( ProcID, OutChnlID );
   
    status = CHNL_delete( ProcID, InChnlID );
   
    status = PROC_stop( ProcID );
   
    status = POOL_close( POOL_makePoolId(ProcID, PoolID) );
   
    status = PROC_detach( ProcID );
   
    status = PROC_destroy();
   
    return status;
}

void SendDSP_Command( DSP_Command* cmd )
{
    ChannelIOInfo req;
   
    req.buffer = ChnlBuffer[0];
    req.size = buffersSize[0];
   
    memcpy( ChnlBuffer[0], &cmd, sizeof( DSP_Command ) );
   
    CHNL_issue( ProcID, OutChnlID, &req );
   
    CHNL_reclaim( ProcID, OutChnlID, WAIT_FOREVER, &req );

    CHNL_issue( ProcID, InChnlID, &req );
   
    CHNL_reclaim( ProcID, InChnlID, WAIT_FOREVER, &req );

    memcpy( &cmd, ChnlBuffer[0], sizeof( DSP_Command ) );
}

void* DSP_Alloc( size_t size )
{
    DSP_Command cmd;
    cmd.opCode   = Alloc;
    cmd.pParam1  = NULL;
    cmd.pParam2  = NULL;
    cmd.numParam = size;
   
    SendDSP_Command( &cmd );
   
    return cmd.pParam1;
}

void DSP_Free( void* data )
{
    DSP_Command cmd;
    cmd.opCode   = Free;
    cmd.pParam1  = data;
    cmd.pParam2  = NULL;
    cmd.numParam = 0;
   
    SendDSP_Command( &cmd );
}

void DSP_MemCpy( char* str1, char* str2, int size )
{
    DSP_Command cmd;
    cmd.opCode   = Cpy;
    cmd.pParam1  = str1;
    cmd.pParam2  = str2;
    cmd.numParam = size;
   
    SendDSP_Command( &cmd );
}

void DSP_Stop()
{
    DSP_Command cmd;
    cmd.opCode   = Stop;
   
    SendDSP_Command( &cmd );
}

DSP_STATUS Do()
{
    DSP_STATUS status;
   
    inBuffer  = (Char8*)DSP_Alloc( strlen( dataBuffer ) );
    outBuffer = (Char8*)DSP_Alloc( strlen( dataBuffer ) );
   
    printf( "DSP_Alloc.\n" );
   
    if( inBuffer == NULL || outBuffer == NULL )
    {
        return DSP_EFAIL;
    }
   
    PROC_write( ProcID, (Uint32)outBuffer, strlen( dataBuffer ), dataBuffer );
   
    printf( "PROC_write.\n" );
   
    DSP_MemCpy( outBuffer, inBuffer, strlen( dataBuffer ) );
   
    printf( "DSP_MemCpy.\n" );
   
    PROC_read( ProcID, (Uint32)inBuffer, strlen( dataBuffer ), returnBuffer );
   
    printf( "PROC_read.\n" );
   
    DSP_Free( inBuffer );
    DSP_Free( outBuffer );
    printf( "DSP_Free.\n" );
   
    DSP_Stop();
    printf( "DSP_Stop.\n" );
   
    return DSP_SOK;
}

int main(int argc, char* argv[])
{
    DSP_STATUS status;

    status = Init();
   
    if( DSP_SUCCEEDED( status ) )
    {
        printf( "Init OK\nSending: %s\n", dataBuffer );
        status = Do();
        printf( "Recivied: %s\n", returnBuffer );
    }
    else
    {
        printf( "Init failed.\n");
    }
   
    Close();
   
    return 0;
}

 

%%%%

 

DSP Side:

 

%% linkEx01Server.cpp %%

#define POOL_COMPONENT

#include <std.h>
#include <log.h>
#include <swi.h>
#include <sys.h>
#include <sio.h>
#include <tsk.h>
#include <gio.h>
#include <pool.h>

#include <dsplink.h>
#include <failure.h>
#include <platform.h>
#include <sma_pool.h>

#include <cstdio>
#include <cstring>
#include <cstdlib>

#define DSPLINK_DRVNAME  "/dio_dsplink"
#define INPUT_CHNL_NAME(drvName)  drvName ## "0"
#define OUTPUT_CHNL_NAME(drvName)  drvName ## "1"
#define INPUT_CHANNEL             INPUT_CHNL_NAME(DSPLINK_DRVNAME)
#define OUTPUT_CHANNEL            OUTPUT_CHNL_NAME(DSPLINK_DRVNAME)

#define SAMPLE_POOL_ID  0

using namespace std;

enum CommSym
{
    Alloc = 0,
    Free = 1,
    Cpy = 2,
    Stop= 3,
    Nop = 0xffffffff
};

struct DSP_Command
{
    CommSym opCode;
    void* pParam1;
    void* pParam2;
    Uint32 numParam;
};

Uint32 buffersSize[1] = { DSPLINK_ALIGN(sizeof(DSP_Command), DSPLINK_BUF_ALIGN) };
Uint32 numOfBuffers[1] = { 4 };

struct TransferInfo
{
    SIO_Handle inStream;
    SIO_Handle outStream;
    Uint32 bufferSize;
    Uint16 numOfBuffers;
    char* buffer[4];
};

bool Init( TransferInfo* transInfo )
{
    SIO_Attrs attrs;
   
    transInfo->bufferSize = DSPLINK_ALIGN(sizeof(DSP_Command), DSPLINK_BUF_ALIGN);
    transInfo->numOfBuffers = 4;
   
    attrs = SIO_ATTRS;
    attrs.nbufs   = transInfo->numOfBuffers ;
    attrs.segid   = DSPLINK_SEGID ;
    attrs.align   = DSPLINK_BUF_ALIGN ;
    attrs.flush   = TRUE ;
    attrs.model   = SIO_ISSUERECLAIM ;
    attrs.timeout = SYS_FOREVER ;
   
    transInfo->inStream = SIO_create( INPUT_CHANNEL, SIO_INPUT, transInfo->bufferSize, &attrs );
    transInfo->outStream = SIO_create( OUTPUT_CHANNEL, SIO_OUTPUT, transInfo->bufferSize, &attrs );
   
    if( transInfo->inStream == NULL || transInfo->outStream == NULL ) return false;
   
    for( int i = 0; i< transInfo->numOfBuffers; ++i )
    {
        Int status = POOL_alloc( SAMPLE_POOL_ID, (Ptr*)transInfo->buffer[i], transInfo->bufferSize );
        if( status!=SYS_OK )
        {
            return false;
        }
    }

    return true;
}

void Close( TransferInfo* transInfo )
{
    if( transInfo->inStream != NULL )
    {
        SIO_delete(transInfo->inStream);
    }

    if( transInfo->outStream != NULL )
    {
        SIO_delete(transInfo->outStream);
    }
   
    for( int i = 0; i< transInfo->numOfBuffers; ++i )
    {
        POOL_free( SAMPLE_POOL_ID, transInfo->buffer[i], transInfo->bufferSize );
    }
}

void Loop( TransferInfo* transInfo )
{
    Int status;
   
    bool done = false;
   
    DSP_Command* cmd;
       
    char* buffer = transInfo->buffer[0];
   
    Int rSize;
    Arg arg = 0;
   
    while( !done )
    {
        status = SIO_issue( transInfo->inStream, buffer, transInfo->bufferSize, arg );
       
        if( status!=SYS_OK ) return;
       
        rSize = SIO_reclaim( transInfo->inStream, (Ptr*) &buffer, &arg );
       
        if( rSize < 0 ) return;
       
        cmd = (DSP_Command*) buffer;
       
        switch( cmd->opCode )
        {
        case Alloc:
            {
                cmd->pParam1 = malloc( cmd->numParam );
            }
            break;
        case Free:
            {
                free( cmd->pParam1 );
            }
            break;
        case Cpy:
            {
                memcpy( cmd->pParam1, cmd->pParam2, cmd->numParam );
            }
            break;
        case Stop:
            {
                done = true;
            }
            break;
        }
       
        status = SIO_issue( transInfo->outStream, buffer, transInfo->bufferSize, arg );
       
        if( status!=SYS_OK ) return;
       
        rSize = SIO_reclaim( transInfo->outStream, (Ptr*) &buffer, &arg );
       
        if( rSize < 0 ) return;
    }
}

static int tskLoop()
{
    TransferInfo transInfo;
    if(Init( &transInfo ))
    {
        Loop( &transInfo );
    }
   
    Close( &transInfo );
   
    return 0;
}

int main(int argc, char* argv[])
{
    TSK_Handle tskLoopTask;
    tskLoopTask = TSK_create(tskLoop, NULL, 0);
   
    DSPLINK_init ();
   
    if (tskLoopTask == NULL)
    {
        return -1;
    }
   
    return 0;
}

%%%%

 

What I am missing?