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.

Fine-grained memory placement?

Anonymous
Anonymous

Hi All,

I would like to ask a question on memory placement.

a typical linker.cmd said:

MEMORY
{
L2RAM: o = 0x10810000 l = 0x00020000
DDR2: o = 0x80000000 l = 0x2000000
}

SECTIONS
{
vectors > 0x80000000, RUN_START(_ISTP_START)
.bss > DDR2
.cinit > DDR2
.cio > DDR2
.const > DDR2
.data > DDR2
.far > DDR2
.stack > DDR2
.switch > DDR2
.sysmem > DDR2
.text > DDR2
/* .ddr2 > DDR2*/
}


Usually one would be able to configure linker.cmd file so that different sections are placed into different locations of the memory (L1, L2, DDR2). However, this allocation is still rather crude in the sense that one type of content (.text, .data, etc.) as a whole is placed to one location together. If I have a rather long .text section generated from a number of C source files, but only a few functions are used frequently as ISR and the majority of other functions are used much less than the ISR function, so I would prefer to place the binary code of ISR in L1P or L2 (as long as they can hold), while keeping other .text parts in DDR2.

For example:


  1. function_A:         in L1P
  2. function_B:         in L2
  3. other functions:   in DDR2

I believe that in order for this to be done, one must somehow "mark" function_A and function_B to differentiate them from others. But how can this be done? What are the remaining steps?



A similar questions is that instead of putting all .data content at one place, is there any way to specify, for example

  1. Array1:               in L1D
  2. Array2:               in L2
  3. Other data:          in DDRs

Just like for functions, one must somehow "mark" Array1 and Array2 to differentiate them from others. But how can this be done and what are the remaining steps?




Sincerely,
Zheng

  • Hello Zheng,

    I'd suggest reading Section 7.5 of Assembly Language Tools User's Guide. It may have the answers you seek:

    http://focus.ti.com/lit/ug/spru186t/spru186t.pdf

    I will also move this thread into the Compiler forum where there will be more expertise for any follow up questions you may have.

    Thanks

    ki

     

     

  • Zheng Zhao said:
    I believe that in order for this to be done, one must somehow "mark" function_A and function_B to differentiate them from others. But how can this be done? What are the remaining steps?

    You can do this with #pragma CODE_SECTION. Please take a look at section 6.8 of the Compiler Users Guide for details. Similarly #pragma DATA_SECTION can be used for data objects that you want to allocate in a separate named section. The named section can then be allocated to the desired memory region in the linker commmand file.

    For example, in the C file:

    #pragma CODE_SECTION(fn, "my_sect")
    int fn(int x)
    {
    return x;
    }

    In the linker command file:

    SECTIONS
    {
     my_sect > L2
     ...
    }

     

     

  • Anonymous
    0 Anonymous in reply to AartiG

    Dear Aarti,

    What about for data? Using

    #pragma DATA_SECTION

    directive?

     

     

    What does "bss" stand for? In the table it means "Global and static variables", which can hardly be inferred from the three letters "b""s""s". Is it an acronym, initialism or abbreviation for any longer word combination?

     

     

    Sincerely,

    Zheng

     

  • Anonymous
    0 Anonymous in reply to Ki

    Dear Ki-Soo,

    This is the right place, many thanks for moving.

     

    Zheng

  • Zheng Zhao said:

    What does "bss" stand for? In the table it means "Global and static variables", which can hardly be inferred from the three letters "b""s""s". Is it an acronym, initialism or abbreviation for any longer word combination?

    "Block Started by Symbol".  See http://en.wikipedia.org/wiki/.bss

  • Anonymous
    0 Anonymous in reply to Archaeologist

    Dear Archaeologist,

    Now I understand it, thanks very much.

     

    Zheng

  • Anonymous
    0 Anonymous in reply to AartiG

    Dear Aarti,

    Is it possible to do #pragma DATA_SECTION for multiple variables at once? For example, if one has arrays:

    • a1
    • a2
    • a3
    • a4
    • a5
    • a6
    • a7
    • a8

    I tried to write like

    #pragma DATA_SECTION (a1, a2, "my_sect"), but the compiler told me "badly formatted pragma".

     

     

    Sincerely,

    Zheng

  • The pragma syntax does not support specifying multiple variables at once. You would need to write it as:

    #pragma DATA_SECTION (a1, "my_sect")
    #pragma DATA_SECTION (a2, "my_sect")

  • Anonymous
    0 Anonymous in reply to AartiG

    Dear Aarti,

    Thanks for confirmation.

     

    Zheng