tags:

views:

62

answers:

1

I'm writing a program that updates flash memory. While I'm erasing/writing flash I would like to be executing from RAM. Ideally I'd link my code to an execution region that's stored in flash that on startup I would copy to the RAM location to which it is linked.

I don't include any of the normal generated C/C++ initialization code so I can't just tag my function as __ram.

If I could do the above then the debuggers symbols would be relevant for the copied to RAM code and I'd be able to debug business as usual.

I'm thinking that something along the lines of OVERLAY/RELOC might help but I'm not sure.

Thanks,

A: 

Maybe your application code can do it manually. Something like

  pSourceAddr = &FunctionInFlash;
  pDestAddr = &RamReservedForFunction;
  while(pSourceAddr <= (&FunctionInFlash+FunctionSize))
  {  *pDestAddr++ = *pSourceAddr++; 
  };

  typedef int (*RamFuncPtr)(int arg1); //or whatever the signature is..

 result = ((RamFuncPtr)&RamReservedForFunction)(argument1);

You should be able to get the linker definition file to export symbols for the FunctionInFlash and RamReservedForFunction addresses.

AShelly