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.

Stack allocation

Other Parts Discussed in Thread: HALCOGEN

Hello,

I'm running some performance test on the TMS570LS3137HDK. I managed to execute benchmarks from SDRAM with the code sections, data, bss and sysmem in the SDRAM. The next step is to put the stack in the SDRAM.

However, HalcoGen (03.02.02) does not allow me to configure the stack as I want. I tried to modify the linker command file (see below) without success.

--retain="*(.intvecs)"
--heap_size=0x80000
--stack_size=0x80000

/*----------------------------------------------------------------------------*/
/* Memory Map                                                                 */

MEMORY
{
    VECTORS (X)  : origin=0x00000000 length=0x00000020
    FLASH0  (RX) : origin=0x00000020 length=0x0017FFE0
    FLASH1  (RX) : origin=0x00180000 length=0x00180000
    STACKS  (RW) : origin=0x80000000 length=0x00080000
    RAM     (RW) : origin=0x08000000 length=0x00040000


    SDRAM1  (RWX): origin=0x80080000 length=0x0017FFFF
    SDRAM2  (RWX): origin=0x80200000 length=0x001FFFFF
    SDRAM3  (RWX): origin=0x80400000 length=0x001FFFFF
    SDRAM4  (RWX): origin=0x80600000 length=0x001FFFFF
}

/*----------------------------------------------------------------------------*/
/* Section Configuration                                                      */

SECTIONS
{
    .intvecs : {} > VECTORS
    .text    : {} > FLASH0 | FLASH1
    .const   : {} > FLASH0 | FLASH1
    .cinit   : {} > FLASH0 | FLASH1
    .pinit   : {} > FLASH0 | FLASH1
    .bss     : {} > SDRAM1
    .data    : {} > SDRAM1
    .stack   : {} > STACKS
    .sysmem  : {} > SDRAM1

   .sdram_section2 : RUN = SDRAM2, LOAD = FLASH0|FLASH1, TABLE(BINIT)
   .sdram_section3 : RUN = SDRAM3, LOAD = FLASH0|FLASH1, TABLE(BINIT)
   .sdram_section4 : RUN = SDRAM4, LOAD = FLASH0|FLASH1, TABLE(BINIT)
}

Is there any way to put the stack in the SDRAM ?

Regards,

Antoine

  • Antoine,

    you could change:

    .stack   : {} > STACKS

    to
        .stack   : {} > SDRAM


    for more information see the linker documentation




    but i would not recommend this. the external SDRAM is not protected by ECC and access time is much slower.

    -Anthony
  • Hi Anthony,

    STACKS has its origin in the SDRAM (0x8000000). So my linker configuration should be compliant with your answer. According to the linker documentation .stack section should appear in the segment allocation map but it does not.

    I know about the bad performance that will come with putting the stack in the SDRAM. I want to evaluate the drop of performance.

    My CCS project is in the attached archive.

    Regards,

    Antoine

    6131.ti_perf_meas.zip

  • Good point - missed that.

    sys_core.asm seems to be controlling the location of the stack:

    ;-------------------------------------------------------------------------------
    ; Initialize Stack Pointers

    .def _coreInitStackPointer_
    .asmfunc

    _coreInitStackPointer_

    cps #17
    ldr sp, fiqSp
    cps #18
    ldr sp, irqSp
    cps #23
    ldr sp, abortSp
    cps #27
    ldr sp, undefSp
    cps #31
    ldr sp, userSp
    cps #19
    ldr sp, svcSp
    bx lr

    userSp .word 0x08000000+0x00001000
    svcSp .word 0x08000000+0x00001000+0x00000100
    fiqSp .word 0x08000000+0x00001000+0x00000100+0x00000100
    irqSp .word 0x08000000+0x00001000+0x00000100+0x00000100+0x00000100
    abortSp .word 0x08000000+0x00001000+0x00000100+0x00000100+0x00000100+0x00000100
    undefSp .word 0x08000000+0x00001000+0x00000100+0x00000100+0x00000100+0x00000100+0x00000100


    I tried changing the "RAM Base Address" on the <device>->RAM tab but this seems to be fixed.
    So you would need to override this by manually editing the sys_core.asm file.

    You can make a copy of the file w. a different name for now and exclude the generated file from the build.
    (Because the user code comments do not appear in C).
    I'll submit a ticket on the issue but it's a bit unusual of a use case IMO as this isn't really
    how the part is designed to operate.
  • Antoine,

    Did you change this section and get it to work?   Here's the ticket number SDOCM00122164  still showing as just submitted.

  • Hi Anthony,

    As the EMIF is initialized using the stack it is not possible to change the address of the stack pointers before the init is done. But if the addresses are changed after it works.

    Based on _coreInitStackPointer_, I have added a function in sys_core.asm to modify the stack addresses (see below). This function is called between the end of the initialization and the call of the main() application :

        .def     _coreSetStackPointerInSDRAM_
        .asmfunc
    
    _coreSetStackPointerInSDRAM_
    
            cps   #17
            ldr   sp,       fiqSpSDRAM
            cps   #18
            ldr   sp,       irqSpSDRAM
            cps   #23
            ldr   sp,       abortSpSDRAM
            cps   #27
            ldr   sp,       undefSpSDRAM
            cps   #31
            ldr   sp,       userSpSDRAM
            cps   #19
            ldr   sp,       svcSpSDRAM
            bx    lr
    
    userSpSDRAM  .word 0x80000000
    svcSpSDRAM   .word 0x80000000+0x0007FB00
    fiqSpSDRAM   .word 0x80000000+0x0007FB00+0x00000100
    irqSpSDRAM   .word 0x80000000+0x0007FB00+0x00000100+0x00000100
    abortSpSDRAM .word 0x80000000+0x0007FB00+0x00000100+0x00000100+0x00000100
    undefSpSDRAM .word 0x80000000+0x0007FB00+0x00000100+0x00000100+0x00000100+0x00000100
    
        .endasmfunc

    Thanks for your help.

    Antoine