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.

TMS570LS3137 stack allocation issue

Other Parts Discussed in Thread: HALCOGEN

1348.ARM_DSR_CSCI.txt

3162.ARM_DSR.txt

Hi,

I am using four different projects in my build and all have
a different *.cmd file for each project, in that same stack memory area
(0x8000000 to 0x8001500) is allocated for all projects.
so is this the correct way OR do I need to allocate separate stack area
for each project?

Currently, I am not at all seeing any data in the stack memory as it might
be taking different memory though I mapped in the *.cmd file

Can any one tell me why it is not showing any data.

Please refer the *.cmd, *.map and snap shot for your reference.

Thanks
Sanjeev

  • Sanjeev,

    1. You can allocate stacks anywhere inside the RAM(R/W) area and map it accordingly.

    2. Linker only helps you to reserve that memory location, later stack pointers are to be assigned for the respective stacks during your boot. If you are using Halcogen then refer to _coreInitStackPointer_().

    3. Check where your stack pointer according to the mode you are in (SP/R13) is pointing to so that you know where your current stack is.

    4.Generally stack grows down, typically in Halcogen user stack starts from 0x08001000.

    I'm assuming the above stack settings as default by Halcogen and you have not modified them.

    Hope this helps.

  • Thanks for the reply Karthikeyan.

    In this case, STACK by default starts from 0x08001000 then there is no need to allocate memory space for stack in the *.cmd file .

    Currently I am allocating as below:

    STACKS   (RW)   : origin = 0x08000000, length = 0x001500

    .stack             : > STACKS

    And do you know how much default length will be allocated? if it starts from 0x08001000.

    I have total 4 different projects in the same build, for all 4 projects the same default stack memory(0x08001000) will be allocated? Will it be safer to have a common stack memory across all 4 projects because program control will be keep switching between all 4 projects.

    Thanks

    Sanjeev

  • Sanjeev,

    1.In this case, STACK by default starts from 0x08001000 then there is no need to allocate memory space for stack in the *.cmd file .

    As I already mentioned,

    Linker only helps you to reserve that memory location to be not used by any other sections, later stack pointers are to be assigned for the respective stacks during your boot. If you are using Halcogen then refer to _coreInitStackPointer_(), where your stack pointers are initialized. Pasting a sample code for your reference (USER - 0x08001000 to 0x08000000)

    .def _coreInitStackPointer_
    .asmfunc

    _coreInitStackPointer_

    cps #17
    ldr sp, fiqSp
    cps #18
    ldr sp, irqSp
    cps #19
    ldr sp, svcSp
    cps #23
    ldr sp, abortSp
    cps #27
    ldr sp, undefSp
    cps #31
    ldr sp, userSp
    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

    .endasmfunc