EmbeddedRelated.com
Forums

Copy to and execution from RAM

Started by Klaus Kragelund December 22, 2017
Am 22.12.2017 um 21:13 schrieb Klaus Kragelund:
> Copy code that needs to run to RAM > Move program counter to first RAM address to start RAM execution > Write to flash, and keep running in RAM > When finished writing to flash, return code execution to flash (that way only limited code needs to be copied to RAM). Move program counter to flash
Yes, it's that easy. If you write the RAM code in assembler, you can make sure that no relocation of adress data is necessary. If you don't, you should tell the linker of that code segment in RAM. Either an extra segment or an overlay. There may be some security / MMU that prevents code execution in RAM / segments with write enabled. Be sure not to trigger any interrupt, as the vector table usually resides in FLASH. Imho ARM lets you relocate that into RAM. I remember a TI app note about that for MSP430, but other vendors will have that too, as this is a well known problem of boot loaders. Maybe there is something like that hard coded into that uC? cheers Gunther