AnsweredAssumed Answered

Can you execute code directly from RAM

Question asked by Mike Mandeville on Apr 9, 2015
Latest reply on Apr 9, 2015 by Mark Butcher

I am currently running into some issues with our In Application Programming.   What I am trying to do is to copy the flash routines into RAM then call them.  I know have copied the routines into RAM correctly (they reside at 0x1FFF0000). I also tried to put them in the upper SRAM region as well.  When I step through the code... as soon as I try to execute from RAM, I get a USAGE FAULT, unaligned access.  But the address is cast as a ULONG*.  I also manually check the address and it is 32-bit aligned. 

What am I missing?  IS there some settings I need to enable to allow the executing code from RAM?

What I did was a create a section in the scatter file that defines the RAM section (I labeled it IAP, but that doesn't matter) I'm going to copy the flash upgrade routine to:

IAP 0x1FFFF000 UNINIT 0x000FFF ;
appFirmwareUpgradeRam.o (*)

and in that I declare the flashfunc().  Then I write to the address of that function. (I still get a usage fault, though). And a few related questions:

1) Does the Kinetis have some protection or settings that may prevent execution from RAM?
2) Does the Kinetis have user/privilege modes that need to be manipulated?
3) The K64 only has a thumb mode. How does that affect my memory addressing of instructions?