Execute Code From RAM

OP #1173311
Rate this post
useful
not useful
Hello!

I'm working on a In Application Programming solution for an STR711
Microcontroller. There are some reasons for me, to execute the routines,
which will write the flash banks from RAM.


So here is my question:

I compiled this routines for executing them in RAM.
I reserved some space for this code by defining a new memory range in
the linker script ( .ld )

MEMORY
{

  IntCodeRAM  (rx) : ORIGIN = 0x00000000, LENGTH = 256k
  ReservedRAM (rw) : ORIGIN = 0x20000000, LENGTH = 2k
  IntDataRAM  (rw) : ORIGIN = 0x20000200, LENGTH = 62k

}

It works, but does someone knows a more flexible method?
The main Problem is, i think, to find an empty space in RAM.

Thanks, Stefan
Guest #1173315
Rate this post
useful
not useful
As already mentioned by A.K. an extra entry in "MEMORY" is not needed.

You could simple try use this function attribute:
_attribute_ ((long_call, section (".data")))
This will assign the function declared with the attribute to the
".data". No modification in the linker-script should be needed for this.

An addtional section (i.e. ".fastrun") might be useful later since the
locations of such extra sections can be changed easily in the
linker-script without side-effect on the "real" .data.

May serve as examples:
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index.html#gcc_ramfunc
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index_at91.html#at91_gamma
both not for STR711 but the method is not target-dependent

Martin Thomas
OP #1173316
Rate this post
useful
not useful
Martin Thomas wrote:
> As already mentioned by A.K. an extra entry in "MEMORY" is not needed.
>
> You could simple try use this function attribute:
> _attribute_ ((long_call, section (".data")))
> This will assign the function declared with the attribute to the
> ".data". No modification in the linker-script should be needed for this.
>
> An addtional section (i.e. ".fastrun") might be useful later since the
> locations of such extra sections can be changed easily in the
> linker-script without side-effect on the "real" .data.
>
> May serve as examples:
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index.html#gcc_ramfunc
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index_at91.html#at91_gamma
> both not for STR711 but the method is not target-dependent
>
> Martin Thomas

Hello!

At first, thanks for all your help. I read and tried the examples above.
The Problem is, that i don't want to place the code permamently in RAM.
I don't want to wast 3kB of RAM, if I don't need the functions.
Sorry guys, im very new to programming ARM.

Regards,

Stefan
Guest #1173318
Rate this post
useful
not useful
Martin Thomas wrote:
> As already mentioned by A.K. an extra entry in "MEMORY" is not needed.
>
> You could simple try use this function attribute:
> _attribute_ ((long_call, section (".data")))
> This will assign the function declared with the attribute to the
> ".data". No modification in the linker-script should be needed for this.
>
> An addtional section (i.e. ".fastrun") might be useful later since the
> locations of such extra sections can be changed easily in the
> linker-script without side-effect on the "real" .data.
>
> May serve as examples:
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index.html#gcc_ramfunc
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/index_at91.html#at91_gamma
> both not for STR711 but the method is not target-dependent
>
> Martin Thomas

Dear Martin,

I have a quiestion about the function attribute, i want to write some
bytes to flash. My function is located in RAM, this works only with
functions without function arguments. Suppose you have a flash write
function with address and data arguments. Can we pass this arguments as
well.

Regards, Bram Dobbelaar


#define FASTRUN _attribute_ ((long_call, section (".data")))

FASTRUN void Erase_sector1(void);
FASTRUN void Word_program(void);
FASTRUN void FLASH_WWrite(u32 XtargetAdd, u32 Xdata);
u32 Addres,data;
Moderator #1173319
Rate this post
useful
not useful
Bram Dobbelaar wrote:
> I have a quiestion about the function attribute, i want to write some
> bytes to flash. My function is located in RAM, this works only with
> functions without function arguments. Suppose you have a flash write
> function with address and data arguments. Can we pass this arguments as
> well.

I have not noticed this before. Can you step though the code with a
debugger to see what is going on?
Guest #1173320
Rate this post
useful
not useful
Martin Thomas wrote:
> Bram Dobbelaar wrote:
>> I have a quiestion about the function attribute, i want to write some
>> bytes to flash. My function is located in RAM, this works only with
>> functions without function arguments. Suppose you have a flash write
>> function with address and data arguments. Can we pass this arguments as
>> well.
>
> I have not noticed this before. Can you step though the code with a
> debugger to see what is going on?


Thanks for you're answer. I have an another probably related problem. I
can erase flash and write word in flash memory (i use the attribute as
mentioned ). It only works one time after programming the flash. After a
power down and up the copied function in RAM are not working. Do i need
to change the linker script to be sure the ram functions are loaded in
memory. I want to make a flash table that can be changed (error
correction for a sensor application).
Probably i will do this in eeprom, but my eeprom was to small, so i
thought maybe a table in flash is possible.


Regards, Bram Dobbelaar
Attached files:

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now