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.

CCS/tms320c6678: FAR_START symbol resolution error

Part Number: TMS320C6678


Tool/software: Code Composer Studio

Hello,

I need to manually clear the bss and the far section of my target (I can't use the cinit automatic zero init feature)

I wrote this code inside the main function

int main(void)
{
    U16 Ind;
    U16 Size;
    U8* Adr;

    //Zero init of BSS RAM section
    //Size = (U16)_symval(&BSS_SIZE); //Doesn't run
    Size = ((U32)_symval(&BSS_END)) - ((U32)_symval(&BSS_START));
    for (Ind=0;Ind<Size;Ind++)
        *((U8*)_symval(&BSS_START) + Ind) = 0;
    //Zero init of FAR RAM section
    Size = ((U32)&FAR_END) - ((U32)&FAR_START);
    Adr = (U8*)_symval(&FAR_START);
    for (Ind=0;Ind<Size;Ind++)
        *Adr++=0;

In the cmd file I added following declarations

    .far           >  SHRAM
            RUN_START(FAR_START)
            RUN_END(FAR_END)
            RUN_SIZE(FAR_SIZE)
and

    .bss           > CORE0_L2_SRAM_OTHER
            RUN_START(BSS_START)
            RUN_END(BSS_END)
            RUN_SIZE(BSS_SIZE)

In the map file, the symbols are created with the right values

The code is located into CORE0_L2_SRAM (main adress is 0x1083b580).

The code compile and runs for bss section, but not for far section : I get this error message : "#17003-D :   relocation from function "main" to symbol "FAR_END" overflowed; the 28-bit relocated address 0xb7947e6 is too large to encode in the 15-bit unsigned field (type = 'R_C6000_SBR_U15_B' (11), file = "./main.obj", offset = 0x00000064, section = ".text")    main.c    /bmw_foe_dp_dsp_cpu01    line 125    C/C++ Problem"


Could you please help me?

  • Your code must declare the symbols BSS_START, FAR_START, etc.  When you do that, be sure to use the far keyword.  Like this ...

    extern far int BSS_START, BSS_END, BSS_SIZE;
    extern far int FAR_START, FAR_END, FAR_SIZE;

    Without the far, the compiler presumes these symbols are relative to the data page register (DP), and computes the address that way.  Because these symbols are not relative the DP, the assembly code generated by the compiler does not build.  Adding the far keyword tells the compiler these are absolute symbols, and it generates different code that does not use the DP.  

    The C6000 assembly language tools manual has a section titled Using Linker Symbols in C/C++ Applications which describes how to refer to symbols (like BSS_START) which are defined by the linker.  This section should say that using far is necessary, but it does not.  So I filed CODEGEN-3797 in the SDOWP sysmem to have that section corrected.  You are welcome to follow it with the SDOWP link below in my signature.

    An optimization to consider ... Instead of coding those loops by hand, call the RTS routine memset instead.  It would look something like ...

    #include <string.h> // for memset
    
    // many lines later, in main ...
       memset(&BSS_START, 0, _symval(&BSS_SIZE));
       memset(&FAR_START, 0, _symval(&FAR_SIZE));

    Thanks and regards,

    -George

  • Thank you very much for your answer : I added far keyword into my declaration and now it works.
    I also took into account your optimization suggestions.