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.

TDA2EG: iss-capture link dump frame command

Part Number: TDA2EG

Hi

    I am working on the CSI2 usecase, and try to dump the frame from capture to save it as a image file in the SD card.

    This thread "https://e2e.ti.com/support/arm/automotive_processors/f/1021/t/661663?tisearch=e2e-sitesearch&keymatch=%20user%3A340760#pi320098=1

used to dump the frame out if the link is iss-capture.

    So i want to ask that if there are some docs or examples about how to use these frame dump commands?

Thanks

xuanbo

  • Hi xianbo,

    If you are using VSDK single channel ISS usecase, then, just run this usecase, it will show up few menu options while usecase is running. One of them option is to dump the captured frames. Please select this option, it will automatically save dumped captured frame into SD card.

    If you are not using this usecase, then there is a control command in the capture link to get the dumped buffer, you could get this buffer in the application and write it to the SD card.

    Regards,

    Brijesh 

  • Hi Brijesh

    I am using the csi2_cal_multi_cam_view usecase, not the single channel ISS usecase.
    Could you explain more about the control command to get the dumped buffer? or give me the related docs or examples path about how to use the commands in the capture link?

    Thanks
    xuanbo
  • Hi xuando,

    First you need to enable allocation of buffer for the dumping by setting allocBufferForRawDump to TRUE in the usecase.
    The control command to save frame is ISSCAPTURE_LINK_CMD_SAVE_FRAME and to get frame status, it is ISSCAPTURE_LINK_CMD_GET_SAVE_FRAME_STATUS

    Please find below sample code

    System_linkControl(
    chainsObj.ucObj.IssCaptureLinkID,
    ISSCAPTURE_LINK_CMD_SAVE_FRAME,
    &chId,
    sizeof(chId),
    TRUE);

    do {
    System_linkControl(
    chainsObj.ucObj.IssCaptureLinkID,
    ISSCAPTURE_LINK_CMD_GET_SAVE_FRAME_STATUS,
    &rawSaveFrameStatus,
    sizeof(IssCaptureLink_GetSaveFrameStatus),
    TRUE);
    } while (rawSaveFrameStatus.isSaveFrameComplete == FALSE);

    Regards,
    Brijesh
  • Hi Brijesh

    Thank you for your explaination. I found the src code in the “chains_issIspSimcop_Display.c”
    I have set the allocBufferForRawDump to TRUE, and use the code you suggested. But i got a problem that "rawSaveFrameStatus.isSaveFrameComplete" is always FALSE, it can not change to TRUE, so my app is always stuck at the do while loop.
    Are there any ways to debug this problems? or are there other flags status i can check to prove the camera sensor is working and buffer has the image data captured?

    Thanks
    xuanbo
  • Hi xuanbo,

    That could mean capture is not working.. Are you seeing captured frames? can you put break point in capture callback and see if it gets called?

    Rgds,
    Brijesh
  • Hi Brijesh

    Yes, i want to see the captured frames as i do not have the display device right now. My usecase is "csi2_cal_multi_cam_view", and i have the log as follows:

    ...
    VIDEO_SENSOR: Detected 4 Camera modules !!!
    (which means the I2C between TDA2Ex and UB964 and 4 cameras is good)
    ...
    ISSCAPTURE: Start in progress !!!
    ISSCAPTURE: Start Done !!!
    (Does this log means that capture is working?)
    ...
    Chains Run-time Menu
    ...

    to here, it can respond to the "p:Print Performance Statistics" and "1:switchDisplayChannel" request from keyboard input.

    So, i think my capture part is working, is it?

    Thanks
    xuanbo
  • Hi Brijesh

         I think i have found the cause of problem, it may be a bug of Vision SDK:

        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        vision_sdk\links_fw\src\rtos\links_ipu\iss_capture\issCaptureLink_drv.c: 

    Int32 IssCaptureLink_drvSaveFrame(IssCaptureLink_Obj *pObj, UInt32 *chId)
    {
    Int32 status = SYSTEM_LINK_STATUS_EFAIL;
    if (pObj->createArgs.allocBufferForRawDump != 0U)
    {
    pObj->saveFrame = TRUE;
    pObj->saveChId = *chId;
    status = SYSTEM_LINK_STATUS_SOK;
    }
    return (status);
    }

    Int32 IssCaptureLink_drvGetSaveFrameStatus(const IssCaptureLink_Obj *pObj,
    IssCaptureLink_GetSaveFrameStatus *pPrm)
    {
    Int32 status = SYSTEM_LINK_STATUS_EFAIL;

    pPrm->isSaveFrameComplete = FALSE;
    pPrm->bufAddr = 0;
    pPrm->bufSize = 0;

    if (pObj->createArgs.allocBufferForRawDump != 0U)
    {
    if(pObj->saveFrame == FALSE)
    {
    pPrm->isSaveFrameComplete = TRUE;
    /* MISRA.CAST.PTR_TO_INT
    * MISRAC_2004 Rule 11.3
    * Cast between a pointer and an integral type
    * KW State: Defer -> Waiver -> Case by case
    * MISRAC_WAIVER: The pointer addresses are stored in the form of
    * UInt32. The pointer address is checked after it is allocated so
    * it contains only valid address from the heap.
    */
    pPrm->bufAddr = (UInt32)pObj->saveFrameBufAddr;
    pPrm->bufSize = pObj->drvCalCfg.inFmt[0].pitch[0] *
    pObj->createArgs.outParams[0U].height;

    }

    status = SYSTEM_LINK_STATUS_SOK;
    }

    return (status);
    }

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    We can see that IssCaptureLink_drvSaveFrame's purpose is to set the pObj->saveFrame from false to true, then the real buffer damp work can be done in the IssCaptureLink_drvGetSaveFrameStatus(). So, in the  IssCaptureLink_drvGetSaveFrameStatus, i think we should use "if(pObj->saveFrame == TRUE)", not the "if(pObj->saveFrame == FALSE)". After i change this, i can get the RAW file in the SD card:

    [IPU1-0] 189.633868 s: filename raw0004.raw 4 exists... skipping
    [IPU1-0] 189.636308 s: FILE: Writing to file [raw0005.raw] (1843200 bytes) ...
    [IPU1-0] 205.361770 s: FILE: File write done. [1843200 bytes]
    [IPU1-0] 205.366497 s: Wrote image raw0005.txt to file
    [IPU1-0] 205.366589 s: FILE: Writing to file [raw0005.txt] (24 bytes) ...
    [IPU1-0] 205.491947 s: FILE: File write done. [24 bytes]

    Thanks

    xuanbo

  • Hi Xuanbo,

    Can you please check the contents of register CAL_CSI2_STATUS0_l at 0x4845 B350 (provided you are using PHY 0).

    If you don't have access to CCS, probably you could print the contents of this register in the usecase itself (after creation). 

    Regards, Sujith

  • hi xuanbo,

    no that's not correct. condition should not be changed in GetSaveFrameStatus. There is no bug in the code.
    Essentially, drvSaveFrame API sets the flag and if this flag is set, processdata API DMAs the captured buffer into separate memory section. When GetSaveFrameStatus is called, it checks if this flag is reset by ProcessData API, then frame is dumped into memory section.. otherwise not..

    In your case, since frame is not getting captured, most likely capture is not working.. Please check status of this register 0x4845 B350?
    If the value at this location is changing, then input stream is detected...

    Rgds,
    brijesh
  • Hi brijesh

          Thank you for your explaination.

          I have checked the value of register 0x4845 B350, it is always 0. So the capture is not working? But why there is the log "ISSCAPTURE: Start Done !!!"?

          Since the I2c communication between TDA2Ex and UB964 and UB913 and 4 cameras is OK, why the capture will be failed? what the possible reasons are?

          You have mentioned that i should put break point in the capture link, how should i do this? Could you explain more about how to debug this capture failure?

    Thanks

    xuanbo

  • Hi brijesh

    By the way, My board is a custom board based on TDA2EX, which connects UB964's CSI0_CLKN/P,CSI0~3_D0N/P with TDA2EX's CSI2_0_DX/Y0~4.
  • Hi brijesh

    And my board do not use the HDMI interface, so the display part of usecase is ignored temporarily.
    Will the display link affect the capture link?
  • Hi xuanbo,

    Well this means capture module is not recognized incoming stream most likely. Can you please also share the value at the offset 0x4845 B304?

    Which sensor are you using on TDA2Ex?

    Regards,
    Brijesh
  • No HDMI does not affect capture link and this is not the link issue. We need to first make sure that the capture module is able to recognize the incoming stream. Lets check the value at the said register.
  • Hi Brijesh

    The value of register 0x4845 B304 is 4a054321.
    Sensor? you mean camera sensor? it is OV10635.

    Thanks
    xuanbo
  • Hi Brijesh

         I think i have solved the dump problem! 

         Thank you for your suggestion about the value of register 0x4845 B304, then i notice the CSI2 polarity set.
         The default setting of usecase is all false, but my custom board is:

          (TDA2EX)CSI2_0_DX1 <-> CSI0_D0N (UB964)

           (TDA2EX)CSI2_0_DY1 <-> CSI0_D0P (UB964)

         which means i should set the CSI2 polarity to TRUE.

         After i change the polarity, the dump command can work now! And RAW file can be found at the SD card!

        Thank you for your good suggestion.

        And i still have another question about the software tool to open the RAW file. I have downloaded a YUVPlayer to open it, and the result is like this:

       

         As you see this is not the image we want. I think the dumped frame is good, but my viewer is not correct. So what RAW file viewer should i use?

    Thanks 

    xuanbo

       

  • Hi xuanbo,

    Great, that's good news. Do you also see frame counter incremental?

    We use IrfanView tool to view raw bayer images. This tool is freely available. Please note you require to install additional plugins to view raw bayer images.

    Rgds,
    Brijesh
  • Hi Brijesh

    I found the proper RAW viewer to see the dump frame file.
    Thank you for your help all the time. You are a very good "teacher".

    Thanks
    xuanbo
  • Hi Brijesh

    After i change the setting of YUV Viewer, it is one frame image, and i did not see any frame counter incremental any more.

    Thanks
    xuanbo