cancel
Showing results for 
Search instead for 
Did you mean: 

RAM function execution

torstendittrich
Associate II
Posted on February 06, 2008 at 16:21

RAM function execution

6 REPLIES 6
torstendittrich
Associate II
Posted on May 17, 2011 at 09:48

Do nobody knows how to run code from ram? (Using RIDE from raisonance) I have read a lot about the attribute ''__ramfunc'', but i think it's a functionality which is implementet in IAR workbench only...i'm right?

best regards

torstendittrich
Associate II
Posted on May 17, 2011 at 09:48

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 >>>

Code:

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 >>>

Code:

.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 >>>

Code:

.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 >>>

Code:

*(.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

sarao
Associate II
Posted on May 17, 2011 at 09:48

Does anyone have a C function to do the same?

thanks.

-jeremy

zouhair
Associate II
Posted on May 17, 2011 at 09:48

Hi,

please refer to this topic:

http://www.st.com/mcu/forums-cat-5047-21.html

regarding the __ramfunc it can be used only with IAR.

Rgds

sarao
Associate II
Posted on May 17, 2011 at 09:48

I did not find that link helpful. Perhaps I didn't understand it. The Keil uVision kit provides a nice example of running function from ram. It is small and easy to understand. So I'm starting there.

What I would like is an example program of how to write (and rewrite) data to some area of flash (say Bank 0 Sector 3), that is persistent between resets.

For example: user sends data over serial port. data is stored to flash. User powers down processor. 3 days later processor is powered up. Data is read from flash. Repeat.

If anyone has an example it would be very much appreciated.

sarao
Associate II
Posted on May 17, 2011 at 09:48

FYI: I am using the Keil uVision IDE and Realview ARM toolchain.

I think the basic problem is something like:

1. Reserve a sector of flash in bank 0

2. inform the linker that this is for data

3. create methods that executes from RAM that read and write to this reserved sector.

This should be a simple problem to solve. I think it is mostly a problem of configuration.

Anyone have a small sample to do this that they would like to share?

Is Mirou still around? 😉