0

I'm out of RAM and need to move my non-critical speed code to flash. Need to know the linker 'attribute' command to select flash.

I'm using mbed online IDE to build for NUCLEO (STM32)f091RC.

But maybe mbed uses a common attribute setting for flash.

I cannot find any help on mbed linker .

Doug Null
  • 7,989
  • 15
  • 69
  • 148
  • I have no experience with _embed online IDE_ but as I understand all functions by default place to flash. Most compilers have special attributes for design code to be runned from RAM. And there need special loaders for move parts of your compiled firmware from flash to RAM at boot time - such functions can be created automatically by some compilers. So, are you sure that your code work in RAM? – imbearr Aug 29 '16 at 13:41

1 Answers1

0

I don't know your linker file structure, but the most probably is that you have .text section which is written in FLASH (99% sure). If you want to force section of your function you must use this attribute just before declaration and definition: __attribute__ ((long_call, section (".text"))) You can also make a macro to this like that:

#define FLASH_FUNC __attribute__ ((long_call, section (".text")))

and use it like this:

in .h file:

FLASH_FUNC void MyFoo(void);

int .c file

FLASH_FUNC void MyFoo(void)
{
    //foo
}
legier
  • 129
  • 1
  • 9