There is a way to define just specific functions in RAM, which is what I do. I got these instructions from Martin Thomas over at
http://embdev.net/forum/arm-gcc, so all credit goes to him. Now let me just find what I had to change... I know it required a couple of changes in different places... Been a long time since I looked at this code

OK, so here are the two functions that I have in RAM
Code:
RAMFUNC int AT91F_Flash_Status (unsigned int Mask)
{
unsigned int status;
status = 0;
//* Wait the end of command
while ((status & Mask) != Mask )
{
status = AT91C_BASE_MC->MC_FSR;
}
return status;
}
RAMFUNC void flushPage(U32 nPageAddr)
{
U32 nPage = nPageAddr >> 8;
// Set number of Flash Waite sate
// SAM7A3 features Single Cycle Access at Up to 30 MHz
// if MCK = 47923200, 72 Cycles for 1.5 µseconde (field MC_FMR->FMCN)
AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN) & (72 <<16)) | AT91C_MC_FWS_1FWS;
// Write the write page command
AT91C_BASE_MC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_START_PROG | (AT91C_MC_PAGEN & (nPage << 8));
// OPTIONAL WRITE COMMAND--- THIS ONE WON'T ERASE MEMORY FIRST!
//AT91C_BASE_MC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_START_PROG | (AT91C_MC_PAGEN & (nPage << 8) | AT91C_MC_NEBP);
// Wait the end of command
AT91F_Flash_Status(AT91C_MC_EOP);
}
RAMFUNC is defined as:
Code:
#define RAMFUNC __attribute__ ((long_call, section (".fastrun")))
Now we get to modify the linker file! For me, that file is: AT91SAM7A3-ROM.ld
Head down to where it creates the .data section, and add in .fastrun at the end of it:
Code:
/* .data section which is used for initialized data */
.data : AT (_etext)
{
_data = .;
PROVIDE (__os_data_start = .);
*(.osData)
PROVIDE (__os_data_end = .);
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
SORT(CONSTRUCTORS) /* mt 4/2005 */
. = ALIGN(4);
*(.fastrun) /* "RAM-Functions" */ /* added by mthomas */
} > RAM
Your linker script likely will not have an .osData section, that's something else I added. It may or may not have the SORT(CONSTRUCTORS) either, as that is for getting C++ to work.
I believe those are the only two changes you have to make. Hopefully it'll work for you!