I'm trying to execute a control function as quickly as possible from SRAM on an STM32F3xx using GCC (System Workbench toolchain).
__attribute__((ramfunc)) f1(void) {
// Set GPIO pin
// Do something that is faster from RAM
// Clear GPIO pin
}
void f2(void) {
// Set GPIO pin
// Do something that is faster from RAM
// Clear GPIO pin
}
How can I check to make sure that it is actually executing from RAM? Will printing its address tell me the flash location or the RAM location?
printf("f1 address = 0x%p\n", f1);
printf("f2 address = 0x%p\n", f2);
Is there an operation that will have an extremely different timing behavior if I measure it with an oscilloscope that I can compare?
f1();
f2();
From the output.map
file:
.text.f1 0x0000000008007470 0x18 src/controller.o
.text.f2 0x0000000008007488 0x18 src/controller.o
From the log:
f1 address = 0x0x8007471
f2 address = 0x0x8007489
Relevant links:
http://www.openstm32.org/forumthread5894
https://www.silabs.com/community/mcu/32-bit/forum.topic.html/how_can_i_executeco-6Zv7
Excerpt from LinkerScript.ld
file showing my added ramfunc
section that doesn't seem to be enough:
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.ramfunc) /* .ramfunc sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
Best Answer
Wow, OK, thanks for clarifying where RAM starts on this device, Chris Stratton.
It looks like I finally proved that it can work on a more isolated project.
Control experiment:
After qualifying the function signature:
I get log line:
Note that this required adding the
.ramfunc
line to the linker script:To directly answer the original question, yes, you should be able to print the address of the function and see that it is in a different region OR check the .map file OR use the debugger to check this address.