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.

How do i use FPUfastRTS library in my RTSC package

Other Parts Discussed in Thread: CONTROLSUITE, SYSBIOS

Hi

I am building RTSC packages for our application which involves floating point maths, I would like to know how i can use FPUfastRTS library from control suit in our custom packages.

  • Ragesh,
    are these RTSC packages something that you are using only locally, or are you eventually planning to ship them to a customer to use them?
    The first case is simpler. You can create a separate package, 'fastRTSpkg' for example, whose only purpose is to deliver the library to your application. Then, in that package you need the file package.xs and in it a function getLibs().

    function getLibs() {
        return ("<absolute path to fastRTS>/fastRTS.lib");
    }

    If needed, you can also add some code that verifies that the build target is compatible with the fastRTS library. Then, an app only need to load that package to link with the fastRTS library.

    xdc.loadPackage('fastRTSpkg');

     

  • Hi Sasha,

    I have created a package systcs\library with a Math module. I am getting warnings"function declared implicitly " in the Math.c. I am new to RTSC packaging.

    /*
    * ======== systcs/library/Math.c ========
    */

    #include <math.h>
    #include "package/internal/Math.xdc.h"

    Float Math_abs(Float X)
    {
    return (X>0.0?X:-X);
    }

    Float Math_sqrt(Float X)
    {
    return sqrt(X);
    }

    Float Math_atan(Float X)
    {
    return atan(X);
    }

    Float Math_atan2(Float X, Float Y)
    {
    return atan2(X,Y);
    }

    Float Math_cos(Float X)
    {
    return cos(X);
    }

    Float Math_sin(Float X)
    {
    return sin(X);
    }

    /*
    * ======== systcs/library/Math.xdc ========
    */

    /*! Collection of math functions */
    module Math {

    /*! Absolute value */
    Float abs(Float X);

    /*! Square root */
    Float sqrt(Float X);

    /*! atan */
    Float atan(Float X);

    /*! atan2 */
    Float atan2(Float X, Float Y);

    /*! sin */
    Float sin(Float X);

    /*! cos */
    Float cos(Float X);

    };
    }

    /*
    * ======== systcs/library/package.bld ========
    */

    var Build = xdc.useModule('xdc.bld.BuildEnvironment');
    var Pkg = xdc.useModule('xdc.bld.PackageContents');

    var LIB_NAME = "lib/" + Pkg.name;
    var LIB_SRCS = ["Math.c"];

    for each (var targ in Build.targets) {
    Pkg.addLibrary(LIB_NAME, targ).addObjects(LIB_SRCS);
    }

    /*
    * ======== systcs/library/package.xdc ========
    */

    /*! Collection of math functions */
    package systcs.library {
    module Math;
    };

    /*
    * ======== systcs/library/package.xs ========
    */

    function getLibs() {
    return ("C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/lib/rts2800_fpu32_fast_supplement.lib");
    }

    /*
    * ======== config.bld ========
    */

    var Build = xdc.useModule('xdc.bld.BuildEnvironment');

    var C28_float = xdc.useModule('ti.targets.C28_float');

    /* modify to match %c2xtools% */
    C28_float.rootDir = "C:/ti/C2000 Code Generation Tools 6.1.1";

    C28_float.platform = 'ti.platforms.concertoC28:F28M35H52C1';

    Build.targets = [C28_float];

  • Ragesh,
    it seems that code in your packages is also using functions from fastRTS. I am not familiar with Control Suite, but I am guessing you have to add an include path for fastRTS header files. If that's the case, in your package.bld when you invoke Pkg.addLibrary, you have to specify 'incs' parameter for additional include directories, something like this:
    Pkg.addLibrary(LIB_NAME, targ, {incs: "-I <path to fastRTS header files"}).addObjects(LIB_SRCS);
    If you still see the warnings, you have to find which math.h file you are finding on your include path, and check which functions are defined in that file. You can set the environment variable XDCOPTIONS=v. That will give you the complete command line when compiling your Math.c and you will be able to see all include directories.

    Since you have your own library in the package systcs.library, your getLibs function has to supply that library too together with the fastRTS library. You can supply them both in the same string but you have to separate them with ';'.
    return ("lib/systcs.library.a" + prog.build.target.suffix + ";C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/lib/rts2800_fpu32_fast_supplement.lib");

  • Hi Sasha,

    I am speaking about the reply you gave me for my first post.These RTSC packages are using only locally.

    function getLibs() {
        return ("<absolute path to fastRTS>/fastRTS.lib");
    }

    this part is done in the package.xs

    /*
    * ======== systcs/math/package.xs ========
    */

    function getLibs() {
    return ("C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/lib/rts2800_fpu32_fast_supplement.lib");
    }

    now how do i make the package.bld for the same.

     

  • Ragesh,
    generally the purpose of package.bld is to generate command lines, and the purpose of getLibs() in package.xs is to add libraries to the linker command file. When you add a library to the linker command file, you don't need to add that same library on the command line in package.bld. What you need to do in package.bld is to add correct header files to the compiler command line. In my earlier post, I explained how to do that in the call to Pkg.addLibrary in package.bld.

    Have you turned on XDCOPTIONS=v? Do you still get warnings? Can you post your console output with command lines after you set XDCOPTIONS to 'v'?

  • Hi Sasha,

    I have included the include path in the package.bld also i have enabled verbose output

    /*
    * ======== systcs/math/package.bld ========
    */

    var Build = xdc.useModule('xdc.bld.BuildEnvironment');
    var Pkg = xdc.useModule('xdc.bld.PackageContents');

    var LIB_NAME = "lib/" + Pkg.name;
    var LIB_SRCS = ["Math.c"];

    for each (var targ in Build.targets) {
    Pkg.addLibrary(LIB_NAME, targ, {incs: "-I D:/ti/ccsv5/tools/compiler/c2000_6.1.0/include"}).addObjects(LIB_SRCS);
    // Pkg.addLibrary(LIB_NAME, targ).addObjects(LIB_SRCS);
    }

    /*
    * ======== systcs/math/Math.c ========
    */

    #include <math.h>
    #include "package/internal/Math.xdc.h"

    Float Math_abs(Float X)
    {
    return (X>0.0?X:-X);
    }

    Float Math_sqrt(Float X)
    {
    return sqrt(X);
    }

    Float Math_atan(Float X)
    {
    return atan(X);
    }

    Float Math_atan2(Float X, Float Y)
    {
    return atan2(X,Y);
    }

    Float Math_cos(Float X)
    {
    return cos(X);
    }

    Float Math_sin(Float X)
    {
    return sin(X);
    }

    /*
    * ======== systcs/math/Math.xdc========
    */

    /*! Collection of math functions */
    module Math {

    /*! Absolute value */
    Float abs(Float X);

    /*! Square root */
    Float sqrt(Float X);

    /*! atan */
    Float atan(Float X);

    /*! atan2 */
    Float atan2(Float X, Float Y);

    /*! sin */
    Float sin(Float X);

    /*! cos */
    Float cos(Float X);

    };
    }

    /*
    * ======== systcs/math/package.xdc ========
    */

    /*! Collection of math functions */
    package systcs.math {
    module Math;
    };

    /*
    * ======== systcs/math/package.xs ========
    */

    function getLibs() {
    return ("C:/ti/controlSUITE/libs/math/FPUfastRTS/V100/lib/rts2800_fpu32_fast_supplement.lib");
    }

    /*
    * ======== config.bld ========
    */

    var Build = xdc.useModule('xdc.bld.BuildEnvironment');

    var C28_float = xdc.useModule('ti.targets.C28_float');

    /* modify to match %c2xtools% */
    C28_float.rootDir = "C:/ti/C2000 Code Generation Tools 6.1.1";

    C28_float.platform = 'ti.platforms.concertoC28:F28M35H52C1';

    Build.targets = [C28_float];

    As you can see "all files completed" from the concole

    now for testing this package, I added the repository directory to my CCS 5 project. I am receiving few unresolved symbol errors when i build the project

    I am using Concerto Experimenter Kit F28M35H52C1, and my project sysconDSP is running on the DSP side of the concerto, with sysbios V. 6.33.4.39

    I am attaching my sysconDSP_main.c, which contains the code to test the Math functions in the Math package i just created.

    When i try to build the following i get few unresolved symbol errors , I am attaching screen shot of the "Problems" tab



    /*
    * ======== main.c ========
    */

    #include <xdc/std.h>
    #include <xdc/runtime/Types.h>

    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>

    #include <ti/sysbios/BIOS.h>

    #include <ti/sysbios/knl/Task.h>


    /* Systcs Header file */
    //#include "systcs_Robot.h"

    #include <systcs/math/Math.h>


    /*
    * ======== main ========
    */
    Void main()
    {
    float x_abs=-2.75,x_sqrt= 16.0, x_cos = 1.0472, x_sin = 0.5236, x_atan = 0.7854;
    volatile float y_abs_Math = 0.0, y_sqrt_Math = 0.0, y_sin_Math = 0.0, y_cos_Math = 0.0, y_atan_Math = 0.0;

    y_abs_Math=Math_abs(x_abs);

    y_sqrt_Math=Math_sqrt(x_sqrt);

    y_atan_Math = Math_atan(x_atan);

    y_sin_Math= Math_sin(x_sin);

    y_cos_Math= Math_cos(x_cos);

    // IPCInit ();

    BIOS_start(); /* enable interrupts and start SYS/BIOS */
    }