CODECOMPOSER: How to create a Static Library with CLA Math code

Part Number: CODECOMPOSER
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hi there,

I am wanting to create a static library containing functionality used by tasks running on the CLA. As such, the static library will mostly be header files with inline functions declared and defined. Was there a preferred way to set this up in CCSv12? I have created a new CCS Project with the Output Type set as a Static Library.

I'm not sure how to get CCS to pull in the required CLA Math library I need - normally this is done in the linker configuration I think, but I'm not entirely sure how to achieve.

In one such file I've included "CLAmath.h" and in the Project's C2000 Compiler option, added the path to the CLA Library from C2000ware to the Include Options, and added _TMS320C28XX_CLA__ as a predefined symbol. I'm not sure if this is the right approach, it certainly feels incorrect.

At the end of the day I would like to create a number of header files that a *.cla file could include. These header files contain some functions that utilize the CLA math library and can be compiled as a static library to be included in a number of different projects.

Ideally I'd like to use the CLAx_math_library_eabi.lib file directly, but I saw on another post that CCS cannot internally create a static library which includes another static library (https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/611386/ccs-how-can-i-build-a-static-lib-which-include-two-lib-in-ccsv7).

Cheers,

Jim

  • Regarding the header files, I have no advice on how to supply those to your customers.

    Regarding the static library ... Do not attempt to somehow combine your library with any other library, such as CLAx_math_library_eabi.lib.  Instead, document to your customers that your library relies on these other libraries.  It is your customer who is then responsible for supplying all of those libraries as inputs to the final link of their application program.

    Thanks and regards,

    -George

  • For your second point, is it still possible to #include "CLAmath.h" and use the trig functions supplied? I have a header file that has something like:

    #include "CLAmath.h"
    
    inline void do_something(float32_t value, float32_t *out)
    {
       ... // do stuff to value
       
       *out = sinf(value);
    }

    I've added the path to the CLAmath.h header to my include search path.

    I want to compile functions like this into a library so I can then use it in a bunch of other projects, as this seemed appropriate.

    Thanks,

    Jim

  • You are writing a header file that is included by other CLA source files.  It has the same limitations as any CLA source file.  For details, please search the C28x compiler manual for the sub-chapter titled CLA C Language Implementation.  For instance, it says you cannot call a standard RTS function like sinf.

    There is yet another issue that I suspect you have overlooked.  What if a customer includes your CLA header file with an inline function in it, they call that function, and they do not build with optimization.  In such a case, the function does not get inlined.  The linker then expects to find a regular, not inlined, implementation of the function that can be the target of the non-inlined call.   

    The solution requires you build for EABI (I think you already do that) and C99.  It is a variation on the method for inlining described  in this article (not from TI).

    Create the header file just like you show in the previous post.  In addition, in one source file for the library, include that header file and this line ...

    extern inline void do_something(float32_t value, float32_t *out);

    You must build with the compiler options --abi=eabi --c99.  

    Thanks and regards,

    -George

  • A lot of this helped and I'm moving towards making the library compile .cla files so I it should be able to call RTS functions.

    Highlighting the caveats to this approach was very useful.

    Cheers