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.

Linux/AM5728: IVA-HD Engine_open() memory access

Part Number: AM5728


Tool/software: Linux

Hello, I am creating an application that will use the IVA-HD decoder on the AM57x EVM, and I am having an issue with the Engine_open() API call (from the libdce library).  When called with the arguments:

engine = Engine_open("ivahd_vidsvr", NULL, &ec) I am receiving segmentation faults.

I have tracked this issue to when omap_bo_new() is called within memplugin_alloc() within Engine_open, however the source file that holds omap_bo_new() is a precompiled binary and I cannot get my debugger to reveal any more before the segfault occurs.

My guess is that I am trying to allocate memory in a space that I am not allowed to, rather than memory not being generally available.  Perhaps I am not allocating memory properly because my program cannot look in the IVA-HD's IPU controller's memory?  I am compiling with the arm-linux-gnueabihf-gcc toolchain on the EVM itself.  Is that incorrect?

Essentially, my question boils down to 'Is there a correct way to compile a program that uses the IVA-HD in such a way that Engine_open() can see the IVA-HD subsystem?'
 

  • The software team have been notified. They will respond here.
  • Hello, is there any word from the software team?  It's the Monday after a long weekend, so I understand if some are taking the day off.  Just making sure that this query doesn't get lost.

  • Looks like you are running out of TILER memory. How many buffers have you allocated for the codec? The buffers coming from TILER memory and that is restricted to 128 MB in size.
  • Currently I am only failing at the Engine_open stage, passing

    "Engine_open("ivahd_vidsvr", NULL, &ec);"

    However, I should only be allocating 60 bytes for my decoder struct (or at least that's how big the struct I'm using to represent a codec is) and roughly 28kB of jpeg data to be decoded.  Unless I missed several zero's somewhere, I doubt that I'm trying to pull 128MB with an Engine_open() call.  

    I explored some further debugging options and found these error messages which seem to corroborate my theory of the program not seeing the TILER memory.  They are as follows:

    [ 466.208051] omap-iommu 55082000.mmu: 55082000.mmu: version 2.1
    [ 1301.138421] virtio_rpmsg_bus virtio1: msg received with no recipient

    As an addenum, here is the codec structure that I mentioned:

    typedef struct decoder{

    Engine_Handle engine;
    VIDDEC3_Handle codec;
    VIDDEC3_Params *params;
    VIDDEC3_DynamicParams *dynParams;
    VIDDEC3_Status *status;
    XDM2_BufDesc *inBufs;
    XDM2_BufDesc *outBufs;
    VIDDEC3_InArgs *inArgs;
    VIDDEC3_OutArgs *outArgs;
    char *input;
    int id;
    int padded_width;
    int padded_height;
    int orig_width;
    int orig_height;

    }decoder;

  • I have also created a dummy application where all it does is call Engine_open() with the same parameters, no other memory buffers are present in the application.  I receive the same SEGFAULT error from /usr/liblibdrm_omap.so.1 

    I can also confirm that gstreamer applications that use the IVA-HD are functional.

    Here is the dummy C program that I mentioned.

    #include <sys/types.h>
    #include <sys/time.h>
    #include <sys/mman.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <errno.h>
    #include <signal.h>
    #include <unistd.h>
    
    #include <xdc/std.h>
    #include <ti/sdo/ce/Engine.h>
    #include <ti/sdo/ce/video3/viddec3.h>
    #include <ti/sdo/codecs/jpegvdec/ijpegvdec.h>
    #include <dce/libdce.h> 
    
    /*---------------------LOCAL DEFINES---------------------*/
    #define SLICEFIFOLEN 3200
    #define SLICESIZE 8192
    #define PRINT_DEBUG
    /*get codec version through XDM_GETVERSION*/
    #define GETVERSION
    #define STRIDE 4096
    //#define JPEGSLICE
    
    
    /*---------------------LOCAL MACROS---------------------*/
    #define ERROR(FMT, ...)  printf("%s:%d:\t%s\terror: " FMT "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)
    /*enable below to print debug information*/
    #ifdef PRINT_DEBUG
    #define DEBUG(FMT, ...)  printf("%s:%d:\t%s\tdebug: " FMT "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)
    #else
    #define DEBUG(FMT, ...)
    #endif
    
    
    /* align x to next highest multiple of 2^n */
    #define ALIGN2(x, n)   (((x) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
    #define PADX ALIGN2(1920, 4)
    #define PADY ALIGN2(1080, 4)
    
    int main(){
    	Engine_Handle engine = NULL;
    	Engine_Error ec;
    	engine = Engine_open("ivahd_vidsvr", NULL, &ec);
    
    	if(!engine){
    		ERROR("could not open engine!: %p\n", ec);
    		return 1;
    	}
    	DEBUG("engine opened\n");
    
    	return 0;
    }

  • Are you using custom board and custom software to develop and test this application or using PLSDK and AM57x IDK/GP EVM from TI? If using TI PLSDK, any changes done to the dts file/bootargs or any other software?

    Are you able to run gstreamer pipeline involving ductai plugins using gst-launch?
  • 1. Using a TI AM57x EVM with PSDK 3.02.05 no modifications to dts/bootargs. Only a systemd bootscript for ethernet configuration.

    2. I can run gstreamer pipelines, but frequently receive errors such as:
    libdce_linux.c:145: dce_buf_unlock ERROR: Failed eError == DCE_EOK error val -5MmRpc_use: Error: unable to declare buffer use
    libdce_linux.c:115: dce_buf_lock ERROR: Failed eError == DCE_EOK error val -5MmRpc_release: Error: unable to release buffer

    These errors occur for h264 encoding, but not for jpeg decoding
  • The error that you are seeing with encoder gst plugin is a known issue with that plugin and we are investigating the issue.

    Regarding the error you are seeing with Engine_open() call, are you able to run out of box viddec3test binary for h.264 and mpeg-4 stream? Have you looked at this code -
    git.ti.com/.../viddec3test.c

  • Yes I have run the code, (viddec3test -w 800x600 airshow_p352x288.h264)

    It does not run, stating that the MmRpc_use cannot declare buffer use. It cannot process the buffer there either.

    It does however open the engine successfully.
  • I just tried viddec3test application at my end and it worked fine for me. I am using PSDK version 3.3. Make sure you have weston running when using -w as cmd line args. You can start weston server by running the script -
    #/etc/init.d/weston start
  • I have been using Weston the whole time, actually. I will try PSDK v3.3 and report back.
  • I have installed PSDK 3.3, and the viddec3test application works correctly. However, since I would like to create my own application using the IVA-HD (in C) I find that I lack the required header files. After installing libdce (from here: git.omapzoom.org/.../ and running the Engine_open test code above, it results in the same error.
  • I didn't get exactly which headers file are missing and from where. Required software are developed and maintained here -
    http://git.ti.com/glsdk/
  • As far as I can tell from reading through the viddec3test source code, I would require libdce.h, and with that would also require the dce project from https://git.ti.com/glsdk to be built.
  • Oh. You can build your application from arago build project as well and can get rid of all these dependencies of downloading component from incorrect repo. That's where omapdrmtest is built from (viddec3test is part of it).

    Check this link. To begin with, you can add your application to omaprmtest folder and update the bitbake recipe with files that you added.
    processors.wiki.ti.com/.../Processor_SDK_Building_The_SDK

    You can compile omapdrmtest using -
    MACHINE=am57xx-evm bitbake omapdrmtest
  • Would I have to re-make the omapdrmtest project every time I need to recompile my application? We've had this conversation before I feel, except it was about Yocto.
  • Oh I remember that conversation now. Yes this is same recommendation (building through Yocto). You have three choices -

    1. Build omapdrmtest through yocto and then copy all the dependent files and library from yocto build to your application (in your build setup) and then build your application outside Yocto. 
    2. Enhance omapdrmtest with your custom application and build your custom application through yocto. You can do your source code changes in local copy of the yocto project. You will need to compile the omapdrmtest if your application is part of that build setup everytime you do changes to your code. You can use below isntructions for building ompadrmtest with your changes and for any incremental build -

                  MACHINE=am57xx-evm bitbake omapdrmtest -c cleanal

                  MACHINE=am57xx-evm bitbake omapdrmtest --f -c compile

    3. Make your own project inside yocto (config, bitbake recipes following omapdrmtest /or strip the omapdrmtest of all the files that you don't need and add your files to it) and build your project through yocto following above build instructions. 

  • I'll get started on that and inform you of the results.
  • Hello Manisha, quick question: if I pursue option 1 in your last post, how would I go about building omapdrm test through yocto? That is, to get the dependent files and library?