1259860_en-US

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

1259860_en-US

1259860_en-US

running code out of the stack

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

Re: running code out of the stack

Hi

I know all that.

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

Thanks,

Re: running code out of the stack

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 

Re: running code out of the stack

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

Re: running code out of the stack

Hi,

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

Thanks,

Stan

Tags (1)
No ratings
Version history
Last update:
‎12-03-2025 01:40 AM
Updated by: