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.

[FAQ] SK-TDA4VM: How to build and compile tiovx on board

Part Number: SK-TDA4VM

Hello

I want to compile the demo examples provided in TIOVX directly on the board. What libraries, header files, or other operations are required?

Based on the demo in the TIOVX User Guide, I have written the following code.

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <VX/vx.h>
#include <TI/tivx.h>

#define         IN_FILE_NAME          "./colors.bmp"
#define         OUT_FILE_NAME         "./vx_image_load_save_out.bmp"

int main(int argc, char *argv[])
{
  vx_context context;
  vx_image image;
  vx_uint32 width, height;
  if (appCommonInit() == 0) {
    tivxInit();
    tivxHostInit();
    
    /* Create OpenVX context */
    context = vxCreateContext();

    /* Create image object */
    
    image = tivx_utils_create_vximage_from_bmpfile(context, IN_FILE_NAME, (vx_bool)vx_false_e);
    vxSetReferenceName((vx_reference)image, "BMP_IMAGE");

    /* Query image object */
    vxQueryImage(image, (vx_enum)VX_IMAGE_WIDTH, &width, sizeof(vx_uint32));
    vxQueryImage(image, (vx_enum)VX_IMAGE_HEIGHT, &height, sizeof(vx_uint32));
    printf("Loaded image of dimensions %dx%d\n", width, height);

    /* Save image object to bitmap file */
    tivx_utils_save_vximage_to_bmpfile(OUT_FILE_NAME, image);

    /* Release image object */
    vxReleaseImage(&image);
    /* Release context object */
    vxReleaseContext(&context);

    tivxHostDeInit();
    tivxDeInit();
    appCommonDeInit();
  }

  return EXIT_SUCCESS;
}

And I have copied the corresponding header files needed for compilation.

tivx.h
tivx_config.h
tivx_debug.h
tivx_event.h
tivx_ext_raw_image.h
tivx_ext_super_node.h
tivx_kernels.h
tivx_log_rt.h
tivx_mem.h
tivx_mutex.h
tivx_nodes.h
tivx_obj_desc.h
tivx_queue.h
tivx_soc.h
tivx_soc_j721e.h
tivx_target_kernel.h
tivx_task.h
tivx_tensor.h
vx.h
vx_api.h
vx_compatibility.h
vx_kernels.h
vx_khr_pipelining.h
vx_khr_user_data_object.h
vx_nodes.h
vx_types.h
vx_vendors.h
vxu.h

Modified the header file referenced in tivx.h from tivx_soc.h to tivx_soc_j721e.h, and successfully compiled using the following command.

gcc -o save_image save_image.c -ltivision_apps

When I run it, it shows a Segmentation fault, the full log information is as follows.

root@j721e-evm:~# ./save_image
APP: Init ... !!!
MEM: Init ... !!!
MEM: Initialized DMA HEAP (fd=5) !!!
MEM: Init ... Done !!!
IPC: Init ... !!!
IPC: Init ... Done !!!
REMOTE_SERVICE: Init ... !!!
REMOTE_SERVICE: Init ... Done !!!
  8041.782433 s: GTC Frequency = 200 MHz
APP: Init ... Done !!!
  8041.782517 s:  VX_ZONE_INIT:Enabled
  8041.782527 s:  VX_ZONE_ERROR:Enabled
  8041.782536 s:  VX_ZONE_WARNING:Enabled
  8041.783296 s:  VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
  8041.783754 s:  VX_ZONE_INIT:[tivxHostInitLocal:101] Initialization Done for HOST !!!
Segmentation fault (core dumped)

  • Hi,

    Could you please check where exactly in the segmentation fault being hit by putting more logs?

    Is it while doing tivx_utils_create_vximage_from_bmpfile()?

    May I know which SDK have you flashed in your SK board? Is it the edgeAI SDK?

    Also which SDK version is this?

    Regards,

    Nikhil

  • Hello,

    The error is located at this statement vxSetReferenceName((vx_reference)image, "BMP_IMAGE"); I'm wondering if it's because the call to tivx_utils_create_vximage_from_bmpfile failed.

    I have flashed ti-processor-sdk-rtos-j721e-evm-09_01_00_06.

    Thanks,

    Lebin

  • Hi Lebin,

    You could use "status =  vxGetStatus((vx_reference) image)" API before vxSetReference(), to check if the image creation is successful or not.

    Regards,

    Nikhil

  • Hi Nikhil,

    I found that any API operations on the image will cause the program to crash.

    Thanks,

    Lebin

  • Hi Lebin,

    Could you please check if your input file path contains colors.bmp?

    I tried this at my end, i.e. placed the below app.c on /opt/vision_apps path and pointed to colors.bmp in the /opt/vision_apps/test_data folder

    Below is my application (same as yours except for the IN_FILE_PATH)

    /cfs-file/__key/communityserver-discussions-components-files/791/2577.app.c

    Below the command I ran at /opt/vision_apps folder to build the application

    gcc app.c -I/usr/include/processor_sdk/tiovx/include/ -I/usr/include/processor_sdk/tiovx/kernels/include/ -I/usr/include/processor_sdk/vision_apps/utils/app_init/include/ -I/usr/include/processor_sdk/tiovx/kernels_j7/include/ -I/usr/include/processor_sdk/tiovx/utils/include/ -DSOC_J721E -ltivision_apps

    This generated a.out which executed successfully.

    Could you try the same at your end?

    Regards,

    Nikhil

  • Hello Nikhil,

    Thank you for your help, I have resolved the problem.

    The reason for this problem is that I forgot to include the header files app_init.h and tivx_utils_file_rd_wr.h, yet I was able to compile successfully.

    Thanks,

    Lebin