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.

DM8148 PhyAddr and Virtaddr



Hi 

  I'm getting frame frome M3 to A8  , and i want to copy frame to other A8_buffer .

  On A8 side , i had received frame information.

  i'm trying to use phyaddr or virtaddr copy frame to other buffer , but  Segmentation fault .

  why Segmentation fault?

  How should i do?

------------------------------------------------------------------

static Void * VcapVenc_ipcFramesSendRecvFxn(Void * prm)
{
VcapVenc_IpcFramesCtrlThrObj *thrObj = ( VcapVenc_IpcFramesCtrlThrObj *) prm;
static Int printStatsInterval = 0;
VIDEO_FRAMEBUF_LIST_S bufList;
Int status;
FILE * fPtr = NULL;
UInt32 pMemVirtAddr=0;
unsigned char * test[10]={'a','b','c','d','e','f','g','h','i','j'};
unsigned char copy_buffer[1920*1080];

#ifdef CUSTOM_SD_DEMO
VcapVenc_ipcFramesFileOpen();
#endif

while (FALSE == thrObj->exitFramesInOutThread)
{
OSA_semWait(&thrObj->framesInNotifySem,OSA_TIMEOUT_FOREVER);

status = Vcap_getFullVideoFrames(&bufList,0);
OSA_assert(0 == status);
if (bufList.numFrames)
{
//VcapVenc_ipcFramesPrintFullFrameListInfo(&bufList,"FullFrameList");
#ifdef CUSTOM_SD_DEMO
VcapVenc_ipcFrameFileWrite(&bufList);
#endif
printf("phyAddr=0x%x , virAddr=0x%x\n",bufList.frames[0].phyAddr[0][0] , bufList.frames[0].addr[0][0]);

//Virt
memcpy(copy_buffer , bufList.frames[0].addr[0][0] ,1920*1080);

//Phy
memcpy(copy_buffer , bufList.frames[0].phyAddr[0][0] ,1920*1080);

//status = Vdis_putFullVideoFrames(&bufList);
OSA_assert(0 == status);
}

//status = Vdis_getEmptyVideoFrames(&bufList,0);
//status = Vcap_putEmptyVideoFrames(&bufList);
//OSA_assert(0 == status);
if (bufList.numFrames)
{
//printf("EmptyFrameList\n");
//VcapVenc_ipcFramesPrintFullFrameListInfo(&bufList,"EmptyFrameList");
status = Vcap_putEmptyVideoFrames(&bufList);
OSA_assert(0 == status);
}
#ifdef IPC_BITS_DEBUG
if ((printStatsInterval % MCFW_IPCFRAMES_INFO_PRINT_INTERVAL) == 0)
{
OSA_printf("MCFW_IPCFRAMES:%s:INFO: periodic print..",__func__);
}
#endif
printStatsInterval++;
OSA_waitMsecs(MCFW_IPCFRAMES_SENDRECVFXN_PERIOD_MS);
}
#ifdef CUSTOM_SD_DEMO
if(gVcapVenc_ctrl.fileFrameWriteEnable)
{
if(gVcapVenc_ctrl.fileFrameWriteState==FILE_WRITE_RUNNING)
{
fclose(gVcapVenc_ctrl.fp);
printf(" Closing file [%s] for CH%d\n", gVcapVenc_ctrl.fileFrameWriteName, gVcapVenc_ctrl.fileFrameWriteChn);
}
}
#endif
return NULL;
}

  • Hi Shawn Shiu,

    Please find some pointers below :
    1. Do not use phyical address, as host uses only virtual memory space.
    2. Use Virtual Address, which is populated in addr only when exportOnlyPhyAddr is set to true in create args of IPCframesInLink of host.
    3. Please verify that the size of memcpy is correct. The resolution details can be obtained from framePitch/frameHeight.

    Regards,
    Shwetha
  • Hi Shwetha KN

     Thank you for your reply , but i want you help to me again.

     I'm try again , but still Segmentation fault.

     See that ,  It's my print frame_information.

     [host] MCFW_IPCFRAMES:VIDFRAME_INFO:
      virt[0][0]:0x5ac1880,
      phy[0][0]:0xadac1880,
      channelNum:0,
      fid:0,
      frameWidth:1920,
      frameHeight:1080,
      framePitch[0]:1920,
      framePitch[1]:1920,
      timeStamp:18784,

     and than i try to copy 10 bytes from virtaddr to other buffer.

      //Test Copy 10bytes

      unsigned char test_cpy[1920*10];
      memcpy(test_cpy , (unsigned char *)bufList.frames[0].addr[0][0] , 10);

      Why am i copy still fail?

  • Hi Shawn,

    Have you try to write yuv Frame into file?

    I think you need to map memory using below API then only you can copy frame to other buffer.

    App_mMap((UInt32)(bufList.frames[0].addr[0][0]), frameSize, &pMemVirtAddr);

    Regards,

    Prashant

  • Hi Shawn,

    I hope the above inputs were helpful in solving your issue. If the issue is solved then please close it by verifying answer.

    regards,
    Anuj
    Pathpartner Technology Pvt Ltd.