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.

SK-TDA4VM: Linking the mathlib_log function to the PDK example

Part Number: SK-TDA4VM
Other Parts Discussed in Thread: MATHLIB

Tool/software:

Hi

I am using the SDK version "ti-processor-sdk-rtos-j721e-evm-09_02_00_05\pdk_jacinto_09_02_00_30" where I have created a simple application to run in C7x DSP core which will perform some operations like log2(x) , log10(x) on a big chunk of unsigned 32 bit data in L2 Ram memory

The overall goal of the work is to make the simple application run more efficiently in the C7x core to replicate it for our requirement. Below are the steps I followed for linking the mathlib_log() to the simple application developed inside PDK
(i) Built the mathlib_log library using the command "

cmake -B build -DTARGET_PLATFORM="" -DAUTO_TEST="1" -DSOC="j721e" -DDEVICE="C7100" \
-DALL_TEST_CASES="1" -DCMAKE_BUILD_TYPE="Release" -DMATHLIB_DEBUGPRINT="0""
(ii) got theMATHLIB_C7100.lib file generated and added the lib file path to the makefile of simple application
(iv) During the compilation I am able to see a issue in ti-cgt-c7100-LTS folder . Below is the error message

"ti-processor-sdk-rtos-j721e-evm-09_02_00_05/pdk_jacinto_09_02_00_30/ti-cgt-c7000_4.1.0.LTS/include/c7x_scalable.h",line 171: fatal error #35: #error directive: "
c7x_scalable.h requires C++"
I am getting this error message under this line in c7x_scalable.h
#ifndef __cplusplus
#error "c7x_scalable.h requires C++"
#endif /* __cplusplus */

Do we need to specifically define the __cplusplus or do we need to additionally include any MACRO definition ?
Thanks
Madhu
 
  • Hi Madhu,

    (iv) During the compilation I am able to see a issue in ti-cgt-c7100-LTS folder . Below is the error message

    This is when compiling your application correct?

    Could you clarify a few things about your development setup?

    Are you:

    - Editing an existing PDK example application

    - Adding a new example in the PDK development environment

    - Linking the PDK and MATHLIB libraries in your own development environment

    As a note, since your application will require C++, do ensure that the C7x compiler is interpreting your file correctly as a C++ file (see sections 3.3.7 Specifying Filenames and 3.3.8 Changing How the Compiler Interprets Filenames in C7000 C/C++ Optimizing Compiler Users Guide)

    Best,

    Asha

  • Hi Asha

    Thanks for the reply , Here is the response for all your queries

    1. This is when compiling your application correct? - Yes I am facing this issue while compiling our application

    2. Editing an existing PDK example application - No , I am not editing any existing example , I am developing another simple application inside example folder of PDK where I am calling MATHLIB_log10() for a chunk of 32 bit values 

    3. Adding a new example in the PDK development environment - Yes I am adding a new example for executing the mathlib_log() in the PDK development environment

    4. Linking the PDK and MATHLIB libraries in your own development environment -Yes I am linking the mathlib function include paths to the make environment that I developed inside PDK for simple application

    In order to link the cpp files for PDK I added these lines in rules_71.mk inside makerules and correspondingly I was adding "CPLUSPLUS_BUILD=yes" in build environement as per the makerules

    But while doing compilation I am facing issue stating that "C7x_scalable.h requires C++" from ti-processor-sdk-rtos-j721e-evm-09_02_00_05/pdk_jacinto_09_02_00_30/ti-cgt-c7000_4.1.0.LTS/include/c7x_scalable.h"

    #ifndef __cplusplus
    #error "c7x_scalable.h requires C++"
    #endif /* __cplusplus */

     Thanks 

    Madhu

  • Hi Madhu,

    Thanks for providing the additional details. Yes, as you have discovered, the default for the existing PDK examples will be compiling in C. 

    I was adding "CPLUSPLUS_BUILD=yes" in build environement as per the makerules

    To make sure, you are passing this in, as per Rules.make correct?

    Can you attach the entire compilation log? Based on the C7x compiler documentation -fg should be what you need to pass in for C++ compilation (regardless of the file extension). 

    Based on the code snippet you provided, can you see if you see what the exact cl7x command is when compiling to ensure the -fg flag is included when compiling? 

    Best,

    Asha

  • Hi Asha
    Thanks for your response, 

    Can you once confirm where do we need to get the compilation log , are you asking for the .map file getting generated while compiling?

    Regards,

    Madhu

  • Hi Madhu,

    To clarify, I am asking for the output on the command line after running the make command you use to run your custom PDK example. In particular, I'm wondering if you can echo the build commands that get run during the "Object File Creation." I am assuming this is going to be a C7x compiler build command (cl7x) and I want ensure that the "-fg" flag is getting passed.

    Best,

    Asha

  • Hi Asha

    Here is the compile log that you asked for while running the make command "make -s BOARD=j721e_evm CORE=c7x_1 mathlib_log_testapp_freertos CPLUSPLUS_BUILD=yes"

    1. Basically the goal is to call a function mathlib_log10() that is defined in .cpp file (i.e) in the folder path "mathlib_09_02_00_04\src\MATHLIB_log10\MATHLIB_log10.cpp"  from a .c file

    This is the folder structure of my simple test application 

    Its respective makefile script is,

    Additionally If I try giving this way in makefile script 

      COMPILEMODE = -fg

    I am getting issues while trying to link the functions in .c file during compilation , below is the error

    Regards,

    Madhu

  • Hi Madhu,

    With the first error you are showing, that's the error we have been initially trying to track down. 

    Additionally If I try giving this way in makefile script 

      COMPILEMODE = -fg

    I am getting issues while trying to link the functions in .c file during compilation , below is the error

    When you pass the flag in this way, is it getting passed the errors you were seeing earlier regarding building with C++. This error at least seems unrelated. Did you declare an implementation of the InitMmu function in your main_rtos.c file? This is required to set up the C7x MMU. The other examples have this function call if you need a reference.

    Best,

    Asha

  • Hi Asha

    As you mentioned here , the error which I am getting for InitMmu() is unrelated for the compiler issue which means I am able to pass the compiler flag as expected and I am not seeing the original issue "c7x_scalable.h requires C++" since the compiler mode is passed as -fg if I pass the CPLUSPLUS_BUILD=yes in make cmd, but some how I am facing this initMmu() issue even though I included the definition in main.c file

     

    Regards,

    Madhu

  • Hi Madhu,

    Okay, good to know you have gotten passed the C++ build issues.

    To solve the linking issue -

    To confirm, have you included the following includes in your main_rtos.c file? These are the includes in the udma_memcpy_testapp_freertos application that can run on C7x for reference. I would make sure that there are aren't any discrepancies between these includes and the makefile 

    #include <ti/osal/osal.h>
    #include <ti/osal/TaskP.h>
    #include <ti/csl/soc.h>
    #include <ti/board/board.h>

    In particular for InitMmu, you should be required to include the csl and osal libraries.

    Best,

    Asha

  • Hi Asha

    To confirm, have you included the following includes in your main_rtos.c file? These are the includes in the udma_memcpy_testapp_freertos application that can run on C7x for reference. I would make sure that there are aren't any discrepancies between these includes and the makefile 

    #include <ti/osal/osal.h>
    #include <ti/osal/TaskP.h>
    #include <ti/csl/soc.h>
    #include <ti/board/board.h>

    For your clarification, I included all these header files already in the main_rtos.c file and also correspondingly we have this below mentioned in the makefile script

    # List all the external components/interfaces, whose interface header files
    #  need to be included for this component
    INCLUDE_EXTERNAL_INTERFACES = pdk
    Do we get these type of issue if we include the macro define  CPLUSPLUS_BUILD=yes  in our build cmd because of which is there any kind of conflict happening while compiling the actual .c file ?
    Regards,
    Madhu
  • Hi Madhu,

    Asha is on vacation for the rest of this week. So, please expect a delay in response. Asha will get back to you sometime early-mid next week.

    regards

    Suman

  • Hi Suman

    Thanks for the response 

    Regards,

    Madhu

  • Hi Madhu,

    Thanks for the additional information. Can you check if ti.osal.ae71 is being included for libraries to link?

    For example when I build with the command make BOARD=j721e_evm CORE=c7x_1 udma_memcpy_testapp_freertos I see the following for the linking step:

    Can you post the same from your build - do remember to not include the "-s" in the make command, otherwise you can't see this command. 

    Best,

    Asha

  • Hi Asha

    Thanks for the response.

    Here is the snap of the command while building the mathlib_log test app , where we can see that ti.osal.ae71 being included in linking 

    Build command : make BOARD=j721e_evm CORE=c7x_1 mathlib_log_testapp_freertos CPLUSPLUS_BUILD=yes 

    Regards,

    Madhu

  • Hi Madhu,

    I'm seeing the same result if I compile with  make BOARD=j721e_evm CORE=c7x_1 udma_memcpy_testapp_freertos and CPLUSPLUS_BUILD=yes

    Can you try encapsulating the InitMmu function with extern "C" ? See the snippet below:

    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #if defined(BUILD_MPU) || defined (BUILD_C7X)
    extern void Osal_initMmuDefault(void);
    void InitMmu(void)
    {
        Osal_initMmuDefault();
    }
    #endif
    
    #ifdef __cplusplus
        } /* extern C */
    #endif

    Running the above code with the command with CPLUSPLUS_BUILD=yes does not result in the linking issue for me when building the udma example.

    Best,

    Asha

  • Hi Asha
    I tried encapsulating the InitMmu function with extern "C" as you mentioned. I am able to link the standard lib without any issue and also the executables got generated as expected.Thanks for the support.

    Regards,

    Madhu