Topic : function execution from ram

Forum : ARM

Original Post
Post Information Post
December 11, 2007 - 1:37pm
Guest

hi,

I'm using Reva v2.10 with RIDE (BN747) and an STR912FAW44X6. For my project i need to store parameter und structures in the flash, it should be possible to change the values so that they are persistent in flash. My program code is in flashbank0. flashbank1 (32kB) is reserved for another task of my project. My purpose is to write and erase an area in flashbank0 from my execution code which is in same bank. For this i need a function executed in ram, i know. I have adapted the linker scripts for my requirements.

memory mapping >>>

Quote:
MEMORY
{

FLASH (rx) : ORIGIN = 0, LENGTH = 448K

USERSPACE (xrw) : ORIGIN = 0x00070000, LENGTH = 64K /*space between 448 - 512 KB in FLASH bank0*/

FLASHB1 (rw) : ORIGIN = 0x00080000, LENGTH = 32K

EXTMEMB0 (rx) : ORIGIN = 0x30000000, LENGTH = 64M

EXTMEMB1 (rx) : ORIGIN = 0x34000000, LENGTH = 64M

EXTMEMB2 (rx) : ORIGIN = 0x38000000, LENGTH = 64M

EXTMEMB3 (rx) : ORIGIN = 0x3C000000, LENGTH = 64M

RAM (xrw) : ORIGIN = 0x50000000, LENGTH = 96K
}


this is for my USERSPACE section >>>
Quote:
.usertext :
{
. = ALIGN(4);
*(.usertext)
. = ALIGN(4);
} >USERSPACE

for example to use this : int __attribute__((section(".usertext"))) flash_var;

for my ram function i have adapted the .data section in this way >>>

Quote:
.data : AT ( _sidata )
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_sdata = . ;

*(.data)
*(.data.*)

. = ALIGN(4);
*(.gnu.linkonce.d*)

*(.fastrun) /* !!!! "RAM-Function" example */
. = ALIGN(4);


/* This is used by the startup in order to initialize the .data secion */
_edata = . ;


} >RAM


example of function declaration:__attribute__((section(".fastrun"))) void FMI_BANK0_Write(void)

But when i want to run my program code, the linker reports an error like section.data[000037fc -> 00003a37] overlaps section .fastrun [000037fc -> 00003867]

map report from linker >>>

Quote:
*(.glue_7t)
0x000037fc . = ALIGN (0x4)
0x000037fc _etext = .
0x000037fc _sidata = _etext

.fastrun 0x000037fc 0x6c
.fastrun 0x000037fc 0x6c e:/torsten dittrich/raisonance_st9/scpi_arm/ramfunc.o
0x000037fc FMI_BANK0_Write

.data 0x50000000 0x23c load address 0x000037fc
0x50000000 . = ALIGN (0x4)
0x50000000 _sdata = .
*(.data)
.data 0x50000000 0x4 e:/torsten dittrich/raisonance_st9/scpi_arm/main.o
0x50000000 str_pt
.data 0x50000004 0x1a4 e:/torsten dittrich/raisonance_st9/scpi_arm/para.o
0x50000004 para_table
.data 0x500001a8 0x90 e:/torsten dittrich/raisonance_st9/scpi_arm/scpi.o
0x500001a8 cmd1_table
.data 0x50000238 0x4 /cygdrive/c/programme/gnuarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/libc.a(ctype_.o)
0x50000238 __ctype_ptr
*(.data.*)
0x5000023c . = ALIGN (0x4)
0x5000023c _edata = .


I'm not an expert in view of linker syntax, but i don't understand why the .fastrun section is located in adresses which belongs to the flash (000037fc...). Maybe there is a simple mistake i made. Hope anyone can help me.

thanks a lot in advance...
best regards
T.Dittrich

Replies
Post Information Post
+1
0
-1
December 14, 2007 - 2:06pm
Guest

my problem in a short way: How to run Code from RAM?
best regards

+1
0
-1
December 17, 2007 - 8:21am
Guest

solution: using __attribute__ ((long_call, section (".data"))) instead of own section in .data section works fine

+1
0
-1
December 17, 2007 - 9:20am
Guest

Hello,

if you use your own section in .data, adding "-mlong-calls" to GCC command-line (Options->Project->GCC-ARM->More) would do the trick too. Can you give it a try?

regards
Lionel

+1
0
-1
December 17, 2007 - 12:39pm
Guest

edit: in spite of adding this to options I'm not able to write my function in my own ram section, i can only use longcall in view of the .data section...

regards

+1
0
-1
December 18, 2007 - 8:55am
Guest

a further problem: i can declare variable in my own flash section (.usertext), i can erase and write this section with the FMI library functions from ST executing from ram. But when i want to declare and initialize some global constant variables or structures in .usertext i get this error message again, but only in view of my .usertext section.

section .data[00003ac0->0000425b] overlaps section .usertext[00003ac0->00003ac0]

.data section is the part which will be copied in startup routine from flash0 to ram, for intializing some variables, right?In my Opinion the overlapping shouldn't happen because my .usertext section begins at address 0x0007000.

Maybe someone can help?

best regards