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/TMS320F28069: Running code in RAM when booting from FLASH

Part Number: TMS320F28069

Tool/software: Code Composer Studio

Hi, I'm currently using the TMS28069, but I encountered a problem that I want my 28069 to boot from FLASH and then move the function code into RAM to operate. I have already change my .cmd file to flash version and added the code below

    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (Uint32)&RamfuncsLoadSize);
    InitFlash();

And also, I have put my function in "ramfuncs" as shown below

#include "math.h"
#pragma CODE_SECTION(my_func, "ramfuncs");

void my_func(){
    float res1;
    res1 = cos(angle);
}

Since I used the function "cos" from the library "math.h" in "my_func" and this function is definitely time-consuming, so I want it to run in RAM as well. However, I don't know is it necessary for me to manually put "cos" into "ramfuncs" just like this:

#pragma CODE_SECTION(cos, "ramfuncs");

I have checked the .map file to see the location of the "cos" function and found that it stays always in FLASH area no matter whether I added the code above or not. 

Thanks for your help, sincerely.

  • While there is a function in the RTS library named cos, it calls many other functions.  Putting just cos in RAM is unlikely to help much.  This solution shows how to put multiple functions from RTS in RAM.

    I presume the linker command file has some lines similar to the following ...

            .TI.ramfunc : {} LOAD = FLASHD,
                             RUN = RAML0,
                             LOAD_START(_RamfuncsLoadStart),
                             LOAD_END(_RamfuncsLoadEnd),
                             RUN_START(_RamfuncsRunStart),
                             PAGE = 0
    

    Change these lines to something similar to ...

        .TI.ramfunc :
        {
           *(.TI.ramfunc)
           rts2800_ml.lib<k_rem_pio2.c.obj>(.text)
           rts2800_ml.lib<s_cosf.c.obj>(.text)
        }
                             LOAD = FLASHD,
                             RUN = RAML0,
                             LOAD_START(_RamfuncsLoadStart),
                             LOAD_END(_RamfuncsLoadEnd),
                             RUN_START(_RamfuncsRunStart),
                             PAGE = 0

    If you remove lines 4-5, this code does exactly the same thing as the lines above.  Line 4 specifies the .text input section from the object file k_rem_pio2.c.obj from the RTS library rts2800_ml.lib.  Line 5 does the same thing for the object file s_cosf.c.obj.  These are two of the largest functions used when you call cos.  Feel free to experiment with which RTS object files to allocate to RAM.

    This solution is adapted from the article Linker Command File Primer, especially the sub-chapter titled Allocate a Single Input Section from a Library.

    Thanks and regards,

    -George