running code out of the stack

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

running code out of the stack

997 Views
hajianik
Senior Contributor I

Hi,

I was wondering if any one of the brilliant mind would show me how to load the stack and run the code from there.

I know how to use linker script file to run code out of RAM.

I'm exclusively talking about the stack. I have seen other people do it long time ago, and I know it could be done.

Please don't give me "Stack is used to save machine state" and things of that nature.

 

Thanks,

Koorosh Hajiani

0 Kudos
4 Replies

969 Views
stanish
NXP Employee
NXP Employee

Hi,

could you describe more in the detail what are you trying to achieve by that construction?

Thanks,

Stan

0 Kudos

960 Views
hajianik
Senior Contributor I

Hi Stan,

I just need to run a function from RAM. This is concerning the  the launching command to read/write to Program Once in program flash IFR.

I've done this using a linker script file.I've seen other people use stack to run from RAM however it was a long time ago.

was wondering if any of the brilliant mind out there has an idea!!!!

 

Thanks,

Koorosh

0 Kudos

943 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

well, running some function directly from stack is quite unusual way and not much effective - in my opinion. First of all you need to allocate local memory, then memcopy your "function implementation" into allocated memory from flash and after that you can call function pointer. 

Easiest way is just call function from RAM (as you already did). There is a macro in S32K1xx SDK for running functions from RAM - here is simple example: 


START_FUNCTION_DECLARATION_RAMSECTION
void CCIF_Callback(void)
END_FUNCTION_DECLARATION_RAMSECTION

 

Hope it helps. 

Jiri 

0 Kudos

939 Views
hajianik
Senior Contributor I

Hi

I know all that.

My question was/is  specifically on running function out of stack.

Thanks,

0 Kudos