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.

CMEM Error in my Codec Engine Application

Other Parts Discussed in Thread: OMAP3530

Hi ,

I'm planning to write an application based on Codec Engine G.711 encode and decode server . So my first step is to copy the "app.c" example in dvsdk_3_00_00_40/codec_engine_2_24/examples/ti/sdo/ce/examples/apps/speech and modified it . Then I write my own config.cfg file and makefile.The application could run without any problem with the function SPHENC1_process( )  commentted, so I  think my makefile and config.cfg is correct.  When with that function uncommentted there were errors below:

..................

CMEMK Error: get_phys: Unable to find phys addr for 0x0010f044

CMEMK Error: get_phys: get_user_pages() failed: -14

CMEMK Error: GETPHYS: Failed to convert virtual 0x10f044 to physical.

CMEM Error: getPhys: Failed to get physical address of 0x10f044

..................

 

I googled it and it seems that the address 0x0010f044 is not a virtual address and  CMEM could not get its physical address.  I have successfully run the loadmodules.sh and the TI's examples could run smoothly.

Then I run it in the debug mode  :

#CE_DEBUG=3  ./sphencode

and it said:

========================================================================================================my app

...........

@6,427,917us: [+0 T:0x4001e490 S:0xbef56a04] ti.sdo.ce.speech1.SPHENC1 - SPHENC1_process> Enter (handle=0x4d9d8, inBuf=0xbef56b90, outBuf=0xbef56b84, inArgs=0xbef56b74, outArgs=0xbef56b6c)
@6,428,009us: [+5 T:0x4001e490 S:0xbef569ac] CV - VISA_allocMsg> Allocating message for messageId=0x0002e5c6
@6,428,070us: [+0 T:0x4001e490 S:0xbef5697c] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x40020000, size=64)
@6,428,131us: [+1 T:0x4001e490 S:0xbef5697c] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x40020000, size=64)
@6,428,161us: [+1 T:0x4001e490 S:0xbef5697c] OM - Memory__getPhysicalAddress> found in cb(Sc=0x40020000, Ec=0x40020040, Ss=0x40020000, Es=0x40020040, PSc=0x85ffd000)
@6,428,222us: [+1 T:0x4001e490 S:0xbef5697c] OM - Memory__getPhysicalAddress> returning physAddr=0x85ffd000
@6,428,253us: [+0 T:0x4001e490 S:0xbef5697c] OM - Memory_getBufferPhysicalAddress> return (0x85ffd000)
@6,428,314us: [+0 T:0x4001e490 S:0xbef5697c] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x40021000, size=32)
@6,428,344us: [+1 T:0x4001e490 S:0xbef5697c] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x40021000, size=32)
@6,428,405us: [+1 T:0x4001e490 S:0xbef5697c] OM - Memory__getPhysicalAddress> found in cb(Sc=0x40021000, Ec=0x40021020, Ss=0x40021000, Es=0x40021020, PSc=0x85ffe000)
@6,428,466us: [+1 T:0x4001e490 S:0xbef5697c] OM - Memory_CMEMK Error: get_phys: Unable to find phys addr for 0x0010f044
_getPhysicalAddress> returning pCMEMK Error: get_phys: get_user_pages() failed: -14
hysAddr=0x85ffe000
@6,428,497usCMEMK Error: GETPHYS: Failed to convert virtual 0x10f044 to physical.
: [+0 T:0x4001e490 S:0xbef5697c] OM - Memory_getBufferPhysicalAddress> return (0x85ffe000)
@6,428,558us: [+0 T:0x4001e490 S:0xbef5697c] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x10f044, size=1075085312)
@6,763,641us: [+1 T:0x4001e490 S:0xbef5697c] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x10f044, size=1075085312)
@6,763,702us: [+1 T:0x4001e490 S:0xbef5697c] OM - Memory__getPhysicalAddress> returning physAddr=0x0

CMEM Error: getPhys: Failed to get physical address of 0x10f044
@6,789,428us: [+1 T:0x4001e490 S:0xbef5697c] OM - Memory_getBufferPhysicalAddress> CMEM_getPhys(0x10f044) = 0x0.
@6,789,520us: [+0 T:0x4001e490 S:0xbef5697c] OM - Memory_getBufferPhysicalAddress> return (0x0)
@6,789,581us: [+5 T:0x4001e490 S:0xbef56994] CV - VISA_freeMsg(0x4d9d8, 0x4133e880): Freeing message with messageId=0x0002e5c6
@6,789,642us: [+0 T:0x4001e490 S:0xbef56a04] ti.sdo.ce.speech1.SPHENC1 - SPHENC1_process> Exit (handle=0x4d9d8, retVal=0xffffffff)

.....................

========================================================================================================my app

and the correct print of the Codec Engine's example was below

========================================================================================================TI'example

.......................

Encoder version:  1.00.00.0
App-> Processing frame 0...
@6,955,291us: [+0 T:0x4001d000 S:0xbecc7a14] ti.sdo.ce.speech1.SPHENC1 - SPHENC1_process> Enter (handle=0x5dcf8, inBuf=0xbecc7b98, outBuf=0xbecc7b8c, inArgs=0xbecc7b7c, outArgs=0xbecc7ba4)
@6,955,383us: [+5 T:0x4001d000 S:0xbecc79bc] CV - VISA_allocMsg> Allocating message for messageId=0x0002aa5a
@6,955,444us: [+0 T:0x4001d000 S:0xbecc798c] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x4001e000, size=64)
@6,955,474us: [+1 T:0x4001d000 S:0xbecc798c] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x4001e000, size=64)
@6,955,535us: [+1 T:0x4001d000 S:0xbecc798c] OM - Memory__getPhysicalAddress> found in cb(Sc=0x4001e000, Ec=0x4001e040, Ss=0x4001e000, Es=0x4001e040, PSc=0x85ffd000)
@6,955,596us: [+1 T:0x4001d000 S:0xbecc798c] OM - Memory__getPhysicalAddress> returning physAddr=0x85ffd000
@6,955,627us: [+0 T:0x4001d000 S:0xbecc798c] OM - Memory_getBufferPhysicalAddress> return (0x85ffd000)
@6,955,688us: [+0 T:0x4001d000 S:0xbecc798c] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x4001f000, size=32)
@6,955,749us: [+1 T:0x4001d000 S:0xbecc798c] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x4001f000, size=32)
@6,955,810us: [+1 T:0x4001d000 S:0xbecc798c] OM - Memory__getPhysicalAddress> found in cb(Sc=0x4001f000, Ec=0x4001f020, Ss=0x4001f000, Es=0x4001f020, PSc=0x85ffe000)
@6,955,871us: [+1 T:0x4001d000 S:0xbecc798c] OM - Memory__getPhysicalAddress> returning physAddr=0x85ffe000
@6,955,902us: [+0 T:0x4001d000 S:0xbecc798c] OM - Memory_getBufferPhysicalAddress> return (0x85ffe000)
@6,955,963us: [+0 T:0x4001d000 S:0xbecc79bc] CV - VISA_call(visa=0x5dcf8, msg=0x41164880): messageId=0x0002aa5a, command=0x0
@6,956,024us: [+0 T:0x4001d000 S:0xbecc7984] OC - Comm_put> Enter(queue=0x2, msg=0x41164880)
@6,956,085us: [+0 T:0x4001d000 S:0xbecc7984] OC - Comm_put> return (0)
@6,956,146us: [+0 T:0x4001d000 S:0xbecc797c] OC - Comm_get> Enter(queue=0x10001, msg=0xbecc7a2c, timeout=-1)
@6,963,073us: [+0 T:0x4001d000 S:0xbecc797c] OC - Comm_get> MSGQ_get() status=0x8000, return (0)
@6,963,134us: [+0 T:0x4001d000 S:0xbecc790c] OC - Comm_put> Enter(queue=0x0, msg=0x41163880)
@6,963,226us: [+0 T:0x4001d000 S:0xbecc790c] OC - Comm_put> return (0)
@7,296,813us: [+0 T:0x4001d000 S:0xbecc7904] OC - Comm_get> Enter(queue=0x10000, msg=0xbecc79a4, timeout=-1)
@7,296,905us: [+0 T:0x4001d000 S:0xbecc7904] OC - Comm_get> MSGQ_get() status=0x8000, return (0)
[DSP] @3,958,714tk: [+5 T:0x8783af4c S:0x8783d43c] CN - NODE> 0x8783aa68(g711enc#0) call(algHandle=0x8783ab28, msg=0x87e04880); messageId=0x0002aa5a
[DSP] @3,958,793tk: [+0 T:0x8783af4c S:0x8783d3dc] OM - Memory_cacheInv> Enter(addr=0x85ffd000, sizeInBytes=64)
[DSP] @3,958,852tk: [+0 T:0x8783af4c S:0x8783d3dc] OM - Memory_cacheInv> return
[DSP] @3,958,893tk: [+0 T:0x8783af4c S:0x8783d3dc] OM - Memory_cacheInv> Enter(addr=0x85ffe000, sizeInBytes=32)
[DSP] @3,958,951tk: [+0 T:0x8783af4c S:0x8783d3dc] OM - Memory_cacheInv> return
[DSP] @3,958,994tk: [+0 T:0x8783af4c S:0x8783d39c] ti.sdo.ce.speech1.SPHENC1 - SPHENC1_process> Enter (handle=0x8783ab28, inBuf=0x8783d444, outBuf=0x8783d450, inArgs=0x87e048c8, outArgs=0x87e048d8)
[DSP] @3,959,097tk: [+5 T:0x8783af4c S:0x8783d37c] CV - VISA_enter(visa=0x8783ab28): algHandle = 0x8783ab58
[DSP] @3,959,155tk: [+0 T:0x8783af4c S:0x8783d35c] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Enter(alg=0x8783ab58)
[DSP] @3,959,214tk: [+0 T:0x8783af4c S:0x8783d35c] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Exit
[DSP] @3,959,289tk: [+5 T:0x8783af4c S:0x8783d37c] CV - VISA_exit(visa=0x8783ab28): algHandle = 0x8783ab58
[DSP] @3,959,353tk: [+0 T:0x8783af4c S:0x8783d35c] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Enter(alg=0x8783ab58)
[DSP] @3,959,413tk: [+0 T:0x8783af4c S:0x8783d35c] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Exit
[DSP] @3,959,465tk: [+0 T:0x8783af4c S:0x8783d39c] ti.sdo.ce.speech1.SPHENC1 - SPHENC1_process> Exit (handle=0x8783ab28, retVal=0x0)
[DSP] @3,959,531tk: [+0 T:0x8783af4c S:0x8783d3dc] OM - Memory_cacheWb> Enter(addr=0x85ffe000, sizeInBytes=32)
[DSP] @3,959,590tk: [+0 T:0x8783af4c S:0x8783d3dc] OM - Memory_cacheWb> return
[DSP] @3,959,633tk: [+5 T:0x8783af4c S:0x8783d43c] CN - NODE> returned from call(algHandle=0x8783ab28, msg=0x87e04880); messageId=0x0002aa5a
[DSP] @3,968,728tk: [+0 T:0x87838f8c S:0x87839f4c] CR - processRmsCmd(0x87e038a8, 4056): cmd = 5
[DSP] @3,968,782tk: [+0 T:0x87838f8c S:0x87839f4c] CR - remote time = 0x0, trace buffer size = 4032
@7,299,957us: [+0 T:0x4001d000 S:0xbecc793c] CE - Engine_fwriteTrace> returning count [2053]
@7,300,018us: [+0 T:0x4001d000 S:0xbecc79bc] CV - VISA_call Completed: messageId=0x0002aa5a, command=0x0, return(status=0)
@7,300,079us: [+5 T:0x4001d000 S:0xbecc79c4] CV - VISA_freeMsg(0x5dcf8, 0x41164880): Freeing message with messageId=0x0002aa5a
@7,300,140us: [+0 T:0x4001d000 S:0xbecc7a14] ti.sdo.ce.speech1.SPHENC1 - SPHENC1_process> Exit (handle=0x5dcf8, retVal=0x0)

......................

========================================================================================================TI's example

 

My application entered virtAddr=0x10f044 and the error occured. Here is my C code:

 

========================================================================================================my code

#include <xdc/std.h>
#include <ti/sdo/ce/Engine.h>
#include <ti/sdo/ce/CERuntime.h>
#include <ti/sdo/ce/speech1/sphenc1.h>
#include <ti/sdo/ce/osal/Memory.h>
#include <ti/sdo/ce/trace/gt.h>
#include <ti/xdais/xdas.h>

#include <stdio.h>
#include <stdlib.h>

#define NSAMPLES    32
#define IFRAMESIZE  (NSAMPLES * sizeof(Int16))  /* raw frame (input) */
#define OFRAMESIZE  (NSAMPLES * sizeof(Int8))   /* encoded frame (output) */
#ifndef BUFALIGN
#define BUFALIGN Memory_DEFAULTALIGNMENT
#endif
#define MAXVERSIONSIZE 128

static XDAS_Int8 *inBuf;
static XDAS_Int8 *outBuf;
static XDAS_Int8 *versionBuf;   /* acquire optional version from codec */

static Void encode(SPHENC1_Handle enc, FILE *in, FILE *out);

int main(int argc, char *argv[])
{
    Engine_Handle ce = NULL;
    SPHENC1_Handle enc = NULL;
    String inFile, outFile;
    Engine_Error err;
    Int                 numAlgs;
    Engine_AlgInfo      algInfo;
    FILE *in = NULL;
    FILE *out = NULL;


   CERuntime_init();



    inBuf = (XDAS_Int8 *) Memory_contigAlloc(IFRAMESIZE, BUFALIGN);
    if(inBuf!=NULL)      printf("inbuf  address: %x\n",inBuf);
    outBuf = (XDAS_Int8 *)Memory_contigAlloc(OFRAMESIZE, BUFALIGN);
    if(outBuf!=NULL)    printf("outbuf address: %x\n",outBuf);
    versionBuf = (XDAS_Int8 *)Memory_contigAlloc(MAXVERSIONSIZE, BUFALIGN);
    if(versionBuf!=NULL) printf("versionBuf address: %x\n",versionBuf);


   
    if(inBuf!=NULL)
    printf("memory allocate success\n");

    printf("app running\n");

    if (argc <= 1) {
        inFile = "./in.dat";
        outFile = "./out.dat";
      
    }
    else if (argc != 3) {
        //fprintf(stderr, usage, argv[0]);
        exit(1);
    }
    else {
       
        inFile = argv[1];
        outFile = argv[2];
    }


 
    ce = Engine_open("sph", NULL, NULL);
    if (ce == NULL) {   
        printf("Error: could not open engine sphenc1  Error code %d.\n", err);
    }




    enc = SPHENC1_create(ce, "g711enc", NULL);
    if (enc != NULL) {
        printf("codec open success\n");
    }





    err = Engine_getNumAlgs("sph", &numAlgs);
    if(Engine_EOK==err)
    printf("engine getNumAlg succuss\n");


    /* open file streams for input and output */
    if ((in = fopen(inFile, "rb")) == NULL) {
        printf("App-> ERROR: can't read file %s\n", inFile);
    }
    if ((out = fopen(outFile, "wb")) == NULL) {
        printf("App-> ERROR: can't write to file %s\n", outFile);
    }



    XDM1_SingleBufDesc          inBufDesc;
    XDM1_SingleBufDesc          outBufDesc;
    SPHENC1_InArgs              encInArgs;
    SPHENC1_OutArgs             encOutArgs;
    encInArgs.size    = sizeof(encInArgs);
    encOutArgs.size   = sizeof(encOutArgs);
    inBufDesc.bufSize = NSAMPLES * sizeof(short);
    outBufDesc.bufSize = NSAMPLES * sizeof(char);

        Int32                       status;


        if(1== fread(inBuf, IFRAMESIZE, 1, in)  ) printf("read from file success!!!\n");
        inBufDesc.buf = inBuf;
        outBufDesc.buf = outBuf;



status =SPHENC1_process(enc, &inBufDesc, &outBufDesc, &encInArgs,&encOutArgs);
if (status == SPHENC1_EOK)
            printf("App-> Encoder frame             successful!\n");



    if (inBuf) {
        Memory_contigFree(inBuf, IFRAMESIZE);
    }
    if (outBuf) {
        Memory_contigFree(outBuf, OFRAMESIZE);
    }
    if (versionBuf) {
        Memory_contigFree(versionBuf, MAXVERSIONSIZE);
    }

    if (enc) {
        SPHENC1_delete(enc);
    }

    Engine_close(ce);

    return 0;

}

========================================================================================================my code

 

and below is the error print: in the terminal

========================================================================================================

inbuf  address: 4001c000
outbuf address: 40021000
versionBuf address: 40b2d000
memory allocate success

app running

codec open success
engine getNumAlg succuss
sphenc1 control success!!!!!!
read from file success!!!

CMEMK Error: get_phys: Unable to find phys addr for 0x0010f044
CMEMK Error: get_phys: get_user_pages() failed: -14

CMEMK Error: GETPHYS: Failed to convert virtual 0x10f044 to physical.
CMEM Error: getPhys: Failed to get physical address of 0x10f044

========================================================================================================

My makefile

========================================================================================================

-include ./Rules.make

XDC_PATH = $(CODEC_INSTALL_DIR)/packages;$(FC_INSTALL_DIR)/packages;$(CE_INSTALL_DIR)/packages;$(LINK_INSTALL_DIR)/packages;$(XDAIS_INSTALL_DIR)/packages;$(CMEM_INSTALL_DIR)/packages;/$(LINUXLIBS_INSTALL_DIR)/include;$(LPM_INSTALL_DIR)/packages;$(BIOS_INSTALL_DIR)/packages;$(BIOSUTILS_INSTALL_DIR)/packages;



CSTOOL_DIR=/home/FC/CodeSourcery/Sourcery_G++_Lite
XDC_INSTALL_DIR = /home/FC/dsprogram/xdctools_3_15_00_50/packages
INCLUDES += -I $(LINUXKERNEL_INSTALL_DIR)/include -I $(BIOS_INSTALL_DIR)/packages/ti/bios/include -I $(XDAIS_INSTALL_DIR)/packages/ti/xdais/include
LD_LIBS = -lpthread $(LINUXLIBS_INSTALL_DIR)/lib/libasound.so.2 $(LINUXLIBS_INSTALL_DIR)/lib/libncurses.so $(EDITLINE_LIB)
C_FLAGS += -Wall -fno-strict-aliasing -g -I./libedit -DREADLINE=1
CC = $(CSTOOL_PREFIX)gcc $(INCLUDES) $(C_FLAGS) $(shell cat $(XDC_COMPILER_FILE)) -c
AR = $(CSTOOL_PREFIX)ar
LN = $(CSTOOL_PREFIX)gcc


XDC_INSTALL_DIR=/home/FC/dsprogram/xdctools_3_15_00_50
XDCTARGET = gnu.targets.arm.GCArmv5T
XDCPLATFORM = ti.platforms.evm3530
XDC_COMPILER_FILE = $(CONFIGPKG)/compiler.opt
XDC_LINKER_FILE = $(CONFIGPKG)/linker.cmd

CONFIGPKG = sph
CONFIGURO = XDCPATH="$(XDC_PATH)"  $(XDC_INSTALL_DIR)/xs xdc.tools.configuro
CONFIG_BLD := config.bld


all:compiler.opt sphencode

compiler.opt:sph.cfg
    $(CONFIGURO) -c $(CSTOOL_DIR)  \
        -t $(XDCTARGET) -p $(XDCPLATFORM) -o $(CONFIGPKG) \
        -b $(CONFIG_BLD) $(CONFIGPKG).cfg

sphencode: sphencode.o $(CONFIGPKG)/linker.cmd
    $(LN) -o $@ $^ $(LD_LIBS)

%.o:%.c $(XDC_COMPILER_FILE)
    $(CC) $(CFLAGS) $(XDC_INCLUDES) -o $@ $<

========================================================================================================

 

 

That's all. I have worked on this problem for a long time. Please help, thanks !

 

  • I think this is b/c your your encInArgs struct has an uninitialized pointer (encInArgs.data.buf) that Codec Engine is internally trying (and failing!) to translate to a physical address.

    The example app doesn't initialize this [unused] encInArgs.data.buf to NULL either(!), so that seems like a bug in the example.  Can you confirm that simply assigning encInArgs.data.buf to NULL (so the Codec Engine doesn't try to translate that uninitialized address) resolves this?  If so, I'll file a bug against the example.

    Thanks!

    Chris

  • After a little internal checking, it looks like this _isn't_ a bug in the CE-provided example.  The 'speech' example you started from uses the SPHENC API (not the SPHENC1 API your app is using).  The SPHENC1 API introduced this encInArgs.data buffer that needs to be initialized.  The example we provide that uses SPHENC1 (ti/sdo/ce/examples/apps/speech1_copy) does initialize this encInArgs.data buffer to NULL.

    So, I don't think this is a bug in the example, but it still feels like it's a bug in your app.

    Chris

  • In fact, the 'speech' example uses SPHENC1 API not the SPHENC API. It includes <ti/sdo/ce/speech1/sphenc1.h> file and its function was all in it. (I'm using dvsdk_3_00_00_40 and codec_engine_2_24)

    I initialized encInArgs.data.buffer by issuing

        encInArgs.data.buf = NULL;

    and still the same error:

    ================================

    inbuf  address: 4001c000                                                       
    outbuf address: 40021000                                                       
    versionBuf address: 40b2d000                                                   
    memory allocate success                                                        
    app running                                                                    
    codec open successCMEMK Error: get_phys: Unable to find phys addr for 0x0010f044
                                                                                   
    engine getNumAlg succuss                                                       
    spheCMEMK Error: get_phys: get_user_pages() failed: -14                        
    nc1 control success!!!!!!                                                      
    read CMEMK Error: GETPHYS: Failed to convert virtual 0x10f044 to physical.     
    from file success!!!                                                           
    CMEM Error: getPhys: Failed to get physical address of 0x10f044  

    ================================

    I don't think there is something wrong in my C code because that  if I replace my code with app.c in 'speech' example , there will be the same error.

    So maybe I forget something in my makefile or something may be incorrect. It's really a hard work to write such a makefile.

  • Dwight,

    I've been looking into possible causes of your issue but am coming up empty.  There are 3 calls to Memory_getBufferPhysicalAddress() in the "process()" function of the SPHENC1 stubs file.  We see the good result from the first two and then a bad result.  The 3rd call to Memory_getBufferPhysicalAddress() is for the encInArgs.data.buf, so we've got to assume this is the one that is failing.  But if you are indeed setting encInArgs.data.buf = NULL then I'm at a loss to explain the bad return, since the stubs' process() function doesn't do the translation when the buf is NULL.  Can you double-check that you're doing that assignment correctly?  Is there a possibility that the stack-based local var is getting overwritten somehow?  The "size" value is interesting - it is 0x40148000, which looks suspiciously like a virtual address, but since you're not initializing encInArgs.data.bufSize (since you shouldn't need to when setting buf to NULL) then I suppose any value could be there.

    I would agree that the example does have a bug in not initializing encInArgs.data.buf = NULL, so I was wondering how it always passes our testing.  When I ran the example on the OMAP3530 it passed always.  I even put a print in the stubs file to pring the data.buf element, and it indeed was NULL so no attempt at translation even happens.  I suppose we're getting "lucky" here in that the stack contents for the encInArgs local var is always 0.  That's why I'm questioning your assertion that you are setting encInArgs.data.buf to NULL, since I don't see how there could be this problem if you are.

    Regards,

    - Rob

  • Hi,you are right. I'm sorry I made a stupid mistake I add encInArgs.data.buf = NULL in a commentted function. When I add it to the correct place the app could run!

    Thank you both very much!

  • I'm glad to hear that it's working for you.  I will be filing a bug report on the CE "speech" example.

    Thankyou for you assistance in helping us find this.

    Regards,

    - Rob