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.

Moving prolog and epilog to RAM

Other Parts Discussed in Thread: TMS320F2812, SYSBIOS

Hi,


when using the Code Optimizer it uses the Functions prolog_c28x_1, prolog_c28x_2, prolog_c28x_1, epilog_c28x_1 and epilog_c28x_2.

They are executed before an after each function call.

These functions are usually located in FLASH. As i need to program the internal FLASH i must run all Functions from RAM during Firmware update.

All other Functions i use during Firmware update are loaded to RAM but i as prolog and epilog are executed without my control, the CPU crashes after erasing FLASH.

i have tired to move those Functions to RAM using:

     fastcode { *(ramfuncs)
            -l = rts2800_ml.lib<epilog.obj>(.text)
            -l = rts2800_ml.lib<prolog.obj>(.text)
}
                           LOAD = FLASH,
                          RUN  = H0SARAM,
                          LOAD_START(_RamfuncsLoadStart),
                          LOAD_END(_RamfuncsLoadEnd),
                          RUN_START(_RamfuncsRunStart),
                          PAGE = 0

in the linker .cmd file as i usually do.

When linking i get the following errors:

error #10056: symbol "_realloc" redefined: first defined in app_p28L.o28L redefined in rts2800_ml.lib<memory.obj>"

error #10056: symbol "_free" redefined: first defined in app_p28L.o28L redefined in rts2800_ml.lib<memory.obj>"

error #10056: symbol "_calloc" redefined: first defined in app_p28L.o28L redefined in rts2800_ml.lib<memory.obj>"

error #10056: symbol "_malloc" redefined: first defined in app_p28L.o28L redefined in rts2800_ml.lib<memory.obj>"


How can i move the prolog and epilog functions to RAM?


MCU: TMS320F2812

Compiler: v16.6.0.STS

CCS: 6.2

BIOS: 6.46.1.38

XDC: 3.32.1.22_core


  • I don't understand how this occurred.  Please attach the linker command file to your next post.  Add the file extension .txt, or it gets rejected.  Also show the command used to perform the link.

    Thanks and regards,

    -George

  • Hi George,


    i have attached my linked cmd file.

    /* --COPYRIGHT--,BSD
     * Copyright (c) $(CPYYEAR), Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    /*
     *  ======== TMS320F2812.cmd ========
     *  Define the memory block start/length for the F2812
     *
     *! Revision History
     *! ================
     *! 26-May-2011 jv  created to support c28 generic platform.
     */
    
    /*  
     *  PAGE 0 will be used to organize program sections
     *  PAGE 1 will be used to organize data sections
     *
     *  Notes: 
     *      Memory blocks on F2812 are uniform (ie same
     *      physical memory) in both PAGE 0 and PAGE 1.  
     *      That is the same memory region should not be
     *      defined for both PAGE 0 and PAGE 1.
     *      Doing so will result in corruption of program 
     *      and/or data. 
     */
    
    MEMORY
    {
    PAGE 0:    /* Program Memory */
    
        OTP         : origin = 0x3D7800, length = 0x000800     /* on-chip OTP */
        FLASH       : origin = 0x3D8000, length = 0x01FF80     /* on-chip FLASH */
        CSM_RSVD    : origin = 0x3F7F80, length = 0x000076     /* Program with all 0x0000 when CSM is in use. */
        BEGIN       : origin = 0x3F7FF6, length = 0x000002     /* Used for "boot to Flash" bootloader mode. */
        CSM_PWL     : origin = 0x3F7FF8, length = 0x000008     /* CSM password locations in FLASH */
        H0SARAM     : origin = 0x3F8000, length = 0x002000     /* on-chip RAM block H0 */
       	//ZONE2       : origin = 0x080000, length = 0x020000     /* XINTF zone 2 */
       	ZONE6       : origin = 0x100000, length = 0x080000     /* XINTF zone 6 */
    
        ROM         : origin = 0x3FF000, length = 0x000FC0     /* Boot ROM available if MP/MCn=0 */
        RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM (MP/MCn=0) or XINTF zone 7 (MP/MCn=1) */
        VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM (MP/MCn=0) or XINTF zone 7 (MP/MCn=1) */
    
    PAGE 1 :   /* Data Memory */
       	PIEVECT     : origin = 0x000D00, length = 0x000100
        M01SARAM    : origin = 0x000000, length = 0x000800     /* on-chip RAM block M0, M1 */
        L01SARAM    : origin = 0x008000, length = 0x002000     /* on-chip RAM block L0, L1 */
     	DRAME0     	: origin = 0x080000, length = 0x040000 		// External Data RAM
    }
    
    /* 
     *  Allocate sections to memory blocks.
     *  Note:
     *      codestart   user defined section in DSP28_CodeStartBranch.asm
     *                  used to redirect code execution when booting to flash
     *
     *      ramfuncs    user defined section to store functions that will be
     *                  copied from Flash into RAM
     */ 
     
    SECTIONS
    {
    
        /* Allocate program areas: */
        .cinit              : > FLASH       PAGE = 0
        .pinit              : > FLASH       PAGE = 0
        .text               : > FLASH       PAGE = 0
        codestart           : > BEGIN       PAGE = 0
      	fastcode { *(ramfuncs)
    
      		  -l = rts2800_ml.lib<epilog.obj>(.text)
      		  -l = rts2800_ml.lib<prolog.obj>(.text)
    							}
    		  				  LOAD = FLASH,
                              RUN  = H0SARAM,
                              LOAD_START(_RamfuncsLoadStart),
                              LOAD_END(_RamfuncsLoadEnd),
                              RUN_START(_RamfuncsRunStart),
                              PAGE = 0
    
       Flash28_API:
       {
            -l ..\Libs\Flash2812_API_V210.lib(.econst)
            -l ..\Libs\Flash2812_API_V210.lib(.text)
       }                   LOAD = FLASH,
                           RUN = H0SARAM,
                           LOAD_START(_Flash28_API_LoadStart),
                           LOAD_END(_Flash28_API_LoadEnd),
                           RUN_START(_Flash28_API_RunStart),
                           PAGE = 0
    
        csmpasswds          : > CSM_PWL     PAGE = 0
        csm_rsvd            : > CSM_RSVD    PAGE = 0
    
        /* Allocate uninitalized data sections: */
        .stack              : > M01SARAM			    		PAGE = 1
        .cio                : > DRAME0     						PAGE = 1
        .ebss               : > L01SARAM | M01SARAM | DRAME0	PAGE = 1
        .esysmem            : > L01SARAM | M01SARAM     		PAGE = 1
    
        /* Initalized sections go in Flash */
        /* For SDFlash to program these, they must be allocated to page 0 */
        .econst             : > FLASH       PAGE = 0
        .switch             : > FLASH       PAGE = 0
    
        /* Allocate IQ math areas: */
        IQmath              : > FLASH       PAGE = 0                  /* Math Code */
        IQmathTables        : > ROM         PAGE = 0, TYPE = NOLOAD   /* Math Tables In ROM */
    
        .LoggerBufSection 	: > DRAME0 						PAGE = 1
       .taskStackSection 	: > L01SARAM 					PAGE = 1
    
       IntRam			: > M01SARAM | L01SARAM,   PAGE = 1
       ExtRam			: > DRAME0, 	PAGE = 1
    
       fir_volt_db align(0x100)		> M01SARAM,   PAGE = 1
       fir_volt				 	  : > M01SARAM,   PAGE = 1
       fir_volt_coeff align(0x100)  > L01SARAM,   PAGE = 1
       fir_curr_db align(0x100)		> M01SARAM,   PAGE = 1
       fir_curr 			 	  : > M01SARAM,   PAGE = 1
    
       /* .reset is a standard section used by the compiler.  It contains the */
       /* the address of the start of _c_int00 for C Code.   /*
       /* When using the boot ROM this section and the CPU vector */
       /* table is not needed.  Thus the default type is set here to  */
       /* DSECT  */
       .reset              : > RESET,      PAGE = 0, TYPE = DSECT
       vectors             : > VECTORS     PAGE = 0, TYPE = DSECT
    }
    

    this is the linker command:

    "C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.6.0.STS/bin/cl2000" -v28 -ml -mt -O3 --opt_for_speed=2 --fp_mode=relaxed --advice:performance=all -g --c99 --cpp_default --gcc --diag_suppress=552 --diag_warning=225 --display_error_number --gen_func_subsections=on --gen_data_subsections=on -z -m"HVA200 Card K SYSBIOS.map" --warn_sections -i"C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.6.0.STS/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.6.0.STS/include" --diag_suppress=16002 --display_error_number --xml_link_info="HVA200 Card K SYSBIOS_linkInfo.xml" --rom_model -o "HVA200 Card K SYSBIOS.out" "./DSPHeader/DSP281x_CpuTimers.obj" "./DSPHeader/DSP281x_GlobalVariableDefs.obj" "./DSPHeader/DSP281x_usDelay.obj" "--- my source object files --- "../CMD/TMS320F2812 FLASH.cmd" "../DSPHeader/DSP281x_Headers_BIOS.cmd" "../Libs/Flash2812_API_V210.lib" -l"configPkg/linker.cmd" -llibc.a

  • I thought I could reproduce the problem with just the linker command file and build options.  However, I am wrong.  I cannot reproduce the problem.  Thus, I am forced to ask you for the full CCS project.  Please see this post for the details of that process.

    Thanks and regards,

    -George

  • I'm not allowed to send you my Project, but i was able to reproduce the problem with an example project.

    I found out that it only happens when C++ is used int the Project. In this project no "epilog.obj" is generated, but i dont know why.

    However it shows exactly what my Problem is: redefinition of RTS functions...

    redefinition_demo_project.zip

  • The problem with the example project is the link order.  The linker should process your custom link command file TMS320F2812.cmd after the link command file(s) auto-generated by the SYS/BIOS configuration.  And the compiler runtime support library should appear last of all.  

    Right click on the project name and select Properties.  Look in the lower left corner.  If it says Show advanced settings, then click on that.  In the pane on the left, click on CCS Build.  In the pane on the right, select the tab Link Order.  Click Add.  Click Select All, then click OK.  Change the link order of a file by selecting it, then clicking the Up or Down buttons.  Make TMS320F2812.cmd appear 2nd to last, and -l"libc.a" appear last.  See the screen shot below.  Click OK.  Rebuild.  The problem goes away.

    Thanks and regards,

    -George

  • This solved the problem!


    Thank you!