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.

How to get current stack pointer

Other Parts Discussed in Thread: OMAP3530

Hi,

I want to save a U-Boot current stack pointer so I could use my own stack in my stand alone U-boot program. I know already how to set a stack pointer, but I can't manage to get a current stack pointer. I tried:

int OldStackPointer;
int * pStack;

{
    //...
    pStack = &OldStackPointer;
    asm volatile ( "LDR R0, %0" : : "m" (pStack) );
    asm volatile ( "STR SP, [R0]" );
    //...
}

But it doesn't work. The variable OldStackPointer doesn't change.

I also tried:

    asm volatile ( "STR SP, =OldStackPointer" );

But it doesn't compile.

 

I run this on ARM core of OMAP3530 under U-Boot bootloader. I use arm-none-eabi-gcc compiler.

 

Best regards

Thomas