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.

TMS320F28375S: Problem in attaching library in code.

Part Number: TMS320F28375S
Other Parts Discussed in Thread: C2000WARE

Hello Team,

I have to read, write data in flash in my code. for that i want to use flash_api F021 library in my code.
i have attached the library but it is showing error.

i have attached the library in the following manner

> first i made a new folder in my project and copy the library files in it.

> then i include the file path in 'Build settings -> c2000 compiler -> include options

> then i also include library path in c2000 linker -> file search path 

please correct me if i have done any mistake in attaching the library or anything else.

when i include the file " #include <F021_F2837xS_C28x.h> " it shows error.

please help me with this.

thanks and regards 

Muzammil Qureshi

  • Hi Muzammil,

    Did you check the build settings and the included files for the flash programming example project provided in C2000Ware at C2000Ware_5_01_00_00\device_support\f2837xs\examples\cpu1\flash_programming\cpu01 ?

    Thanks and regards,
    Vamsi 

  • Hello Vamsi,

    I check the example project earlier but i was not able to understand the build settings and how the flies are included. so I started this thread. can you please give some more clarification about how the include flash library and how the libraries and files are included ingeneral?

    thanks and regards
    Muzammil Qureshi

  • Hi Muzammil,

    When comparing the screenshots of your project build settings with the build settings of the flash programming example, there are a few differences to note. 

    • In the "Include Options" view of the C2000 Compiler, you should be including the Flash API filepath: C2000Ware_Install_Location\libraries\flash_api\f2837xs\include
    • In the "File Search Path" view of the C2000 Linker, you should add the C2000Ware_Install_Location\libraries\flash_api\f2837xs\lib filepath
    • You don't need to create the Flash API folder in the "device" folder 
    • Note: The "../" you see in the filepaths of the flash programming examples are indicating to move "up", or to the parent directory, of that relative location. For example: Path_A/Path_B/Path_C/../../ would result in the final path being Path_A/. Hopefully this clears up any confusion about how the flash programming example includes paths/libraries.

    Kind regards,

    Skyler

  • Hello skyler,

    I made the changes as mentioned by you in my project but still it is giving the error when i include the <F021_F2837xS_C28x.h> library.

    the snapshot of error is shown below

    can you please help me solve this error?

    Note: The "../" you see in the filepaths of the flash programming examples are indicating to move "up", or to the parent directory, of that relative location. For example: Path_A/Path_B/Path_C/../../ would result in the final path being Path_A/. Hopefully this clears up any confusion about how the flash programming example includes paths/libraries.

    is this compulsary to do this in my project also?

    thanks and regards
    Muzammil Qureshi

  • Hi Muzammil,

    What do lines 67-73 look like in the Types.h file that the error occurs in? I suspect there could be a mismatch in what is defined in your project vs the example. Is __TMS320C28XX__ defined in your project?

    is this compulsary to do this in my project also?

    No, as long as your filepaths result in the same destination, there is no need to include the ../ unless you need to navigate "up" a level.

    Best,

    Skyler

  • Hello Skyler,

    What do lines 67-73 look like in the Types.h file that the error occurs in?

    Is __TMS320C28XX__ defined in your project?

    do you mean in predefined symbols options in project settings??

    these are the predefined symbols in my project.

    I have not defined __TMS320C28XX__   but if I define it in predefined symbols, it gives me more errors.

    please help me to solve this problem.

    thanks and regards,

    Muzammil Qureshi

  • Hi Muzammil,

    It looks like the ATTRIBUTE_PACKED that was originally marked as an error is defined, so I'm not sure why it shows up as invalid. Don't define __TMS320C28XX__ in the predefined symbols, I was just verifying that it was defined so the ATTRIBUTE_PACKED macro would be defined in Types.h. What compiler are you using?

    Kind regards,

    Skyler

  • Hello Skyler,

    I am using C2000 Compiler.

    Compiler version : TI v22.6.1.LTS.

    thanks and regards

    Muzammil Qureshi

  • Hi Muzammil,

    Can you send an updated image of your project structure and the filepaths included? I am unable to recreate this error on my side. 

    I am including these Flash API paths in my project and am able to compile with #include <F021_F2837xS_C28x.h> in my main file.

    Kind regards,

    Skyler

  • Hello Skyler,

    Can you send an updated image of your project structure and the filepaths included?

    linker ->.

    can you please reply by today itself please?

    thanks and regards

    Muzammil Qureshi

  • Hello skyler,

    I have made separate hal_flash.c and hal_flash.h files for flash operation. i have made the functions which include Fapi library functions in hal_flash.c and declared that functions in hal_flash.h file.

    i also include "F021_F2837xS.h" file in my hal_flash.h file.

    till then it compiles successfully but when i try to call that functions in main file, it gives me error.

    note that i have also included "hal_flash.h" and "F021_F2837xS.h" in my main file.

    thanks,

    Muzammil Qureshi

  • Hi Muzammil,

    Can you try adding the F021_API_F2837xS_FPU32.lib file to your project directory? Right click the project, select Add Files, navigate to C2000Ware_Install_Location\libraries\flash_api\f2837xs\lib, and select F021_API_F2837xS_FPU32.lib.

    Kind regards,

    Skyler

  • Hello Skyler, 

    I tried adding the library file as you mentioned above, but still the result is same. still i am getting the error i mentioned above.

    is it possible that the error is in linker .cmd file?

    // The user must define CLA_C in the project linker settings if using the
    // CLA C compiler
    // Project Properties -> C2000 Linker -> Advanced Options -> Command File
    // Preprocessing -> --define
    #ifdef CLA_C
    // Define a size for the CLA scratchpad area that will be used
    // by the CLA compiler for local symbols and temps
    // Also force references to the special symbols that mark the
    // scratchpad are.
    CLA_SCRATCHPAD_SIZE = 0x100;
    --undef_sym=__cla_scratchpad_end
    --undef_sym=__cla_scratchpad_start
    #endif //CLA_C
    
    MEMORY
    {
    PAGE 0 :
       /* BEGIN is used for the "boot to SARAM" bootloader mode   */
    
       BEGIN           	: origin = 0x000000,   length = 0x000002
       RAMM0           	: origin = 0x000123,   length = 0x0002DD
       RAMD0           	: origin = 0x00B000,   length = 0x000800
       RAMD1            : origin = 0x00B800,   length = 0x000800
       /* RAMLS4      	    : origin = 0x00A000, length = 0x000800 */
       /* RAMLS5           : origin = 0x00A800, length = 0x000800 */
       RAMLS2      		: origin = 0x009000,   length = 0x000800
       RAMLS3      		: origin = 0x009800,   length = 0x000800
       RAMLS4_5         : origin = 0x00A000,   length = 0x001000
       RAMGS3           : origin = 0x00F000,   length = 0x001000
       RAMGS5           : origin = 0x011000,   length = 0x001000
       RAMGS10          : origin = 0x016000,   length = 0x001000
       RESET           	: origin = 0x3FFFC0,   length = 0x000002
    
       FLASH_USED        : origin = 0x080000, length = 0x01FFF
    
    PAGE 1 :
    
       BOOT_RSVD       : origin = 0x000002, length = 0x000121     /* Part of M0, BOOT rom will use this for stack */
       RAMM1           : origin = 0x000400, length = 0x0003F8     /* on-chip RAM block M1 */
    //   RAMM1_RSVD      : origin = 0x0007F8, length = 0x000008     /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
       RAMLS0          	: origin = 0x008000,   length = 0x000800
       RAMLS1          	: origin = 0x008800,   length = 0x000800
       //RAMLS2      		: origin = 0x009000,   length = 0x000800
       //RAMLS3      		: origin = 0x009800,   length = 0x000800
    
       RAMGS0           : origin = 0x00C000,   length = 0x001000
       RAMGS1           : origin = 0x00D000,   length = 0x001000
       RAMGS2           : origin = 0x00E000,   length = 0x001000
    //   RAMGS3           : origin = 0x00F000,   length = 0x001000
       RAMGS4           : origin = 0x010000,   length = 0x001000
       //RAMGS5           : origin = 0x011000,   length = 0x001000
       RAMGS6           : origin = 0x012000,   length = 0x001000
       RAMGS7           : origin = 0x013000,   length = 0x001000
       RAMGS8           : origin = 0x014000,   length = 0x001000
       RAMGS9           : origin = 0x015000,   length = 0x001000
    //   RAMGS10          : origin = 0x016000,   length = 0x001000
    
    //   RAMGS11     : origin = 0x017000, length = 0x000FF8   /* Uncomment for F28374D, F28376D devices */
    
    //   RAMGS11_RSVD : origin = 0x017FF8, length = 0x000008    /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
       RAMGS11          : origin = 0x017000, length = 0x001000     /* Only Available on F28379D, F28377D, F28375D devices. Remove line on other devices. */
       RAMGS12          : origin = 0x018000, length = 0x001000     /* Only Available on F28379D, F28377D, F28375D devices. Remove line on other devices. */
       RAMGS13          : origin = 0x019000, length = 0x001000     /* Only Available on F28379D, F28377D, F28375D devices. Remove line on other devices. */
       RAMGS14          : origin = 0x01A000, length = 0x001000     /* Only Available on F28379D, F28377D, F28375D devices. Remove line on other devices. */
       RAMGS15          : origin = 0x01B000, length = 0x000FF8     /* Only Available on F28379D, F28377D, F28375D devices. Remove line on other devices. */
    
    //   RAMGS15_RSVD : origin = 0x01BFF8, length = 0x000008    /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
                                                                /* Only on F28379D, F28377D, F28375D devices. Remove line on other devices. */
    
       EMIF1_CS0n       : origin = 0x80000000, length = 0x10000000
       EMIF1_CS2n       : origin = 0x00100000, length = 0x00200000
       EMIF1_CS3n       : origin = 0x00300000, length = 0x00080000
       EMIF1_CS4n       : origin = 0x00380000, length = 0x00060000
       EMIF2_CS0n       : origin = 0x90000000, length = 0x10000000
       EMIF2_CS2n       : origin = 0x00002000, length = 0x00001000
    
       CANA_MSG_RAM     : origin = 0x049000,   length = 0x000800
       CANB_MSG_RAM     : origin = 0x04B000,   length = 0x000800
    
       CLA1_MSGRAMLOW   : origin = 0x001480,   length = 0x000080
       CLA1_MSGRAMHIGH  : origin = 0x001500,   length = 0x000080
    }
    
    SECTIONS
    {
       codestart        : > BEGIN,      PAGE = 0
       .text            : >> RAMD0 | RAMD1 | RAMGS5 | RAMLS2 | RAMLS3 | RAMLS4_5 | RAMGS3 | RAMGS10,    PAGE = 0
       .cinit           : > RAMM0,      PAGE = 0
       .switch          : > RAMM0,      PAGE = 0
       .reset           : > RESET,      PAGE = 0, TYPE = DSECT /* not used, */
       .stack           : > RAMM1,      PAGE = 1
       /* IMPORTANT: The FreeRTOS statically allocated stack should be allocated to this section only */
       .freertosStaticStack  : >> RAMGS0 | RAMGS1 | RAMGS2,        PAGE = 1
       /* IMPORTANT: The FreeRTOS heap should be allocated to this section only as the C28x stack
          memory can be allocated in the lower 64k RAM memory only. */
       .freertosHeap         : >> RAMGS9,            PAGE = 1
    
    #if defined(__TI_EABI__)
       .bss             : > RAMGS6,    PAGE = 1
       .bss:output      : > RAMGS6,    PAGE = 1
       .init_array      : > RAMM0,     PAGE = 0
       .const           : > RAMGS7,    PAGE = 1
       .data            : > RAMGS7,    PAGE = 1
       .sysmem          : > RAMGS7,    PAGE = 1
    #else
       .pinit           : > RAMM0,     PAGE = 0
       .ebss            : > RAMGS6,    PAGE = 1
       .econst          : > RAMGS7,    PAGE = 1
       .esysmem         : > RAMGS7,    PAGE = 1
    #endif
       Filter_RegsFile  : > RAMGS8,	    PAGE = 1
    
       .em1_cs0         : > EMIF1_CS0n, PAGE = 1
       .em1_cs2         : > EMIF1_CS2n, PAGE = 1
       .em1_cs3         : > EMIF1_CS3n, PAGE = 1
       .em1_cs4         : > EMIF1_CS4n, PAGE = 1
       .em2_cs0         : > EMIF2_CS0n, PAGE = 1
       .em2_cs2         : > EMIF2_CS2n, PAGE = 1
    
        /* CLA specific sections */
       Cla1Prog         : > RAMLS1, PAGE=1
    
       CLADataLS0		: > RAMLS0, PAGE=1
       CLADataLS1		: > RAMLS0, PAGE=1
    
       Cla1ToCpuMsgRAM  : > CLA1_MSGRAMLOW,   PAGE = 1
       CpuToCla1MsgRAM  : > CLA1_MSGRAMHIGH | RAMGS4,  PAGE = 1
    
       /* The following section definition are for SDFM examples */
       Filter1_RegsFile : > RAMGS12,	PAGE = 1, fill=0x1111
       Filter2_RegsFile : > RAMGS13,	PAGE = 1, fill=0x2222
       Filter3_RegsFile : > RAMGS14,	PAGE = 1, fill=0x3333
       Filter4_RegsFile : > RAMGS4,	PAGE = 1, fill=0x4444
    
    #ifdef __TI_COMPILER_VERSION__
       #if __TI_COMPILER_VERSION__ >= 15009000
        .TI.ramfunc : {} > RAMM0,      PAGE = 0
       #else
        ramfuncs    : > RAMM0      PAGE = 0   
       #endif
    #endif
    
    #ifdef CLA_C
       /* CLA C compiler sections */
       //
       // Must be allocated to memory the CLA has write access to
       //
       CLAscratch       :
                         { *.obj(CLAscratch)
                         . += CLA_SCRATCHPAD_SIZE;
                         *.obj(CLAscratch_end) } >  RAMLS0,  PAGE = 1
    
       .scratchpad      : > RAMLS0,       PAGE = 1
       .bss_cla		    : > RAMLS0,       PAGE = 1
       .const_cla	    : > RAMLS0,       PAGE = 1
    #endif //CLA_C
    
    
    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */
    

    this is my linker file.

    if i add the below code in the above file (at bottom, after the #endif), the error is solved but i am not able to write or read the flash.

    GROUP
    {
    .TI.ramfunc
    { -l F021_API_F2837xS_FPU32_EABI.lib}

    } LOAD = FLASH_USED,
    RUN = RAMGS11,
    LOAD_START(RamfuncsLoadStart),
    LOAD_SIZE(RamfuncsLoadSize),
    LOAD_END(RamfuncsLoadEnd),
    RUN_START(RamfuncsRunStart),
    RUN_SIZE(RamfuncsRunSize),
    RUN_END(RamfuncsRunEnd),
    ALIGN(8)
    }

    please guide me further.

    thanks and regards

    Muzammil Qureshi 

  • Hi Muzammil,

    Now that your code is able to compile after editing the linker file, what behavior do you see when attempting to write to flash? Are you following the flash initialization shown in the flash_programming example for F2837xS?

    Kind regards,

    Skyler