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.

placing a group of functions to some section using .cfg file

Hi

We are using a keystone multicore device.

Is there a way to place a group of functions (.text section) in some other section like #pragma CODE_SECTION does using .cfg file?

i know this can be done using linker.cmd file but can this be done using .cfg file?

Actually I want to place the code at some fixed address say 0x92000000 and the make the section write protected.

Tarun

  • Here is my post about how to place the memory at a certian address.

    http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/t/177186.aspx

    I think if you create the section in the .cfg and then place a #pragma in your code around the function, it will be the same.

    However, to make it read only - you will need to create a special platform in CCS (Using Tools->RTSC Tools->Platform->New) and create a memory section such as DDR3_RO or something and set the permissions, length and acceptable information type (code, data or both).  (Be sure to import the C66x default platform first, makes a good starting point.) Then in your config, you will reference your program section to this new memory section.

    For example here I created a special platform for my program that had MSMCRAM_NDK where I placed all the buffers for NDk in seperate section of MSMCRAM.  You could do this for DDR3 starting at 0x92000000.

    Program.sectMap[".myLocalMemory"] = "L2SRAM";

    Program.sectMap[".myHeapSection"] = "DDR3";

    Program.sectMap[".resmgr_memregion"] = {loadSegment: "L2SRAM", loadAlign:128}; /* QMSS descriptors region */

    Program.sectMap[".resmgr_handles"] = {loadSegment: "L2SRAM", loadAlign:16}; /* CPPI/QMSS/PA Handles */

    Program.sectMap[".resmgr_pa"] = {loadSegment: "L2SRAM", loadAlign:8}; /* PA Memory */

    Program.sectMap[".far:NDK_OBJMEM"] = {loadSegment: "MSMCSRAM_NDK", loadAlign: 8};

    Program.sectMap[".far:NDK_PACKETMEM"] = {loadSegment: "MSMCSRAM_NDK", loadAlign: 128};

    Also, lesson learned from created a special platform.  When you uncheck the "customize memory" box you will need to also add the length of your L1D andL1P memory sections otherwise it won't link.  Not sure why the default one will work without the length but a customized one needs the lenghth.

    Anyhow, TI please correct if I have misspoken.

    Good luck!

    Brandy

  • Thanks Brandy for the useful cues.

    Please take a look at this post that describes how to put a group of functions into a section without having to put #pragma CODE_SECTION before each function. But the approach described works only for the linker command file (correct me if I am wrong).

    http://e2e.ti.com/support/development_tools/compiler/f/343/t/41618.aspx

    I want to put functions into a section without having to put #pragma before each function.

     

    Tarun

     

  • Tarun,
    can you post the linker directives that you would use in the linker command file, and I'll check if they can be replicated in the CFG script?

  • Thanks Sasha

    Here are the directives I use in my linker command file

     

    SECTIONS
    {
        .mytext :
        {
            file1.obj(.text)      /* Link .text section from f1.obj */
            file2.obj(.text)      /* Link .text from f4.obj */
        }
    }

    One more thing, I made some memory sections in .cfg file using Program.sectMap() but these sections are not visible in my linker command file Is there a way I could access those section in my linker command file?

    I mean could I do this in my .cfg file-

    Program.sectMap[".mytext"] = new prog.SectionSpec();

    Program.sectMap[".mytext"].loadSegment = 'DDR3'

     

    Then in my linker command file I want to do this

    SECTIONS
    {
        .mytext :
        {
            file1.obj(.text)      /* Link .text section from f1.obj */
            file2.obj(.text)      /* Link .text from f4.obj */
        }
    }

    Is this possible?

    Tarun

  • Tarun,
    combining input sections is not supported by Program.sectMap. What you can do, short of writing your own complete linker command file, is to use Program.sectionsTemplate property to insert your own section allocations.This config parameter specifies a template that replaces the automatically generated directive SECTIONS with your own content:
    Program.sectionsTemplate = "../mySections.xdt";

    If you start the path to the template file with "../", then you can keep the template in the same directory with your config script.
    Then, you need to create the template file "mySections.xdt". It uses XDCtools-specific template syntax, but your goal is simple enough that it requires only a couple of lines of code:

    .mytext 
        {
            file1.obj(.text)      /* Link .text section from f1.obj */
            file2.obj(.text)      /* Link .text from f4.obj */
        } > DDR3
    `$args[1]`

    The first line is your addition, and the second line adds the allocation for the rest of the sections. Check the linked docs for Program.sectionsTemplate for more detailed explanation how it works.

  • Thanks Sasha  for all the help.

    Making a template worked although I had to give it an absolute path but am trying to figure out what went wrong with relative path.

     

    Thanks

    Tarun