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.

Compiler: malloc warning while linking

Tool/software: TI C/C++ Compiler

Hi Guys,

I am facing some linking issue, need your help for the same. my steps are below. using ccs 7,4 for compilation and using ccs5.4 for simulator (I believe CCS version is not a issue)

I am creating simple project for EVE, it compiles and runs well on simulator (i am playing with simulator not on actual hardware due to some reason).

now if i use malloc in the same project for image processing i get below warning (here good thing is it creates the .out file ) and when i run the program i see some warning and dont get the expected output.
I guess if compilation warning can me removed everything shall run fine but not able to luck how to get rid of that.

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

compilation warning

'Building file: "../src_kernelC/vcop_array_add_uns_char.c"'
'Invoking: EVE Compiler'
"D:/TI-Automotive/for_CCS_7.3/ccs7.4/ccsv7/tools/compiler/arp32_1.0.9/bin/cl-arp32" -v210 -g --include_path="D:/TI-Automotive/for_CCS_7.3/ccs7.4/ccsv7/tools/compiler/arp32_1.0.9/include/vcop" --include_path="D:/TI-Automotive/for_CCS_7.3/workspace_eve/array_add_uns_char" --include_path="D:/TI-Automotive/for_CCS_7.3/ccs7.4/ccsv7/tools/compiler/arp32_1.0.9/include" --diag_warning=225 --display_error_number --diag_wrap=off --preproc_with_compile --preproc_dependency="src_kernelC/vcop_array_add_uns_char.d_raw" --obj_directory="src_kernelC"  "../src_kernelC/vcop_array_add_uns_char.c"
'Finished building: "../src_kernelC/vcop_array_add_uns_char.c"'
 
'Building target: "array_add_uns_char.out"'
'Invoking: EVE Linker'
"D:/TI-Automotive/for_CCS_7.3/ccs7.4/ccsv7/tools/compiler/arp32_1.0.9/bin/cl-arp32" -v210 -g --diag_warning=225 --display_error_number --diag_wrap=off -z -m"array_add_uns_char.map" -i"D:/TI-Automotive/for_CCS_7.3/ccs7.4/ccsv7/tools/compiler/arp32_1.0.9/lib" -i"D:/TI-Automotive/for_CCS_7.3/ccs7.4/ccsv7/tools/compiler/arp32_1.0.9/include" --reread_libs --warn_sections --xml_link_info="array_add_uns_char_linkInfo.xml" --rom_model -o "array_add_uns_char.out" "./src_kernelC/vcop_array_add_uns_char.obj" "./src_kernelC/vcop_array_add_uns_char_kernel.obj" "../src_kernelC/linker.cmd"  -llibc.a
<Linking>
warning #10247-D: creating output section ".imemha" without a SECTIONS specification
warning #10247-D: creating output section ".imemhb" without a SECTIONS specification
warning #10247-D: creating output section ".imemla" without a SECTIONS specification
warning #10247-D: creating output section ".imemlb" without a SECTIONS specification
warning #10247-D: creating output section ".wmem" without a SECTIONS specification

'Finished building target: "array_add_uns_char.out"'

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

warning while running the output on simulator

EVE_1: Warning: multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space multi_eve_subsystem.EVE_0.MEM_SWITCH: Invalid access to reserved space

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

Thanks,

mohammed

  • You need to start with ...

    mohammed zakariya ansari said:
    warning #10247-D: creating output section ".imemha" without a SECTIONS specification
    warning #10247-D: creating output section ".imemhb" without a SECTIONS specification
    warning #10247-D: creating output section ".imemla" without a SECTIONS specification
    warning #10247-D: creating output section ".imemlb" without a SECTIONS specification
    warning #10247-D: creating output section ".wmem" without a SECTIONS specification

    You should never see that.  This is caused by a lack of entries in your linker command file.  In your case it is the file "../src_kernelC/linker.cmd".  Another, less likely, possibility is you are missing a linker command file.  Where does this linker command file come from?  If you wrote it, then I can work the details directly with you.  If you got it from some other team at TI, then it is better to work the issue with them.

    Thanks and regards,

    -George

  • Hi George,

    Thanks for hint,

    for your update linker file i am using for this project is came with the SDk installation (EVE software release package). When i compile the code (say for sobel algorithm) as it it compiles, runs and gives expected output but as soon as i am modifying the same program (say i am malloc for vector processing) i see this warning while compilation.

    Any more help appreciated.

    Thanks,

    Mohammed

  • Hi Mohammed,

    I have forwarded your question to EVE experts.

    Regards,
    Yordan
  • Thanks Yordan,

    Awaiting update...

  • Yordan,

    i am attaching my application, kernel and linker file for reference, see if it helps the guys. change the extension before use as follows

    app.txt to app.c

    gradient.txt to gradient.k

    link.vcop.txt to link.vcop.cmd

    content in gradient.h is as below

    void vcop_vec_gradients
    (
    __vptr_uint8 in_ptr,
    __vptr_uint8 out_ptr,
    unsigned short width,
    unsigned short height
    );

    attached project .rar file if need more details.

    Appreciate the help.

    thanks,

    Mohamed

    eve_sample_kernel.rar

    /*==========================================================================*/
    /*      Copyright (C) 2009-2013 Texas Instruments Incorporated.             */
    /*                      All Rights Reserved                                 */
    /*==========================================================================*/
    
    /*----------------------------------------------------------------------------*/
    /* NAME: eve_array_add_uns_char                                               */
    /*                                                                            */
    /*                                                                            */
    /* DESCRIPTION:                                                               */
    /*                                                                            */
    /* The function "eve_array_add_uns_char_     " takes two input arrays         */
    /* in1_ptr and in2_ptr, and adds the values in them writing it out to         */
    /* the output array "optr". The input and output arrays are 2D arrays         */
    /* of the form [width * height].                                              */
    /*                                                                            */
    /* The function has the following prototype:                                  */
    /*                                                                            */
    /* void eve_array_add_uns_char_                                               */
    /* (                                                                          */
    /*    __vptr_uint8  in1_ptr,         // input 1 data pointer                  */
    /*    __vptr_uint8  in2_ptr,         // input 2 data pointer                  */
    /*    __vptr_uint8  optr,            // output data pointer                   */
    /*           Uint16 width,           // width of each line                    */
    /*           Uint16 height           // height of each line                   */
    /* )                                                                          */
    /*                                                                            */
    /* ASSUMPTIONS:                                                               */
    /*                                                                            */
    /* This function does not expect any alignment restrictions on "in1_ptr"      */
    /* "in2_ptr" and "optr". It expects the width to be a multiple of 8, and      */
    /* can be as small as 8.                                                      */
    /*                                                                            */
    /*----------------------------------------------------------------------------*/
    /* Texas Instruments Incorporated 2010-2012.                                  */
    /*============================================================================*/
    
    
    #define ELEMSZ          sizeof(*in_ptr)
    #define VECTORSZ        (VCOP_SIMD_WIDTH*ELEMSZ)
    
    void vcop_vec_gradients
    (
    __vptr_uint8 in_ptr,
    __vptr_uint8 out_ptr,
    unsigned short width,
    unsigned short height
    )
    {
    __vector VinT1,VinT2; //Top pixel
    __vector VinL1,VinL2; //Left pixel
    __vector VinR1,VinR2; //Right pixel
    __vector VinB1,VinB2; //Bottom pixel
    __vector VgX_1,VgX_2; //Gx
    __vector VgY_1,VgY_2; //Gy
    __vector Vabs_gX_1,Vabs_gX_2; //abs of Gx
    __vector Vabs_gY_1,Vabs_gY_2; //abs of Gy
    __vector Vmag1,Vmag2; //Mag
    for (int I1 = 0; I1 < height; I1++)
    {
        for (int I2 = 0; I2 < width/VCOP_SIMD_WIDTH; I2++)
               {
                    __agen Addr;
                   Addr = I1*width*ELEMSZ + I2*VECTORSZ;
                   (VinT1,VinT2) = (in_ptr) [Addr].deinterleave();
                   (VinL1,VinL2) = (in_ptr+width) [Addr].deinterleave();
                   (VinR1,VinR2) = (in_ptr+width+2) [Addr].deinterleave();
                   (VinB1,VinB2) = (in_ptr+2*width+1)[Addr].deinterleave();
                   VgX_1 = VinR1 - VinL1;
                   VgY_1 = VinB1 - VinT1;
                   VgX_2 = VinR2 - VinL2;
                   VgY_2 = VinB2 - VinT2;
                   Vabs_gX_1 = abs(VgX_1);
                   Vabs_gY_1 = abs(VgY_1);
                   Vabs_gX_2 = abs(VgX_2);
                   Vabs_gY_2 = abs(VgY_2);
                   Vmag1 = 0; //Vabs_gX_1 + Vabs_gY_1;
                   Vmag2 = 0;//Vabs_gX_2 + Vabs_gY_2;
                   out_ptr[Addr].interleave() = (Vmag1,Vmag2).saturate(0,255);
    
               }
        }
    }
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include <string.h>
    #include <math.h>
    
    #include <vcop.h>
    #include "gradient.h"
    
    #define IMAGE_HEIGHT  144
    #define IMAGE_WIDTH   176
    /**
     * main.c
     */
    int main(void)
    {
        uint8_t *inputData= NULL;
        uint8_t  *outputData= NULL;
        FILE *fp_in = NULL;
        FILE *fp_out = NULL;
    
        inputData     = (uint8_t *) vcop_malloc(VCOP_IBUFHA,IMAGE_WIDTH* IMAGE_HEIGHT * sizeof(uint8_t));
        outputData   = (uint8_t *) vcop_malloc(VCOP_IBUFHA,IMAGE_WIDTH* IMAGE_HEIGHT * sizeof(uint8_t));
    
        fp_in = fopen("qcif.y", "rb");
    
        if(fp_in == NULL)
        {
        printf("Failed to open input file.\n");
        return -1;
        }
    
        fread(inputData, IMAGE_WIDTH * IMAGE_HEIGHT, sizeof(uint8_t), fp_in);
    
    
        vcop_vec_gradients(inputData,   inputData , IMAGE_WIDTH, IMAGE_HEIGHT );
    
        fp_out = fopen("qcif_out.y", "wb");
    
        if(fp_out == NULL)
        {
          printf("Failed to open output file.\n");
          return -1;
        }
    
          fwrite(inputData, IMAGE_WIDTH * IMAGE_HEIGHT, sizeof(uint8_t), fp_out);
          fclose(fp_out);
          fclose(fp_in);
    
    }
    
    /*
    *
    * Copyright (c) 2009-2017 Texas Instruments Incorporated
    *
    * All rights reserved not granted herein.
    *
    * Limited License.
    *
    * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
    * license under copyrights and patents it now or hereafter owns or controls to make,
    * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
    * terms herein.  With respect to the foregoing patent license, such license is granted
    * solely to the extent that any such patent is necessary to Utilize the software alone.
    * The patent license shall not apply to any combinations which include this software,
    * other than combinations with devices manufactured by or for TI ("TI Devices").
    * No hardware patent is licensed hereunder.
    *
    * Redistributions must preserve existing copyright notices and reproduce this license
    * (including the above copyright notice and the disclaimer and (if applicable) source
    * code license limitations below) in the documentation and/or other materials provided
    * with the distribution
    *
    * Redistribution and use in binary form, without modification, are permitted provided
    * that the following conditions are met:
    *
    * *       No reverse engineering, decompilation, or disassembly of this software is
    * permitted with respect to any software provided in binary form.
    *
    * *       any redistribution and use are licensed by TI for use only with TI Devices.
    *
    * *       Nothing shall obligate TI to provide you with source code for the software
    * licensed and provided to you in object code.
    *
    * If software source code is provided to you, modification and redistribution of the
    * source code are permitted provided that the following conditions are met:
    *
    * *       any redistribution and use of the source code, including any resulting derivative
    * works, are licensed by TI for use only with TI Devices.
    *
    * *       any redistribution and use of any object code compiled from the source code
    * and any resulting derivative works, are licensed by TI for use only with TI Devices.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
    *
    * may be used to endorse or promote products derived from this software without
    * specific prior written permission.
    *
    * DISCLAIMER.
    *
    * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
    * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    * OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    
    -heap  0x20000
    -stack 0x1000
    
    MEMORY
    {
        PAGE 0:
          VECMEM  :    origin      = 0x80000000, length = 0x0100
          CMDMEM  :    origin      = 0x80000100, length = 0x1000
          EXTMEM  :    origin      = 0x80001100, length = 0x10000
    
        PAGE 1:
          DATMEM  :    origin = 0x40020000 length = 0x8000
          WMEM    :    origin = 0x40040000 length = 0x7E00
          IMEMLA  :    origin = 0x40050000 length = 0x4000
          IMEMHA  :    origin = 0x40054000 length = 0x4000
          IMEMLB  :    origin = 0x40070000 length = 0x4000
          IMEMHB  :    origin = 0x40074000 length = 0x4000
          GEM0_L2_MEM: origin = 0x40800000 length = 0x8000
          EXTDMEM :    origin = 0x80030000 length = 0x2000000
          L3MEM   :    origin = 0x40300000, length = 0x100000
    }
    
    #ifdef VCOP_CAMA
    /*---------------------------------------------------------------------------*/
    /* VCOP Compiler Assisted Memory Allocation                                  */
    /*---------------------------------------------------------------------------*/
    
    /*---------------------------------------------------------------------------*/
    /* Define VCOP heap sizes. These can be smaller than the actual memory region*/
    /*---------------------------------------------------------------------------*/
    
    IMEML_SIZE = 0x4000;
    IMEMH_SIZE = 0x4000;
    WMEM_SIZE  = 0x7800;
    
    /*--------------------------------------------------------------------------*/
    /* Define VCOP heap locations and ensure heaps span the appropriate size    */
    /*--------------------------------------------------------------------------*/
    SECTIONS
    {
      .imemla: { *(.imemla) . += (IMEML_SIZE - 8); } > IMEMLA PAGE 1
      .imemha: { *(.imemha) . += (IMEMH_SIZE - 8); } > IMEMHA PAGE 1
      .imemlb: { *(.imemlb) . += (IMEML_SIZE - 8); } > IMEMLB PAGE 1
      .imemhb: { *(.imemhb) . += (IMEMH_SIZE - 8); } > IMEMHB PAGE 1
      .wmem  : { *(.wmem)   . += (WMEM_SIZE  - 8); } > WMEM   PAGE 1
    }
    
    #else
    
    /*-----------------------------------------------------------------------------*/
    /* Disable VCOP Compiler Assisted Memory Allocation by setting heapsize to zero*/
    /*-----------------------------------------------------------------------------*/
    IMEML_SIZE = 0x0;
    IMEMH_SIZE = 0x0;
    WMEM_SIZE  = 0x0;
    
    #endif
    
    /*---------------------------------------------------------------------------*/
    /* VCOP Manual Allocation                                                    */
    /*---------------------------------------------------------------------------*/
    
    SECTIONS
    {
      .const       > DATMEM  PAGE 1
      Adata        > IMEMLA  PAGE 1
      Bdata        > IMEMHA  PAGE 1
      Cdata        > WMEM    PAGE 1
      EOutdata     > DATMEM  PAGE 1
      Sdata        > DATMEM  PAGE 1
      Udata        > WMEM    PAGE 1
      Vdata        > WMEM    PAGE 1
      Ydata        > WMEM    PAGE 1
      .cint        > DATMEM  PAGE 1
      .stack       > DATMEM  PAGE 1
      .sysmem      > EXTDMEM  PAGE 1
      .cinit       > DATMEM  PAGE 1
      .cio         > DATMEM  PAGE 1
      .far         > DATMEM  PAGE 1
      .fardata     > DATMEM  PAGE 1
      .init_array  > DATMEM  PAGE 1
      .vcop_parameter_block > WMEM PAGE 1
    }
    
    
    SECTIONS
    {
      .intvecs      > VECMEM  PAGE 0
      .inthandler   > CMDMEM  PAGE 0
      .exitlocation > CMDMEM  PAGE 0
    
      .text > EXTMEM   PAGE 0
      {
        *(.text)
      }
    
      GROUP
      {
          .bss            /* This order facilitates a single segment for */
          .data           /* GDP-relative addressing                     */
          .rodata
      }>DATMEM PAGE 1
    
       SRC_MEM        > EXTDMEM    PAGE 1
       DDR_MEM        > EXTDMEM    PAGE 1
       DST_MEM        > EXTDMEM    PAGE 1
       IBUFLA         > IMEMLA     PAGE 1
       IBUFHA         > IMEMHA     PAGE 1
       IBUFLB         > IMEMLB     PAGE 1
       IBUFHB         > IMEMHB     PAGE 1
       WBUF           > WMEM       PAGE 1
    
    }
    

  • Hi Mohamed,

        Can you define VCOP_CAMA in your build and try.

    Regards,

    Anshu
     

  • Hi Anshu,

    Do you mean add "VCOP_CAMA" in build option like "gmake -k VCOP_CAMA" ?

  • i am adding "#define VCOP_CAMA" in linker file , i am able to compile it without warning, i will update if it solves my problem while executing the program.
  • Hi Anshu,

    "#define VCOP_CAMA" solves my warning pproblem but it does not the change the output, i mean i seeoutput image is same as input image, not effect processing, can you help for the same please if i am using vector wrongly or anything else.

    thanks,
    mohammed
  • Mohammed,
    I see that in your file you are requesting two buffers :
    inputData = (uint8_t *) vcop_malloc(VCOP_IBUFHA,IMAGE_WIDTH* IMAGE_HEIGHT * sizeof(uint8_t));
    outputData = (uint8_t *) vcop_malloc(VCOP_IBUFHA,IMAGE_WIDTH* IMAGE_HEIGHT * sizeof(uint8_t));

    Both these buffers are requested in the same memory (VCOP_IBUFHA) and given the sizes which you have used for IMAGE_WIDTH and IMAGE_HEIGHT vcop_malloc should have failed for both of them as you have only 16KB of IBUFHA buffer and you are requesting close to 25KB for each of the buffers. Can you check if you are getting valid pointers for these buffers.

    Regards,
    Anshu
  • Anshu,
    You are right about 25 KB size(but,when i refer example codes they are allocating the memory this way only), what could be the probable solution here? shall i use BAM to process small data from the image? or any quick solution? actually i am want very light demo-able kernel, my intention is not to use all of the functionality just to reduce the processing...
    anyway, let me know what shall i do for the same.
    Appreciate your help.

  • Can you point to the example which you are referring to?
    If it is just for learning how to program kernel you can just reduce the size of your input and output data ( for instance just process 32x32 block) so that it fits into the internal memories of EVE.

    Regards,
    Anshu
  • ok instead reading all image and processing i can use block of the image ,right?
  • Yes eventually thats how you will have to process. But for the beginning you can work with just one block data to understand kernel programming and test your kernel functionality. Once that is verified then you will have to use EDMA to bring data into smaller blocks and process.

    Regards,
    Anshu
  • Hi Anshu,

    Thanks for your help,

    two major problem what i had was size and linker. now i am good to go, it solved.