Hi all,
Actually there no need for a modification of the bootloader for that. In the linker script of the application, you need to place your RAM function into RAM but also in flash. See this extract of our linker script:
/* MAIN TEXT SECTION */
.text : ALIGN(4)
{
__section_table_start = .;
__data_section_table = .;
LONG(LOADADDR(.data));
LONG( ADDR(.data));
LONG( SIZEOF(.data));
LONG(LOADADDR(.ram_func));
LONG( ADDR(.ram_func));
LONG( SIZEOF(.ram_func));
__data_section_table_end = .;
__bss_section_table = .;
LONG( ADDR(.bss));
LONG( SIZEOF(.bss));
__bss_section_table_end = .;
__section_table_end = . ;
/* End of Global Section Table */
*(.after_vectors*)
} > PROGRAM_FLASH
(...)
_etext = .;
/* RAM functions (SRAM_ITC) */
.ram_func : ALIGN(4)
{
FILL(0xff)
PROVIDE(__start_ram_func = .) ;
*(vtable)
*(.ramfunc*)
KEEP(*(CodeQuickAccess))
KEEP(*(DataQuickAccess))
*(RamFunction)
. = ALIGN(4) ;
PROVIDE(__end_ram_func = .) ;
} > SRAM_ITC AT>PROGRAM_FLASH
You can see that RAM functions are linked in ITC but place in flash. At startup, in ResetISR function, the application copies the code defined in __data_section_table into RAM. This table is defined in the linker script (see above).
// Load base address of Global Section Table
SectionTableAddr = &__data_section_table;
// Copy the data sections from flash to SRAM.
while (SectionTableAddr < &__data_section_table_end) {
LoadAddr = *SectionTableAddr++;
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
data_init(LoadAddr, ExeAddr, SectionLen);
}
So there is almost nothing to do but modifying the linker script a little.
Hope this can help someone.
Hugo