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/TMS320F28379D: Move one function in a TI supplied library to RAM.

Part Number: TMS320F28379D

Tool/software: Code Composer Studio

We are using a TI supplied library which is currently being stored and executed from flash.  Is there a way to move a single function from that library to RAM for execution?

Thank you,

Ed

  • Ed Sanders said:
    Is there a way to move a single function from that library to RAM for execution?

    I presume this move happens entirely at build time.  If you are talking about allocating that function to FLASH, then, during system startup, copying it from FLASH to RAM, that is handled differently then what I discuss in this post.

    Please see the sub-chapter Allocate a Single Input Section from a Library from the larger article Linker Command File Primer.

    Thanks and regards,

    -George

  • Hi George,

    This library function is currently stored in flash and run from flash. We would like to be able to link it such that we copy it to RAM and run it from there. But it’s in a library over which we have no control as it is part of Control Suite.

    Thank you,

    Ed
  • Ed Sanders said:
    we copy it to RAM and run it from there

    When you do you want this copy to occur?  During system startup?  Or later?

    Thanks and regards,

    -George

  • The copy would occur during system startup.  But only one function from the library would be copied.

  • Add lines similar to these to the SECTIONS directive of your linker command file ...

        lib_function_in_ram
        {
           library_name.lib<file_name.obj>(.text)
        } load=FLASH, run=RAM, table(BINIT)
    

    This creates an output section named lib_function_in_ram.  It has one input section.  This input section is the .text section, from the file file_name.obj, which comes from the the library library_name.lib.  This output section is allocated to the FLASH memory range for loading, and the RAM memory range for execution.  The table(BINIT) syntax means an entry is added to the BINIT copy table.  This copy table is processed by the C environment startup code to copy this output section from FLASH to RAM.  

    That copy table entry is in the output section .binit.  So, if you don't have it already, also add this line to the SECTIONS directive ...

        .binit > FLASH
    

    This allocates the .binit output section to the FLASH memory range.

    Thanks and regards,

    -George

  • I prefer to aggregate all functions which have to run from RAM in one section

    SECTIONS
    {
        ramfuncs:       {
                            rts2800_fpu32.lib<l_div.obj>(.text)
                            *(ramfuncs)
                            *(.TI.ramfunc)
                        }
                        LOAD = P_FF,
                        RUN = P_LS05 | P_D01 | P_GS05,
                        LOAD_START(_RamfuncsLoadStart),
                        LOAD_SIZE(_RamfuncsLoadSize),
                        LOAD_END(_RamfuncsLoadEnd),
                        RUN_START(_RamfuncsRunStart),
                        RUN_SIZE(_RamfuncsRunSize),
                        RUN_END(_RamfuncsRunEnd),
                        PAGE = 0, ALIGN(4)

     

  • Mitja Nemec said:
    I prefer to aggregate all functions which have to run from RAM in one section

    That is also a valid solution.  

    Note this solution does not depend on the C startup code to perform the copy from FLASH to RAM, but some other routine that must run before any call to a copied function.

    Thanks and regards,

    -George

  • George, when has this functionality been added to the compiler/linker and RTS library?

  • I presume you mean the ability to specify one input section from a object file inside a library ... That was introduced in the linker several years ago.  

    Thanks and regards,

    -George

  • No, I mean the binit table anc RTC copying section before entering main
  • Mitja Nemec said:
    No, I mean the binit table and RTS copying section before entering main

    That is introduced in version 15.12.0.LTS, January 2016.

    Thanks and regards,

    -George

  • Hi George,

    I'm trying to implement this, and need to understand what the <file_name.obj> means.

    Ed
  • That is the syntax for specifying the name of a file (also called a member) from a library.  Please see the subchapter Allocate a Single Input Section from a Library from the article Linker Command File Primer.

    Thanks and regards,

    -George