Steps to run a Bootloader from RAM


For a project (using R7FA2L1AB2DFL), a bootloader which can update our firmware is needed. We have decided to copy this bootloader in RAM, and execute it from there since otherwise code flash memory cannot be programmed. We plan to access this bootloader by setting a certain random KEY in no_init RAM (setting this is triggered by an external command) and then triggering a reset. Upon reset and before jumping into our application, we check for this KEY and whether it is set or not. If it is set, we can copy our bootloader from code flash to RAM, and proceed to flash the memory. 

For me, it is still unclear what a good way would be to realize this process. There are a couple of points in particular

  • Where do I actually copy the bootloader from FLASH to RAM, can I do this best in the FSP system.c file?

  • How do I take preinitialized variables into account?

  • How do I manage that the linker takes into account that the bootloader is executed from SRAM (absolute vs relative addresses)

Something like an example of similar functionality would be of great help here, as the general picture of this process is still quite unclear to me. 

Thanks in advance.