cancel
Showing results for 
Search instead for 
Did you mean: 

problem of code in ram

christophe239955
Associate II
Posted on August 13, 2007 at 10:21

problem of code in ram

3 REPLIES 3
christophe239955
Associate II
Posted on August 10, 2007 at 07:41

I need to write in the data flash, and I can do it only from RAM

1st solution : I'll put all the code in RAM

How to load code from flash to ram?

I read in one datafile that (8150.pdf) :

- the mechanism consisting in loading a user code in RAM is fully defined by ST.

Where can I have this?

2nd solution : to put the FLASH function in ram

for this I'm using :

#define RAM_FUNC __attribute__((long_call,section(''.ramsection'')))

and in ram.ld I'm defining the ramsection

But the problem is when I'm switching off the system and swithing ON the software, the code in ram is lost(normal because it is not in flash).

How can I put this part of software in ram but to keep store during switching OFF

Thanks

mehdi239955
Associate II
Posted on August 10, 2007 at 10:58

Hi ch2;

Could you attach the linker you're using in order to verify if something is wrong?

:-]

I thing the loop for Copying the data from FLASH to RAM doesn't copy the ramsection you're using.

Follows the code which copies the data from FLASH to RAM:

Quote:

/* ;copy the initial values for .data section from FLASH to RAM */

ldr R1, =_sidata /* provided by linker*/

ldr R2, =_sdata /* provided by linker*/

ldr R3, =_edata /* provided by linker*/

_reset_inidata_loop:

cmp R2, R3

ldrlO R0, [R1], #4

strlO R0, [R2], #4

blO _reset_inidata_loop

and here how should be the Section declaration in the linker:

first,

Quote:

.data : AT ( _sidata )

{

_sdata = . ;

*(.data .data.*)

*(.gnu.linkonce.d.*)

. = ALIGN(4);

*(.ramsection .ramsection.*)

} >RAM

. = ALIGN(4);

_edata = .;

or ,

Quote:

.data : AT ( _sidata ) /* AT : load region: means load at _sidata address in the flash */

{

. = ALIGN(4);

_sdata = . ;

*(.data)

. = ALIGN(4);

_edata2 = . ;

} >RAM

.ramsection :

{

. = ALIGN(4);

_sdata2 = . ;

*(.ramsection)

. = ALIGN(4);

_edata = . ;

} >RAM

Personally I prefer the last solution but the first works as well. :o

Best regards,

MBS

[ This message was edited by: MBS on 10-08-2007 14:39 ]

christophe239955
Associate II
Posted on August 13, 2007 at 10:21

thanks