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.

TMS320F28377D: run in ram

Part Number: TMS320F28377D

Tool/software:

Hi,everyone

i need some help about App Code run in ram

before i use the following type to run the Code in ram,everything is ok,compiling with no errors. after i do the following :

(1) i add my first App1.obj(.text), compiling is successful, with no errors.

(2)i add my 2nd,which named App2.obj(.text),errors happen, which is

redefined: xxxx first defined in "<whole-program>"; redefined in "App2.obj" ,where  xxxx is fuction name or variable name that defined in App2,and they are all private variable.

.TI.ramfunc : { App1.obj (.text),

App2.obj(.text)}

LOAD = FLASHH,

RUN = RAMS2_6,

LOAD_START(_RamfuncsLoadStart),

LOAD_SIZE(_RamfuncsLoadSize),

LOAD_END(_RamfuncsLoadEnd),

RUN_START(_RamfuncsRunStart),

RUN_SIZE(_RamfuncsRunSize),

RUN_END(_RamfuncsRunEnd),

so, why this happens? only after change the cmd file to run Code in Ram, the errors come out, can you please help me solve the issue?

  • Hello,

    I have brought this thread to the attention of the compiler experts for further analysis.

    Thanks

    ki

  • Thanks for your reply ,  this issue bothers me a lot.

  • Please search the article Linker Command File Primer for the part titled Load at One Address, Run from a Different Address.  Change these lines in your linker command file ...

    .TI.ramfunc : { App1.obj (.text),

    App2.obj(.text)}

    LOAD = FLASHH,

    RUN = RAMS2_6,

    LOAD_START(_RamfuncsLoadStart),

    LOAD_SIZE(_RamfuncsLoadSize),

    LOAD_END(_RamfuncsLoadEnd),

    RUN_START(_RamfuncsRunStart),

    RUN_SIZE(_RamfuncsRunSize),

    RUN_END(_RamfuncsRunEnd),

    ... to be similar to the example in the article.  In addition, apply the ramfunc attribute to all the functions you want in the .TI.ramfunc output section.  For details, please search the C28x compiler manual for the phrase ramfunc attribute.

    Thanks and regards,

    -George

  • Hi,George

    Thanks for your information. What confused me is that if other APP_x.obj(.text) added, no errors occur, only after I add  APP_2.obj(.text), compiling is wrong.

    below is the detail:

    (1) other APP_x.obj(.text) added, no errors:

    (2) after the 2nd .obj (.text) is added,errors  occur

    so , what  difference  between the two .c file  which can cause this error ?  Do you have any suggestions for me to locate the issue rapidly?

    Thanks .

  • You build with --opt_level=4.  This is also called link-time optimization (LTO).  LTO involves, among other things, recompiling most parts of the program into a single temporary object file.  This temporary file has the name <whole-program> you see in the diagnostics.  Because you use LTO, do not refer to specific object files in the linker command file.  Otherwise, you can end up redefining the same functions and data, which results in those build errors.  

    what  difference  between the two .c file  which can cause this error ?

    I am not certain, but I think one file is not built with --opt_level=4, thus none of the functions or data it defines appears in <whole-program>.  Therefore, an appearance of this file in the linker command file does not result in any redefinition errors.

    The fix is as I described in my previous post.  Change the linker command file to refer to no object files.  For the functions you want in the output section .TI.ramfunc, apply the ramfunc attribute.

    Thanks and regards,

    -George

  • Hi,George

    Thanks for your advice. Using CODE_SECTION  instead of mentioned method above  is effective. However, Off the -OPT_LEVEL also report same errors,if you have any idea on this, please contact me.

    One more question, should  the Ram Zone which run the CODE  be continuous? Can I RUN the CODE in different RAM Zone,like, RAMLS0_LS3 and RAMLS5, i have tried, it seems noneffective.

    Thanks.Have a good day.

  • Using CODE_SECTION  instead of mentioned method above  is effective.

    I'm not sure what you mean.

    Off the -OPT_LEVEL also report same errors

    I'm confused.  What errors occur?  Please show an example.  Please copy and paste the text of the associated commands, system response, etc.  Do not use a screenshot.

    should  the Ram Zone which run the CODE  be continuous? Can I RUN the CODE in different RAM Zone,like, RAMLS0_LS3 and RAMLS5, i have tried, it seems noneffective.

    Please see if this forum post is helpful.

    Thanks and regards,

    -George

  • Hi,George

    I'm not sure what you mean.

    I mean by using #pragma CODE_SECTION (App_UnitFaultxxxx, ".TI.ramfunc"), no errors report. "App_UnitFaultxxxx" are the Functions which belongs to "App_UnitFault.c" file. I think this method is what you suggest ever. 

    I'm confused.  What errors occur?  Please show an example.  Please copy and paste the text of the associated commands, system response, etc.  Do not use a screenshot.

    MEMORY
    {
    PAGE 0 : /* Program Memory */

    BEGIN : origin = 0x084000, length = 0x000002
    RAMD0_1 : origin = 0x00B000, length = 0x001000 /* BOOT CODE */
    RAMLS0 : origin = 0x008000, length = 0x000800 /* CLA CODE */
    RAMLS2_5 : origin = 0x009000, length = 0x002000 /* CPU1 CODE */
    RESET : origin = 0x3FFFC0, length = 0x000002

    /* Flash sectors */
    FLASHA_B : origin = 0x080000, length = 0x004000 /* BOOT */
    FLASHC_G : origin = 0x084002, length = 0x01BFFE /* APP */
    FLASHH : origin = 0x0A0000, length = 0x008000 /* on-chip Flash */
    FLASHI : origin = 0x0A8000, length = 0x008000 /* on-chip Flash */
    FLASHJ : origin = 0x0B0000, length = 0x008000 /* on-chip Flash */
    FLASHK : origin = 0x0B8000, length = 0x002000 /* on-chip Flash */
    FLASHL : origin = 0x0BA000, length = 0x002000 /* on-chip Flash */
    FLASHM : origin = 0x0BC000, length = 0x002000 /* on-chip Flash */
    FLASHN : origin = 0x0BE000, length = 0x001FFE /* on-chip Flash */

    PAGE 1 :

    BOOT_RSVD : origin = 0x000002, length = 0x000120 /* Part of M0, BOOT rom will use this for stack */
    RAMM0_1 : origin = 0x000126, length = 0x0006D9 /* BOOT DATA */
    RAMLS1 : origin = 0x008800, length = 0x000800 /* CLA DATA */
    RAMGS0_6 : origin = 0x00C000, length = 0x007000 /* CPU1 DATA */
    RAMGS7 : origin = 0x013000, length = 0x001000 /* CPU1 CPU2 Shared DATA,CPU1 can read Write, CPU2 only Read */
    RAMGS8_15 : origin = 0x014000, length = 0x008000 /* CPU2 DATA */

    CPU2TOCPU1RAM(R): origin = 0x03F800, length = 0x000400 /* CPU1 only Read */
    CPU1TOCPU2RAM : origin = 0x03FC00, length = 0x000400
    CLA1_MSGRAMLOW : origin = 0x001480, length = 0x000080
    CLA1_MSGRAMHIGH : origin = 0x001500, length = 0x000080
    }

    SECTIONS
    {
    /* Allocate program areas: */
    .cinit : > FLASHC_G PAGE = 0, ALIGN(4)
    .pinit : > FLASHC_G PAGE = 0, ALIGN(4)
    .text : >> FLASHC_G, PAGE = 0, ALIGN(4)

    codestart : > BEGIN PAGE = 0, ALIGN(4)

    /* Allocate uninitalized data sections: */
    .stack : > RAMM0_1 PAGE = 1
    .ebss : >> RAMGS0_6, PAGE = 1
    .esysmem : > RAMGS0_6 PAGE = 1

    /* Initalized sections go in Flash */
    .econst : > FLASHC_G PAGE = 0, ALIGN(4)
    .switch : > FLASHC_G PAGE = 0, ALIGN(4)
    .reset : > RESET, PAGE = 0, TYPE = DSECT /* not used */

    secureFlashFuncs : > FLASHC_G PAGE = 0, ALIGN(4)
    FPUmathTables : > FLASHC_G, PAGE = 0, ALIGN(4)

    CLAData : > RAMLS1, PAGE = 1

    Cla1ToCpuMsgRAM : > CLA1_MSGRAMLOW, PAGE = 1
    CpuToCla1MsgRAM : > CLA1_MSGRAMHIGH, PAGE = 1

    GROUP : > RAMGS7, PAGE = 1
    {
    ADC_RAM /* AD Data Shared RAM */
    }

    /* CLA specific sections */
    Cla1Prog : LOAD = FLASHC_G ,
    RUN = RAMLS0,
    LOAD_START(_Cla1funcsLoadStart),
    LOAD_END(_Cla1funcsLoadEnd),
    RUN_START(_Cla1funcsRunStart),
    LOAD_SIZE(_Cla1funcsLoadSize),
    PAGE = 0, ALIGN(4)

    #ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
    .TI.ramfunc :
     {App_UnitFault.obj (.text)} //should not be enabled, or errors come out. 

    //But,if other .c files are placed here, no errors.


    LOAD = FLASHC_G,
    RUN = RAMLS2_5,
    LOAD_START(_RamfuncsLoadStart),
    LOAD_SIZE(_RamfuncsLoadSize),
    LOAD_END(_RamfuncsLoadEnd),
    RUN_START(_RamfuncsRunStart),
    RUN_SIZE(_RamfuncsRunSize),
    RUN_END(_RamfuncsRunEnd),
    PAGE = 0, ALIGN(4)
    #else
    ramfuncs : LOAD = FLASHCDEFG,
    RUN = RAMLS2_5,
    LOAD_START(_RamfuncsLoadStart),
    LOAD_SIZE(_RamfuncsLoadSize),
    LOAD_END(_RamfuncsLoadEnd),
    RUN_START(_RamfuncsRunStart),
    RUN_SIZE(_RamfuncsRunSize),
    RUN_END(_RamfuncsRunEnd),
    PAGE = 0, ALIGN(4)
    #endif
    #endif

    /* The following section definitions are required when using the IPC API Drivers */
    GROUP : > CPU1TOCPU2RAM, PAGE = 1
    {

    }

    GROUP : > CPU2TOCPU1RAM, PAGE = 1
    {

    }

    #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) } > RAMLS1, PAGE = 1

    .scratchpad : > RAMLS1, PAGE = 1
    .bss_cla : > RAMLS1, PAGE = 1
    .const_cla : LOAD = FLASHC_G,
    RUN = RAMLS1,
    RUN_START(_Cla1ConstRunStart),
    LOAD_START(_Cla1ConstLoadStart),
    LOAD_SIZE(_Cla1ConstLoadSize),
    PAGE = 1, ALIGN(4)

    #endif //CLA_C

    //--------------------------------------------------------------------------------------------//

    Above is the Main CMD file,report errors are below:

    #10056 symbol "_App_xxx" redefined: first defined in "<whole-program>"; redefined in "App_UnitFault.obj"

    Off the -OPT_LEVEL also report same errors

    You said the errors may be in connection with Optimization, so I turn off the option, the same thing happen.

    Thanks for your reply and patience.

  • I mean by using #pragma CODE_SECTION (App_UnitFaultxxxx, ".TI.ramfunc"), no errors report. "App_UnitFaultxxxx" are the Functions which belongs to "App_UnitFault.c" file. I think this method is what you suggest ever. 

    I did not suggest using #pragma CODE_SECTION.  I suggested using the ramfunc attribute.  The most significant effect of using ramfunc is that the affected function is allocated to .TI.ramfunc.  But other things happen too.

    Even though you disabled optimization, you still see this diagnostic ...

    #10056 symbol "_App_xxx" redefined: first defined in "<whole-program>"; redefined in "App_UnitFault.obj"

    Please put your CCS project into the state where this occurs.  Next, rebuild the entire project.  One way to do that is to right-click on the name of the project and select Rebuild Project.  Then save the contents of the Console (not Problems) view to a text file.  Use the icon named Copy Build Log (older versions of CCS) or Save build log to file (newer versions of CCS).  When you name the log file, be sure to use the file extension .txt.  Please attach that text file to your next post.

    Thanks and regards,

    -George

  • Hi, George

    I use the ramfunc attribute , it works too.  Either #pragma CODE_SECTION or ramfunc attribute is effective. So, I decide to ignore the problem which caused by reference {.txt} in CMD file. Thank you for your long support. Have a good day.