EmbDev.net

Forum: ARM programming with GCC/GNU tools Execute Code From RAM


Author: Stefan S. (dangermouse)
Posted on:

Rate this post
0 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

Author: A.K. (Guest)
Posted on:

Rate this post
0 useful
not useful
>   IntCodeRAM  (rx) : ORIGIN = 0x00000000, LENGTH = 256k
>   ReservedRAM (rw) : ORIGIN = 0x20000000, LENGTH = 2k
>   IntDataRAM  (rw) : ORIGIN = 0x20000200, LENGTH = 62k

0x200 is 512, not 2048 (2K).

Author: Stefan S. (dangermouse)
Posted on:

Rate this post
0 useful
not useful
A.K. wrote:
>>   IntCodeRAM  (rx) : ORIGIN = 0x00000000, LENGTH = 256k
>>   ReservedRAM (rw) : ORIGIN = 0x20000000, LENGTH = 2k
>>   IntDataRAM  (rw) : ORIGIN = 0x20000200, LENGTH = 62k
>
> 0x200 is 512, not 2048 (2K).

Thanks, just a little typing error. But this isn't the Problem.

Regards,

Stefan

Author: A.K. (Guest)
Posted on:

Rate this post
0 useful
not useful
To permanently place some functions in RAM, you do not have to define a
separate memory region. The linker script can place them the into the
same RAM memory region as the data.

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 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...
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm...
both not for STR711 but the method is not target-dependent

Martin Thomas

Author: Stefan S. (dangermouse)
Posted on:

Rate this post
0 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...
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm...
> 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

Author: A.K. (Guest)
Posted on:

Rate this post
0 useful
not useful
If you have several functions to execute in RAM, but need only one at a
time placed there, look for the "Overlay" command in the GNU LD
documentation:
http://www.gnu.org/software/binutils/manual/ld-2.9...

Author: Bram Dobbelaar (Guest)
Posted on:

Rate this post
0 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...
> 
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm...
> 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;

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 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?

Author: Bram Dobbelaar (Guest)
Posted on:
Attached files:

Rate this post
0 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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.