I am developing an application for the STM32L151QC device using gcc and my application needs the facility to perform In-Application Programming. The application update will be contained in an external hardware module which is connected via a UART. Software for controlling the module and for retreiving files from it will exist in my application. Obviously I want to reuse this software as well as existing interrupt routines for using the UART etc.
I have read the application note AN3310 "Updating firmware in STM32L1xx microcontrollers through in-application programming using the USART" and this seems to use "#define __RAM_FUNC FLASH_Status __attribute__((section(".data")))" from the peripheral library to generate a macro which places functions etc in SRAM.
However I would prefer not to use up my SRAM space with functions when not required so would rather have all the relevant functions reside in flash when not in In Application Programming mode. So ideally I would like a way to generate a coherent subsystem which normally lives in flash but which can be copied into SRAM when required and run from there.
So can anyone tell me how to use the gcc toolset to ensure a disparate selection of functions are contiguous in Flash and then find start and end of the area of flash containing them so as to be able to dma the code from flash into SRAM ?
I have found references for remapping the SRAM after copying it, but as I say, I have no requirement to boot from SRAM, only to execute from it.