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.

TMS320F280039C: Move many functions from flash to many specified RAM locations in a simple way

Part Number: TMS320F280039C


Dear Champs,

I am asking this for our customer.

The user wants to move many functions from flash to RAM, and each function has a specified location.

We are aware that we can use

#pragma CODE_SECTION(func1, "func1_section");

in the .cmd, they use 

func1_section :

LOAD = FLASH_BANK0_SEC1,
RUN = RAMLS0,
LOAD_START(RamfuncsLoadStart),
LOAD_SIZE(RamfuncsLoadSize),
LOAD_END(RamfuncsLoadEnd),
RUN_START(RamfuncsRunStart),
RUN_SIZE(RamfuncsRunSize),
RUN_END(RamfuncsRunEnd),
ALIGN(8)

Questions:

1. Can they allocate RAM location in .c directly for better code management?

Like 

#pragma CODE_SECTION(func1, 0x0000);

#pragma CODE_SECTION(func2, 0x0100);

#pragma CODE_SECTION(func2, 0x0200);

...

2. Instead of using what we know repetitively in both .c and .cmd. Is there any simpler/easier way for them to allocate many functions, each at a specified RAM location? 

  • Hi Wayne,

    I am assigning this to our compiler team - they can suggest best on this.

    Thanks and regards,
    Vamsi

  • This post presumes the customer builds for EABI with the compiler switch --abi=eabi.  If the older COFF ABI is used, changes are needed.  

    Use the compiler switch --gen_func_subsections.  This causes each function to be allocated to a separate input section, with names similar to .text:function_name.

    In the linker command file, in the SECTIONS directive, have lines similar to ...

            .text:func1  load = FLASH, run = 0x0000, table(BINIT)
            .text:func2  load = FLASH, run = 0x0100, table(BINIT)
            .text:func3  load = FLASH, run = 0x0200, table(BINIT)
            .binit > FLASH

    Consider line 1.  This creates an output section named .text:func1.  It is made up of all the input sections with the name .text:func1.  In this case, there is only one such input section.  It is allocated to the FLASH memory range for loading, and the address 0x0000 for running.  The syntax table(BINIT) creates a copy table entry.  This copy table is automatically detected by the startup code, and is used to copy the instructions for func1 from FLASH to the address 0x0000.  This copy occurs before main is called.  Lines 2 and 3 are similar.  Line 4 allocates the .binit output section.  This is the section which contains the copy tables that are automatically created by the linker, and is typically allocated to read-only memory like FLASH.

    It is possible to write linker command file specifications that work regardless of whether EABI or COFF ABI is used.  But it is more complicated.  For now, I suspect keeping things simple is more important.

    Thanks and regards,

    -George